initial commit
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using Indotalent.ConfigBackEnd.Extensions;
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public class CreatePurchaseRequisitionRequest
|
||||
{
|
||||
public DateTime? RequisitionDate { get; set; }
|
||||
public Data.Enums.PurchaseRequisitionStatus RequisitionStatus { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? VendorId { get; set; }
|
||||
public string? TaxId { get; set; }
|
||||
}
|
||||
|
||||
public class CreatePurchaseRequisitionResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? AutoNumber { get; set; }
|
||||
}
|
||||
|
||||
public record CreatePurchaseRequisitionCommand(CreatePurchaseRequisitionRequest Data) : IRequest<CreatePurchaseRequisitionResponse>;
|
||||
|
||||
public class CreatePurchaseRequisitionHandler : IRequestHandler<CreatePurchaseRequisitionCommand, CreatePurchaseRequisitionResponse>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public CreatePurchaseRequisitionHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<CreatePurchaseRequisitionResponse> Handle(CreatePurchaseRequisitionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entityName = nameof(Data.Entities.PurchaseRequisition);
|
||||
var autoNo = await _context.GenerateAutoNumberAsync(
|
||||
entityName: entityName,
|
||||
prefixTemplate: $"PR/{{Year}}/{{Month}}/",
|
||||
ct: cancellationToken
|
||||
);
|
||||
|
||||
var entity = new Data.Entities.PurchaseRequisition
|
||||
{
|
||||
AutoNumber = autoNo,
|
||||
RequisitionDate = request.Data.RequisitionDate,
|
||||
RequisitionStatus = request.Data.RequisitionStatus,
|
||||
Description = request.Data.Description,
|
||||
VendorId = request.Data.VendorId,
|
||||
TaxId = request.Data.TaxId,
|
||||
BeforeTaxAmount = 0,
|
||||
TaxAmount = 0,
|
||||
AfterTaxAmount = 0
|
||||
};
|
||||
|
||||
_context.PurchaseRequisition.Add(entity);
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return new CreatePurchaseRequisitionResponse
|
||||
{
|
||||
Id = entity.Id,
|
||||
AutoNumber = entity.AutoNumber
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Indotalent.Shared.Utils;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public class CreatePurchaseRequisitionItemRequest
|
||||
{
|
||||
public string? PurchaseRequisitionId { get; set; }
|
||||
public string? ProductId { get; set; }
|
||||
public string? Summary { get; set; }
|
||||
public decimal? UnitPrice { get; set; }
|
||||
public double? Quantity { get; set; }
|
||||
}
|
||||
|
||||
public record CreatePurchaseRequisitionItemCommand(CreatePurchaseRequisitionItemRequest Data) : IRequest<bool>;
|
||||
|
||||
public class CreatePurchaseRequisitionItemHandler : IRequestHandler<CreatePurchaseRequisitionItemCommand, bool>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public CreatePurchaseRequisitionItemHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<bool> Handle(CreatePurchaseRequisitionItemCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = new Data.Entities.PurchaseRequisitionItem
|
||||
{
|
||||
PurchaseRequisitionId = request.Data.PurchaseRequisitionId,
|
||||
ProductId = request.Data.ProductId,
|
||||
Summary = request.Data.Summary,
|
||||
UnitPrice = request.Data.UnitPrice ?? 0,
|
||||
Quantity = request.Data.Quantity ?? 0,
|
||||
Total = (request.Data.UnitPrice ?? 0) * (decimal)(request.Data.Quantity ?? 0)
|
||||
};
|
||||
|
||||
_context.PurchaseRequisitionItem.Add(entity);
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
if (!string.IsNullOrEmpty(request.Data.PurchaseRequisitionId))
|
||||
{
|
||||
PurchaseRequisitionHelper.Recalculate(_context, request.Data.PurchaseRequisitionId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public class CreatePurchaseRequisitionValidator : AbstractValidator<CreatePurchaseRequisitionRequest>
|
||||
{
|
||||
public CreatePurchaseRequisitionValidator()
|
||||
{
|
||||
RuleFor(x => x.RequisitionDate).NotEmpty().WithMessage("Date is required");
|
||||
RuleFor(x => x.VendorId).NotEmpty().WithMessage("Vendor is required");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public record DeletePurchaseRequisitionByIdCommand(string Id) : IRequest<bool>;
|
||||
|
||||
public class DeletePurchaseRequisitionByIdHandler : IRequestHandler<DeletePurchaseRequisitionByIdCommand, bool>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public DeletePurchaseRequisitionByIdHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<bool> Handle(DeletePurchaseRequisitionByIdCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.PurchaseRequisition
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken);
|
||||
|
||||
if (entity == null) return false;
|
||||
|
||||
_context.PurchaseRequisition.Remove(entity);
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Indotalent.Shared.Utils;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public record DeletePurchaseRequisitionItemCommand(string Id) : IRequest<bool>;
|
||||
|
||||
public class DeletePurchaseRequisitionItemHandler : IRequestHandler<DeletePurchaseRequisitionItemCommand, bool>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public DeletePurchaseRequisitionItemHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<bool> Handle(DeletePurchaseRequisitionItemCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.PurchaseRequisitionItem
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken);
|
||||
|
||||
if (entity == null) return false;
|
||||
|
||||
var requisitionId = entity.PurchaseRequisitionId;
|
||||
|
||||
_context.PurchaseRequisitionItem.Remove(entity);
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
if (!string.IsNullOrEmpty(requisitionId))
|
||||
{
|
||||
PurchaseRequisitionHelper.Recalculate(_context, requisitionId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public class PurchaseRequisitionItemResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? ProductId { get; set; }
|
||||
public string? ProductName { get; set; }
|
||||
public string? Summary { get; set; }
|
||||
public decimal? UnitPrice { get; set; }
|
||||
public double? Quantity { get; set; }
|
||||
public decimal? Total { get; set; }
|
||||
}
|
||||
|
||||
public class GetPurchaseRequisitionByIdResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? AutoNumber { get; set; }
|
||||
public DateTime? RequisitionDate { get; set; }
|
||||
public Data.Enums.PurchaseRequisitionStatus RequisitionStatus { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? VendorId { get; set; }
|
||||
public string? VendorName { get; set; }
|
||||
public string? VendorStreet { get; set; }
|
||||
public string? VendorCity { get; set; }
|
||||
public string? VendorState { get; set; }
|
||||
public string? VendorZipCode { get; set; }
|
||||
public string? VendorPhone { get; set; }
|
||||
public string? VendorEmail { get; set; }
|
||||
public string? VendorFax { get; set; }
|
||||
public string? CompanyName { get; set; }
|
||||
public string? CompanyStreet { get; set; }
|
||||
public string? CompanyCity { get; set; }
|
||||
public string? CompanyState { get; set; }
|
||||
public string? CompanyZipCode { get; set; }
|
||||
public string? CompanyPhone { get; set; }
|
||||
public string? CompanyEmail { get; set; }
|
||||
public string? CurrencySymbol { get; set; }
|
||||
public string? TaxId { get; set; }
|
||||
public decimal? BeforeTaxAmount { get; set; }
|
||||
public decimal? TaxAmount { get; set; }
|
||||
public decimal? AfterTaxAmount { get; set; }
|
||||
public DateTimeOffset? CreatedAt { get; set; }
|
||||
public string? CreatedBy { get; set; }
|
||||
public DateTimeOffset? UpdatedAt { get; set; }
|
||||
public string? UpdatedBy { get; set; }
|
||||
public List<PurchaseRequisitionItemResponse> Items { get; set; } = new();
|
||||
}
|
||||
|
||||
public record GetPurchaseRequisitionByIdQuery(string Id) : IRequest<GetPurchaseRequisitionByIdResponse?>;
|
||||
|
||||
public class GetPurchaseRequisitionByIdHandler : IRequestHandler<GetPurchaseRequisitionByIdQuery, GetPurchaseRequisitionByIdResponse?>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public GetPurchaseRequisitionByIdHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<GetPurchaseRequisitionByIdResponse?> Handle(GetPurchaseRequisitionByIdQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var company = await _context.Company
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Currency)
|
||||
.OrderByDescending(x => x.IsDefault)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
return await _context.PurchaseRequisition
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Vendor)
|
||||
.Include(x => x.PurchaseRequisitionItemList)
|
||||
.ThenInclude(x => x.Product)
|
||||
.Where(x => x.Id == request.Id)
|
||||
.Select(x => new GetPurchaseRequisitionByIdResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
AutoNumber = x.AutoNumber,
|
||||
RequisitionDate = x.RequisitionDate,
|
||||
RequisitionStatus = x.RequisitionStatus,
|
||||
Description = x.Description,
|
||||
VendorId = x.VendorId,
|
||||
VendorName = x.Vendor!.Name,
|
||||
VendorStreet = x.Vendor!.Street,
|
||||
VendorCity = x.Vendor!.City,
|
||||
VendorState = x.Vendor!.State,
|
||||
VendorZipCode = x.Vendor!.ZipCode,
|
||||
VendorPhone = x.Vendor!.PhoneNumber,
|
||||
VendorEmail = x.Vendor!.EmailAddress,
|
||||
VendorFax = x.Vendor!.FaxNumber,
|
||||
CompanyName = company != null ? company.Name : string.Empty,
|
||||
CompanyStreet = company != null ? company.StreetAddress : string.Empty,
|
||||
CompanyCity = company != null ? company.City : string.Empty,
|
||||
CompanyState = company != null ? company.StateProvince : string.Empty,
|
||||
CompanyZipCode = company != null ? company.ZipCode : string.Empty,
|
||||
CompanyPhone = company != null ? company.Phone : string.Empty,
|
||||
CompanyEmail = company != null ? company.Email : string.Empty,
|
||||
CurrencySymbol = company != null && company.Currency != null ? company.Currency.Symbol : "IDR",
|
||||
TaxId = x.TaxId,
|
||||
BeforeTaxAmount = x.BeforeTaxAmount,
|
||||
TaxAmount = x.TaxAmount,
|
||||
AfterTaxAmount = x.AfterTaxAmount,
|
||||
CreatedAt = x.CreatedAt,
|
||||
CreatedBy = x.CreatedBy,
|
||||
UpdatedAt = x.UpdatedAt,
|
||||
UpdatedBy = x.UpdatedBy,
|
||||
Items = x.PurchaseRequisitionItemList.Select(i => new PurchaseRequisitionItemResponse
|
||||
{
|
||||
Id = i.Id,
|
||||
ProductId = i.ProductId,
|
||||
ProductName = i.Product!.Name,
|
||||
Summary = i.Summary,
|
||||
UnitPrice = i.UnitPrice,
|
||||
Quantity = i.Quantity,
|
||||
Total = i.Total
|
||||
}).ToList()
|
||||
}).FirstOrDefaultAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public class GetPurchaseRequisitionListResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? AutoNumber { get; set; }
|
||||
public DateTime? RequisitionDate { get; set; }
|
||||
public string? VendorName { get; set; }
|
||||
public decimal? AfterTaxAmount { get; set; }
|
||||
public Data.Enums.PurchaseRequisitionStatus RequisitionStatus { get; set; }
|
||||
}
|
||||
|
||||
public record GetPurchaseRequisitionListQuery() : IRequest<List<GetPurchaseRequisitionListResponse>>;
|
||||
|
||||
public class GetPurchaseRequisitionListHandler : IRequestHandler<GetPurchaseRequisitionListQuery, List<GetPurchaseRequisitionListResponse>>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public GetPurchaseRequisitionListHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<List<GetPurchaseRequisitionListResponse>> Handle(GetPurchaseRequisitionListQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.PurchaseRequisition
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Vendor)
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(x => new GetPurchaseRequisitionListResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
AutoNumber = x.AutoNumber,
|
||||
RequisitionDate = x.RequisitionDate,
|
||||
VendorName = x.Vendor!.Name,
|
||||
AfterTaxAmount = x.AfterTaxAmount,
|
||||
RequisitionStatus = x.RequisitionStatus
|
||||
}).ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Indotalent.Data.Enums;
|
||||
using Indotalent.ConfigBackEnd.Extensions;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public class PurchaseRequisitionLookupResponse
|
||||
{
|
||||
public List<LookupItem> Vendors { get; set; } = new();
|
||||
public List<LookupItem> Taxes { get; set; } = new();
|
||||
public List<LookupItem> Products { get; set; } = new();
|
||||
public List<LookupStatusItem> Statuses { get; set; } = new();
|
||||
}
|
||||
|
||||
public class LookupItem
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
|
||||
public class LookupStatusItem
|
||||
{
|
||||
public int Value { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
|
||||
public record GetPurchaseRequisitionLookupQuery() : IRequest<PurchaseRequisitionLookupResponse>;
|
||||
|
||||
public class GetPurchaseRequisitionLookupHandler : IRequestHandler<GetPurchaseRequisitionLookupQuery, PurchaseRequisitionLookupResponse>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public GetPurchaseRequisitionLookupHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<PurchaseRequisitionLookupResponse> Handle(GetPurchaseRequisitionLookupQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = new PurchaseRequisitionLookupResponse();
|
||||
|
||||
response.Vendors = await _context.Vendor.AsNoTracking()
|
||||
.OrderBy(x => x.Name)
|
||||
.Select(x => new LookupItem { Id = x.Id, Name = x.Name })
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
response.Taxes = await _context.Tax.AsNoTracking()
|
||||
.OrderBy(x => x.Name)
|
||||
.Select(x => new LookupItem { Id = x.Id, Name = x.Name })
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
response.Products = await _context.Product.AsNoTracking()
|
||||
.OrderBy(x => x.Name)
|
||||
.Select(x => new LookupItem { Id = x.Id, Name = x.Name })
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
response.Statuses = Enum.GetValues(typeof(PurchaseRequisitionStatus))
|
||||
.Cast<PurchaseRequisitionStatus>()
|
||||
.Select(x => new LookupStatusItem
|
||||
{
|
||||
Value = (int)x,
|
||||
Name = x.GetDescription()
|
||||
}).ToList();
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Indotalent.Shared.Utils;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public class UpdatePurchaseRequisitionRequest
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public DateTime? RequisitionDate { get; set; }
|
||||
public Data.Enums.PurchaseRequisitionStatus RequisitionStatus { get; set; }
|
||||
public string? AutoNumber { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? VendorId { get; set; }
|
||||
public string? TaxId { get; set; }
|
||||
public decimal? BeforeTaxAmount { get; set; }
|
||||
public decimal? TaxAmount { get; set; }
|
||||
public decimal? AfterTaxAmount { get; set; }
|
||||
public DateTimeOffset? CreatedAt { get; set; }
|
||||
public string? CreatedBy { get; set; }
|
||||
public DateTimeOffset? UpdatedAt { get; set; }
|
||||
public string? UpdatedBy { get; set; }
|
||||
}
|
||||
|
||||
public record UpdatePurchaseRequisitionCommand(UpdatePurchaseRequisitionRequest Data) : IRequest<bool>;
|
||||
|
||||
public class UpdatePurchaseRequisitionHandler : IRequestHandler<UpdatePurchaseRequisitionCommand, bool>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public UpdatePurchaseRequisitionHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<bool> Handle(UpdatePurchaseRequisitionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.PurchaseRequisition
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Data.Id, cancellationToken);
|
||||
|
||||
if (entity == null) return false;
|
||||
|
||||
entity.RequisitionDate = request.Data.RequisitionDate;
|
||||
entity.RequisitionStatus = request.Data.RequisitionStatus;
|
||||
entity.Description = request.Data.Description;
|
||||
entity.VendorId = request.Data.VendorId;
|
||||
entity.TaxId = request.Data.TaxId;
|
||||
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
if (!string.IsNullOrEmpty(entity.Id))
|
||||
{
|
||||
PurchaseRequisitionHelper.Recalculate(_context, entity.Id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Indotalent.Shared.Utils;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public class UpdatePurchaseRequisitionItemRequest
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? ProductId { get; set; }
|
||||
public string? Summary { get; set; }
|
||||
public decimal? UnitPrice { get; set; }
|
||||
public double? Quantity { get; set; }
|
||||
}
|
||||
|
||||
public record UpdatePurchaseRequisitionItemCommand(UpdatePurchaseRequisitionItemRequest Data) : IRequest<bool>;
|
||||
|
||||
public class UpdatePurchaseRequisitionItemHandler : IRequestHandler<UpdatePurchaseRequisitionItemCommand, bool>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public UpdatePurchaseRequisitionItemHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<bool> Handle(UpdatePurchaseRequisitionItemCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.PurchaseRequisitionItem
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Data.Id, cancellationToken);
|
||||
|
||||
if (entity == null) return false;
|
||||
|
||||
entity.ProductId = request.Data.ProductId;
|
||||
entity.Summary = request.Data.Summary;
|
||||
entity.UnitPrice = request.Data.UnitPrice ?? 0;
|
||||
entity.Quantity = request.Data.Quantity ?? 0;
|
||||
entity.Total = (request.Data.UnitPrice ?? 0) * (decimal)(request.Data.Quantity ?? 0);
|
||||
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
if (!string.IsNullOrEmpty(entity.PurchaseRequisitionId))
|
||||
{
|
||||
PurchaseRequisitionHelper.Recalculate(_context, entity.PurchaseRequisitionId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace Indotalent.Features.Purchase.PurchaseRequisition.Cqrs;
|
||||
|
||||
public class UpdatePurchaseRequisitionValidator : AbstractValidator<UpdatePurchaseRequisitionRequest>
|
||||
{
|
||||
public UpdatePurchaseRequisitionValidator()
|
||||
{
|
||||
RuleFor(x => x.Id).NotEmpty();
|
||||
RuleFor(x => x.VendorId).NotEmpty().WithMessage("Vendor is required");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user