Refactor code structure for int in alll ids instesd defult using long
This commit is contained in:
@@ -20,7 +20,7 @@ public sealed class AuditService : IAuditService
|
||||
}
|
||||
|
||||
public async Task<PagedResponse<AuditLogDto>> ListLogsAsync(
|
||||
string? entityType, long? entityId, long? userId, DateOnly? from, DateOnly? to, PageQuery query, CancellationToken ct = default)
|
||||
string? entityType, int? entityId, int? userId, DateOnly? from, DateOnly? to, PageQuery query, CancellationToken ct = default)
|
||||
{
|
||||
var q = _logs.Query().AsNoTracking();
|
||||
if (!string.IsNullOrWhiteSpace(entityType)) q = q.Where(l => l.EntityType == entityType);
|
||||
@@ -41,7 +41,7 @@ public sealed class AuditService : IAuditService
|
||||
}
|
||||
|
||||
public async Task<PagedResponse<JournalEntryStubDto>> ListJournalAsync(
|
||||
string? sourceDocType, long? sourceDocId, PageQuery query, CancellationToken ct = default)
|
||||
string? sourceDocType, int? sourceDocId, PageQuery query, CancellationToken ct = default)
|
||||
{
|
||||
var q = _journal.Query().AsNoTracking();
|
||||
if (!string.IsNullOrWhiteSpace(sourceDocType)) q = q.Where(j => j.SourceDocType == sourceDocType);
|
||||
|
||||
@@ -47,7 +47,7 @@ public sealed class CategoryService : ICategoryService
|
||||
|
||||
var byParent = all.ToLookup(c => c.ParentId);
|
||||
|
||||
List<CategoryTreeDto> Build(long? parentId) =>
|
||||
List<CategoryTreeDto> Build(int? parentId) =>
|
||||
byParent[parentId]
|
||||
.Select(c => new CategoryTreeDto(c.CategoryId, c.Name, c.ParentId, Build(c.CategoryId)))
|
||||
.ToList();
|
||||
|
||||
@@ -49,7 +49,7 @@ public sealed class CountService : ICountService
|
||||
_uow = uow;
|
||||
}
|
||||
|
||||
public async Task<CountDto?> GetAsync(long countId, CancellationToken ct = default)
|
||||
public async Task<CountDto?> GetAsync(int countId, CancellationToken ct = default)
|
||||
{
|
||||
var count = await _counts.Query().AsNoTracking().Include(c => c.Lines)
|
||||
.FirstOrDefaultAsync(c => c.CountId == countId, ct);
|
||||
@@ -94,7 +94,7 @@ public sealed class CountService : ICountService
|
||||
return Map(count);
|
||||
}
|
||||
|
||||
public async Task<CountDto> EnterCountsAsync(long countId, EnterCountsRequest request, CancellationToken ct = default)
|
||||
public async Task<CountDto> EnterCountsAsync(int countId, EnterCountsRequest request, CancellationToken ct = default)
|
||||
{
|
||||
var count = await _counts.Query().Include(c => c.Lines)
|
||||
.FirstOrDefaultAsync(c => c.CountId == countId, ct)
|
||||
@@ -115,7 +115,7 @@ public sealed class CountService : ICountService
|
||||
return Map(count);
|
||||
}
|
||||
|
||||
public async Task<CountPostResultDto> PostAsync(long countId, CancellationToken ct = default)
|
||||
public async Task<CountPostResultDto> PostAsync(int countId, CancellationToken ct = default)
|
||||
{
|
||||
var count = await _counts.Query().Include(c => c.Lines)
|
||||
.FirstOrDefaultAsync(c => c.CountId == countId, ct)
|
||||
@@ -135,7 +135,7 @@ public sealed class CountService : ICountService
|
||||
{
|
||||
count.Status = CountStatus.Posted;
|
||||
await _uow.SaveChangesAsync(ct);
|
||||
return new CountPostResultDto(count.CountId, count.Status, null, Array.Empty<long>());
|
||||
return new CountPostResultDto(count.CountId, count.Status, null, Array.Empty<int>());
|
||||
}
|
||||
|
||||
var reason = await _reasonCodes.Query().AsNoTracking()
|
||||
|
||||
@@ -65,7 +65,7 @@ public sealed class GrnService : IGrnService
|
||||
_uow = uow;
|
||||
}
|
||||
|
||||
public async Task<GrnDto?> GetAsync(long grnId, CancellationToken ct = default)
|
||||
public async Task<GrnDto?> GetAsync(int grnId, CancellationToken ct = default)
|
||||
{
|
||||
var grn = await _grns.Query().AsNoTracking()
|
||||
.Include(g => g.Lines)
|
||||
@@ -80,7 +80,7 @@ public sealed class GrnService : IGrnService
|
||||
|
||||
// Resolve vendor + PO context.
|
||||
PurchaseOrder? po = null;
|
||||
long vendorId;
|
||||
int vendorId;
|
||||
if (request.PoId is not null)
|
||||
{
|
||||
po = await _pos.Query().AsNoTracking().Include(p => p.Lines)
|
||||
@@ -100,7 +100,7 @@ public sealed class GrnService : IGrnService
|
||||
}
|
||||
|
||||
var lines = new List<GrnLine>();
|
||||
var batchCache = new Dictionary<(long ItemId, string BatchNo), Batch>();
|
||||
var batchCache = new Dictionary<(int ItemId, string BatchNo), Batch>();
|
||||
|
||||
foreach (var input in request.Lines)
|
||||
{
|
||||
@@ -169,7 +169,7 @@ public sealed class GrnService : IGrnService
|
||||
return Map(grn);
|
||||
}
|
||||
|
||||
public async Task<GrnConfirmResultDto> ConfirmAsync(long grnId, string? idempotencyKey, CancellationToken ct = default)
|
||||
public async Task<GrnConfirmResultDto> ConfirmAsync(int grnId, string? idempotencyKey, CancellationToken ct = default)
|
||||
{
|
||||
var grn = await _grns.Query()
|
||||
.Include(g => g.Lines)
|
||||
@@ -184,7 +184,7 @@ public sealed class GrnService : IGrnService
|
||||
|
||||
var actor = _currentUser.AuditUserId;
|
||||
var now = DateTime.UtcNow;
|
||||
var runningBalance = new Dictionary<(long, long), decimal>();
|
||||
var runningBalance = new Dictionary<(int, int), decimal>();
|
||||
var createdLayers = new List<StockLayer>();
|
||||
var ledgerRefs = new List<StockLedger>();
|
||||
|
||||
@@ -232,7 +232,7 @@ public sealed class GrnService : IGrnService
|
||||
await GetPoStatusAsync(grn.PoId, ct));
|
||||
}
|
||||
|
||||
public async Task<ReleaseLineResultDto> ReleaseLineAsync(long grnId, long grnLineId, string action, CancellationToken ct = default)
|
||||
public async Task<ReleaseLineResultDto> ReleaseLineAsync(int grnId, int grnLineId, string action, CancellationToken ct = default)
|
||||
{
|
||||
var grn = await _grns.Query()
|
||||
.Include(g => g.Lines)
|
||||
@@ -279,7 +279,7 @@ public sealed class GrnService : IGrnService
|
||||
}
|
||||
|
||||
private async Task<Batch?> ResolveBatchAsync(
|
||||
Item item, BatchInput? batch, Dictionary<(long, string), Batch> cache, CancellationToken ct)
|
||||
Item item, BatchInput? batch, Dictionary<(int, string), Batch> cache, CancellationToken ct)
|
||||
{
|
||||
if (item.TrackingMode == TrackingMode.Batch && batch is null)
|
||||
throw new DomainException(ErrorCodes.Validation, $"Item {item.ItemId} is batch-tracked; a batch is required.", 422);
|
||||
@@ -302,7 +302,7 @@ public sealed class GrnService : IGrnService
|
||||
}
|
||||
|
||||
private async Task<(decimal QtyBase, decimal UnitCostBase)> ToBaseAsync(
|
||||
Item item, long uomId, decimal qty, decimal unitCostPerUom, CancellationToken ct)
|
||||
Item item, int uomId, decimal qty, decimal unitCostPerUom, CancellationToken ct)
|
||||
{
|
||||
if (uomId == item.BaseUomId)
|
||||
return (qty, unitCostPerUom);
|
||||
@@ -315,7 +315,7 @@ public sealed class GrnService : IGrnService
|
||||
return (qty * conv.Factor, unitCostPerUom / conv.Factor);
|
||||
}
|
||||
|
||||
private async Task UpdatePoStatusAsync(long? poId, CancellationToken ct)
|
||||
private async Task UpdatePoStatusAsync(int? poId, CancellationToken ct)
|
||||
{
|
||||
if (poId is null) return;
|
||||
var po = await _pos.Query().Include(p => p.Lines).FirstOrDefaultAsync(p => p.PoId == poId, ct);
|
||||
@@ -327,7 +327,7 @@ public sealed class GrnService : IGrnService
|
||||
po.UpdatedAt = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
private async Task<PurchaseOrderStatus?> GetPoStatusAsync(long? poId, CancellationToken ct)
|
||||
private async Task<PurchaseOrderStatus?> GetPoStatusAsync(int? poId, CancellationToken ct)
|
||||
{
|
||||
if (poId is null) return null;
|
||||
return await _pos.Query().AsNoTracking().Where(p => p.PoId == poId).Select(p => (PurchaseOrderStatus?)p.Status).FirstOrDefaultAsync(ct);
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace ERPCore.Services.Interfaces;
|
||||
public interface IAuditService
|
||||
{
|
||||
Task<PagedResponse<AuditLogDto>> ListLogsAsync(
|
||||
string? entityType, long? entityId, long? userId, DateOnly? from, DateOnly? to, PageQuery query, CancellationToken ct = default);
|
||||
string? entityType, int? entityId, int? userId, DateOnly? from, DateOnly? to, PageQuery query, CancellationToken ct = default);
|
||||
|
||||
Task<PagedResponse<JournalEntryStubDto>> ListJournalAsync(
|
||||
string? sourceDocType, long? sourceDocId, PageQuery query, CancellationToken ct = default);
|
||||
string? sourceDocType, int? sourceDocId, PageQuery query, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace ERPCore.Services.Interfaces;
|
||||
/// <summary>Cycle/full stock-count business logic (docs/11 §5.6; FR-STK-08).</summary>
|
||||
public interface ICountService
|
||||
{
|
||||
Task<CountDto?> GetAsync(long countId, CancellationToken ct = default);
|
||||
Task<CountDto?> GetAsync(int countId, CancellationToken ct = default);
|
||||
Task<CountDto> CreateAsync(CreateCountRequest request, CancellationToken ct = default);
|
||||
Task<CountDto> EnterCountsAsync(long countId, EnterCountsRequest request, CancellationToken ct = default);
|
||||
Task<CountPostResultDto> PostAsync(long countId, CancellationToken ct = default);
|
||||
Task<CountDto> EnterCountsAsync(int countId, EnterCountsRequest request, CancellationToken ct = default);
|
||||
Task<CountPostResultDto> PostAsync(int countId, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface IFifoCostingService
|
||||
{
|
||||
/// <summary>Create an inbound FIFO layer (qty and unit cost in the item's base UOM).</summary>
|
||||
Task<StockLayer> CreateInboundLayerAsync(
|
||||
long itemId, long warehouseId, long? batchId, long? serialId, long? grnLineId,
|
||||
int itemId, int warehouseId, int? batchId, int? serialId, int? grnLineId,
|
||||
decimal qtyBase, decimal unitCost, DateTime receiptDate, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
@@ -27,20 +27,20 @@ public interface IFifoCostingService
|
||||
/// and ledger costing). Must run inside a UoW transaction.
|
||||
/// </summary>
|
||||
Task<IReadOnlyList<ConsumedSegment>> ConsumeAsync(
|
||||
long itemId, long warehouseId, long? batchId, decimal qtyBase, CancellationToken ct = default);
|
||||
int itemId, int warehouseId, int? batchId, decimal qtyBase, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Append an immutable ledger entry (value = qtyBase × unitCost).</summary>
|
||||
Task<StockLedger> PostLedgerAsync(
|
||||
long itemId, long warehouseId, long? binId, long? batchId, long? serialId, long userId,
|
||||
int itemId, int warehouseId, int? binId, int? batchId, int? serialId, int userId,
|
||||
Direction direction, decimal qtyBase, decimal unitCost, decimal runningBalance,
|
||||
string sourceDocType, long sourceDocId, DateTime createdAt, CancellationToken ct = default);
|
||||
string sourceDocType, int sourceDocId, DateTime createdAt, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Current on-hand (Σ open-layer qtyRemaining) for an item at a warehouse.</summary>
|
||||
Task<decimal> GetOnHandAsync(long itemId, long warehouseId, CancellationToken ct = default);
|
||||
Task<decimal> GetOnHandAsync(int itemId, int warehouseId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Valuation over open layers: Σ(qtyRemaining × unitCost) (FR-STK-04).</summary>
|
||||
Task<StockValuationDto> GetValuationAsync(long itemId, long warehouseId, CancellationToken ct = default);
|
||||
Task<StockValuationDto> GetValuationAsync(int itemId, int warehouseId, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
/// <summary>A quantity consumed from one FIFO layer at that layer's unit cost.</summary>
|
||||
public sealed record ConsumedSegment(long LayerId, decimal Qty, decimal UnitCost);
|
||||
public sealed record ConsumedSegment(int LayerId, decimal Qty, decimal UnitCost);
|
||||
|
||||
@@ -5,11 +5,11 @@ namespace ERPCore.Services.Interfaces;
|
||||
/// <summary>Goods-receipt business logic (docs/11 §4; FR-GRN-01..08).</summary>
|
||||
public interface IGrnService
|
||||
{
|
||||
Task<GrnDto?> GetAsync(long grnId, CancellationToken ct = default);
|
||||
Task<GrnDto?> GetAsync(int grnId, CancellationToken ct = default);
|
||||
Task<GrnDto> CreateAsync(CreateGrnRequest request, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Confirm: create FIFO layers + inbound ledger + update PO receipts, atomically.</summary>
|
||||
Task<GrnConfirmResultDto> ConfirmAsync(long grnId, string? idempotencyKey, CancellationToken ct = default);
|
||||
Task<GrnConfirmResultDto> ConfirmAsync(int grnId, string? idempotencyKey, CancellationToken ct = default);
|
||||
|
||||
Task<ReleaseLineResultDto> ReleaseLineAsync(long grnId, long grnLineId, string action, CancellationToken ct = default);
|
||||
Task<ReleaseLineResultDto> ReleaseLineAsync(int grnId, int grnLineId, string action, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -12,17 +12,17 @@ namespace ERPCore.Services.Interfaces;
|
||||
public interface IItemService
|
||||
{
|
||||
Task<PagedResponse<ItemListItemDto>> ListAsync(
|
||||
PageQuery query, EntityStatus? status, long? categoryId, TrackingMode? trackingMode, CancellationToken ct = default);
|
||||
PageQuery query, EntityStatus? status, int? categoryId, TrackingMode? trackingMode, CancellationToken ct = default);
|
||||
|
||||
Task<ETagged<ItemDetailDto>?> GetAsync(long itemId, CancellationToken ct = default);
|
||||
Task<ETagged<ItemDetailDto>?> GetAsync(int itemId, CancellationToken ct = default);
|
||||
|
||||
Task<ETagged<ItemDetailDto>> CreateAsync(CreateItemRequest request, CancellationToken ct = default);
|
||||
|
||||
Task<ETagged<ItemDetailDto>> UpdateAsync(long itemId, UpdateItemRequest request, uint expectedRowVersion, CancellationToken ct = default);
|
||||
Task<ETagged<ItemDetailDto>> UpdateAsync(int itemId, UpdateItemRequest request, uint expectedRowVersion, CancellationToken ct = default);
|
||||
|
||||
Task SetStatusAsync(long itemId, EntityStatus status, CancellationToken ct = default);
|
||||
Task SetStatusAsync(int itemId, EntityStatus status, CancellationToken ct = default);
|
||||
|
||||
Task<ItemReorderSettingsDto> UpdateReorderAsync(long itemId, UpdateReorderRequest request, CancellationToken ct = default);
|
||||
Task<ItemReorderSettingsDto> UpdateReorderAsync(int itemId, UpdateReorderRequest request, CancellationToken ct = default);
|
||||
|
||||
Task<ItemUomConversionsDto> UpdateUomConversionsAsync(long itemId, UpdateUomConversionsRequest request, CancellationToken ct = default);
|
||||
Task<ItemUomConversionsDto> UpdateUomConversionsAsync(int itemId, UpdateUomConversionsRequest request, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace ERPCore.Services.Interfaces;
|
||||
public interface IPurchaseOrderService
|
||||
{
|
||||
Task<PagedResponse<PurchaseOrderSummaryDto>> ListAsync(
|
||||
PageQuery query, PurchaseOrderStatus? status, long? vendorId, CancellationToken ct = default);
|
||||
PageQuery query, PurchaseOrderStatus? status, int? vendorId, CancellationToken ct = default);
|
||||
|
||||
Task<ETagged<PurchaseOrderDto>?> GetAsync(long poId, CancellationToken ct = default);
|
||||
Task<ETagged<PurchaseOrderDto>?> GetAsync(int poId, CancellationToken ct = default);
|
||||
Task<ETagged<PurchaseOrderDto>> CreateAsync(CreatePurchaseOrderRequest request, CancellationToken ct = default);
|
||||
Task<ETagged<PurchaseOrderDto>> UpdateAsync(long poId, UpdatePurchaseOrderRequest request, uint expectedRowVersion, CancellationToken ct = default);
|
||||
Task<PurchaseOrderDto> ApproveAsync(long poId, CancellationToken ct = default);
|
||||
Task<PurchaseOrderDto> CancelAsync(long poId, string? reason, CancellationToken ct = default);
|
||||
Task<ETagged<PurchaseOrderDto>> UpdateAsync(int poId, UpdatePurchaseOrderRequest request, uint expectedRowVersion, CancellationToken ct = default);
|
||||
Task<PurchaseOrderDto> ApproveAsync(int poId, CancellationToken ct = default);
|
||||
Task<PurchaseOrderDto> CancelAsync(int poId, string? reason, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ namespace ERPCore.Services.Interfaces;
|
||||
/// <summary>Reorder alerts and suggested requisitions (docs/11 §5.7; FR-STK-10).</summary>
|
||||
public interface IReorderService
|
||||
{
|
||||
Task<PagedResponse<ReorderAlertDto>> GetAlertsAsync(long? warehouseId, PageQuery query, CancellationToken ct = default);
|
||||
Task<RequisitionDto> CreateSuggestedRequisitionAsync(long itemId, long warehouseId, CancellationToken ct = default);
|
||||
Task<PagedResponse<ReorderAlertDto>> GetAlertsAsync(int? warehouseId, PageQuery query, CancellationToken ct = default);
|
||||
Task<RequisitionDto> CreateSuggestedRequisitionAsync(int itemId, int warehouseId, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ERPCore.Services.Interfaces;
|
||||
public interface IRequisitionService
|
||||
{
|
||||
Task<PagedResponse<RequisitionSummaryDto>> ListAsync(PageQuery query, CancellationToken ct = default);
|
||||
Task<RequisitionDto?> GetAsync(long requisitionId, CancellationToken ct = default);
|
||||
Task<RequisitionDto?> GetAsync(int requisitionId, CancellationToken ct = default);
|
||||
Task<RequisitionDto> CreateAsync(CreateRequisitionRequest request, CancellationToken ct = default);
|
||||
Task<RequisitionDto> SubmitAsync(long requisitionId, CancellationToken ct = default);
|
||||
Task<RequisitionDto> SubmitAsync(int requisitionId, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace ERPCore.Services.Interfaces;
|
||||
/// <summary>RFQ & vendor-quotation business logic (docs/11 §3.2).</summary>
|
||||
public interface IRfqService
|
||||
{
|
||||
Task<RfqDto?> GetAsync(long rfqId, CancellationToken ct = default);
|
||||
Task<RfqDto?> GetAsync(int rfqId, CancellationToken ct = default);
|
||||
Task<RfqDto> CreateAsync(CreateRfqRequest request, CancellationToken ct = default);
|
||||
Task<VendorQuotationDto> AddQuotationAsync(long rfqId, CreateQuotationRequest request, CancellationToken ct = default);
|
||||
Task<RfqComparisonDto> GetComparisonAsync(long rfqId, CancellationToken ct = default);
|
||||
Task<VendorQuotationDto> AddQuotationAsync(int rfqId, CreateQuotationRequest request, CancellationToken ct = default);
|
||||
Task<RfqComparisonDto> GetComparisonAsync(int rfqId, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using ERPCore.Domain.Entities;
|
||||
namespace ERPCore.Services.Interfaces;
|
||||
|
||||
/// <summary>A signed base-UOM change to an item's stock at one warehouse.</summary>
|
||||
public sealed record StockDelta(long ItemId, long? BinId, long? BatchId, decimal QtyDelta);
|
||||
public sealed record StockDelta(int ItemId, int? BinId, int? BatchId, decimal QtyDelta);
|
||||
|
||||
/// <summary>
|
||||
/// Shared poster for stock-affecting documents (adjustments, count variances,
|
||||
@@ -16,6 +16,6 @@ public sealed record StockDelta(long ItemId, long? BinId, long? BatchId, decimal
|
||||
public interface IStockMutator
|
||||
{
|
||||
Task<IReadOnlyList<StockLedger>> ApplyAsync(
|
||||
long warehouseId, string sourceDocType, long sourceDocId, DateTime now,
|
||||
int warehouseId, string sourceDocType, int sourceDocId, DateTime now,
|
||||
IReadOnlyList<StockDelta> deltas, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ namespace ERPCore.Services.Interfaces;
|
||||
/// <summary>Read-side stock enquiry, ledger and valuation (docs/11 §5.1–5.3).</summary>
|
||||
public interface IStockService
|
||||
{
|
||||
Task<StockOnHandDto> GetOnHandAsync(long itemId, long warehouseId, CancellationToken ct = default);
|
||||
Task<StockOnHandDto> GetOnHandAsync(int itemId, int warehouseId, CancellationToken ct = default);
|
||||
|
||||
Task<PagedResponse<StockLedgerRowDto>> GetLedgerAsync(
|
||||
long? itemId, long? warehouseId, DateOnly? from, DateOnly? to, PageQuery query, CancellationToken ct = default);
|
||||
int? itemId, int? warehouseId, DateOnly? from, DateOnly? to, PageQuery query, CancellationToken ct = default);
|
||||
|
||||
Task<StockValuationDto> GetValuationAsync(long itemId, long warehouseId, CancellationToken ct = default);
|
||||
Task<StockValuationDto> GetValuationAsync(int itemId, int warehouseId, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace ERPCore.Services.Interfaces;
|
||||
/// <summary>Inter-warehouse transfer business logic (docs/11 §5.4; FR-STK-05/06).</summary>
|
||||
public interface ITransferService
|
||||
{
|
||||
Task<TransferDto?> GetAsync(long transferId, CancellationToken ct = default);
|
||||
Task<TransferDto?> GetAsync(int transferId, CancellationToken ct = default);
|
||||
Task<TransferDto> CreateAsync(CreateTransferRequest request, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Dispatch: consume source FIFO layers into in-transit (row-locked).</summary>
|
||||
Task<DispatchResultDto> DispatchAsync(long transferId, CancellationToken ct = default);
|
||||
Task<DispatchResultDto> DispatchAsync(int transferId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Receive: create the destination layer at the inherited (cost-preserving) cost.</summary>
|
||||
Task<ReceiveResultDto> ReceiveAsync(long transferId, ReceiveTransferRequest request, CancellationToken ct = default);
|
||||
Task<ReceiveResultDto> ReceiveAsync(int transferId, ReceiveTransferRequest request, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace ERPCore.Services.Interfaces;
|
||||
public interface IVendorService
|
||||
{
|
||||
Task<PagedResponse<VendorDto>> ListAsync(PageQuery query, EntityStatus? status, CancellationToken ct = default);
|
||||
Task<ETagged<VendorDto>?> GetAsync(long vendorId, CancellationToken ct = default);
|
||||
Task<ETagged<VendorDto>?> GetAsync(int vendorId, CancellationToken ct = default);
|
||||
Task<ETagged<VendorDto>> CreateAsync(CreateVendorRequest request, CancellationToken ct = default);
|
||||
Task<ETagged<VendorDto>> UpdateAsync(long vendorId, UpdateVendorRequest request, uint expectedRowVersion, CancellationToken ct = default);
|
||||
Task SetStatusAsync(long vendorId, EntityStatus status, CancellationToken ct = default);
|
||||
Task<ETagged<VendorDto>> UpdateAsync(int vendorId, UpdateVendorRequest request, uint expectedRowVersion, CancellationToken ct = default);
|
||||
Task SetStatusAsync(int vendorId, EntityStatus status, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace ERPCore.Services.Interfaces;
|
||||
public interface IWarehouseService
|
||||
{
|
||||
Task<PagedResponse<WarehouseDto>> ListAsync(PageQuery query, CancellationToken ct = default);
|
||||
Task<WarehouseDto?> GetAsync(long warehouseId, CancellationToken ct = default);
|
||||
Task<WarehouseDto?> GetAsync(int warehouseId, CancellationToken ct = default);
|
||||
Task<WarehouseDto> CreateAsync(CreateWarehouseRequest request, CancellationToken ct = default);
|
||||
|
||||
Task<IReadOnlyList<BinDto>> ListBinsAsync(long warehouseId, CancellationToken ct = default);
|
||||
Task<BinDto> CreateBinAsync(long warehouseId, CreateBinRequest request, CancellationToken ct = default);
|
||||
Task<IReadOnlyList<BinDto>> ListBinsAsync(int warehouseId, CancellationToken ct = default);
|
||||
Task<BinDto> CreateBinAsync(int warehouseId, CreateBinRequest request, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public sealed class ItemService : IItemService
|
||||
}
|
||||
|
||||
public async Task<PagedResponse<ItemListItemDto>> ListAsync(
|
||||
PageQuery query, EntityStatus? status, long? categoryId, TrackingMode? trackingMode, CancellationToken ct = default)
|
||||
PageQuery query, EntityStatus? status, int? categoryId, TrackingMode? trackingMode, CancellationToken ct = default)
|
||||
{
|
||||
var q = _items.Query().AsNoTracking();
|
||||
|
||||
@@ -66,7 +66,7 @@ public sealed class ItemService : IItemService
|
||||
return PagedResponse<ItemListItemDto>.Create(rows, query.Page, query.PageSize, total);
|
||||
}
|
||||
|
||||
public async Task<ETagged<ItemDetailDto>?> GetAsync(long itemId, CancellationToken ct = default)
|
||||
public async Task<ETagged<ItemDetailDto>?> GetAsync(int itemId, CancellationToken ct = default)
|
||||
{
|
||||
var item = await _items.Query().AsNoTracking()
|
||||
.Include(i => i.ReorderSettings)
|
||||
@@ -104,7 +104,7 @@ public sealed class ItemService : IItemService
|
||||
}
|
||||
|
||||
public async Task<ETagged<ItemDetailDto>> UpdateAsync(
|
||||
long itemId, UpdateItemRequest request, uint expectedRowVersion, CancellationToken ct = default)
|
||||
int itemId, UpdateItemRequest request, uint expectedRowVersion, CancellationToken ct = default)
|
||||
{
|
||||
var item = await _items.Query()
|
||||
.Include(i => i.ReorderSettings)
|
||||
@@ -135,7 +135,7 @@ public sealed class ItemService : IItemService
|
||||
return new ETagged<ItemDetailDto>(ToDetail(item), item.RowVersion);
|
||||
}
|
||||
|
||||
public async Task SetStatusAsync(long itemId, EntityStatus status, CancellationToken ct = default)
|
||||
public async Task SetStatusAsync(int itemId, EntityStatus status, CancellationToken ct = default)
|
||||
{
|
||||
var item = await _items.GetByIdAsync(itemId, ct)
|
||||
?? throw new NotFoundException($"Item {itemId} was not found.");
|
||||
@@ -146,7 +146,7 @@ public sealed class ItemService : IItemService
|
||||
}
|
||||
|
||||
public async Task<ItemReorderSettingsDto> UpdateReorderAsync(
|
||||
long itemId, UpdateReorderRequest request, CancellationToken ct = default)
|
||||
int itemId, UpdateReorderRequest request, CancellationToken ct = default)
|
||||
{
|
||||
if (request.Settings.Select(s => s.WarehouseId).Distinct().Count() != request.Settings.Count)
|
||||
throw new DomainException(ErrorCodes.Validation, "Duplicate warehouseId in reorder settings.", 400);
|
||||
@@ -194,7 +194,7 @@ public sealed class ItemService : IItemService
|
||||
}
|
||||
|
||||
public async Task<ItemUomConversionsDto> UpdateUomConversionsAsync(
|
||||
long itemId, UpdateUomConversionsRequest request, CancellationToken ct = default)
|
||||
int itemId, UpdateUomConversionsRequest request, CancellationToken ct = default)
|
||||
{
|
||||
var pairs = request.Conversions.Select(c => (c.FromUom, c.ToUom)).ToList();
|
||||
if (pairs.Distinct().Count() != pairs.Count)
|
||||
@@ -240,7 +240,7 @@ public sealed class ItemService : IItemService
|
||||
return new ItemUomConversionsDto(item.ItemId, item.BaseUomId, conversions);
|
||||
}
|
||||
|
||||
private async Task ValidateReferencesAsync(long categoryId, long baseUomId, long? defaultVendorId, CancellationToken ct)
|
||||
private async Task ValidateReferencesAsync(int categoryId, int baseUomId, int? defaultVendorId, CancellationToken ct)
|
||||
{
|
||||
if (!await _categories.Query().AnyAsync(c => c.CategoryId == categoryId, ct))
|
||||
throw new DomainException(ErrorCodes.Validation, $"Category {categoryId} does not exist.", 422);
|
||||
|
||||
@@ -49,7 +49,7 @@ public sealed class PurchaseOrderService : IPurchaseOrderService
|
||||
}
|
||||
|
||||
public async Task<PagedResponse<PurchaseOrderSummaryDto>> ListAsync(
|
||||
PageQuery query, PurchaseOrderStatus? status, long? vendorId, CancellationToken ct = default)
|
||||
PageQuery query, PurchaseOrderStatus? status, int? vendorId, CancellationToken ct = default)
|
||||
{
|
||||
var q = _pos.Query().AsNoTracking().Include(p => p.Lines).AsQueryable();
|
||||
if (!string.IsNullOrWhiteSpace(query.Q))
|
||||
@@ -71,7 +71,7 @@ public sealed class PurchaseOrderService : IPurchaseOrderService
|
||||
return PagedResponse<PurchaseOrderSummaryDto>.Create(summaries, query.Page, query.PageSize, total);
|
||||
}
|
||||
|
||||
public async Task<ETagged<PurchaseOrderDto>?> GetAsync(long poId, CancellationToken ct = default)
|
||||
public async Task<ETagged<PurchaseOrderDto>?> GetAsync(int poId, CancellationToken ct = default)
|
||||
{
|
||||
var po = await _pos.Query().AsNoTracking()
|
||||
.Include(p => p.Lines)
|
||||
@@ -107,7 +107,7 @@ public sealed class PurchaseOrderService : IPurchaseOrderService
|
||||
}
|
||||
|
||||
public async Task<ETagged<PurchaseOrderDto>> UpdateAsync(
|
||||
long poId, UpdatePurchaseOrderRequest request, uint expectedRowVersion, CancellationToken ct = default)
|
||||
int poId, UpdatePurchaseOrderRequest request, uint expectedRowVersion, CancellationToken ct = default)
|
||||
{
|
||||
var po = await _pos.Query()
|
||||
.Include(p => p.Lines)
|
||||
@@ -143,7 +143,7 @@ public sealed class PurchaseOrderService : IPurchaseOrderService
|
||||
return new ETagged<PurchaseOrderDto>(Map(po), po.RowVersion);
|
||||
}
|
||||
|
||||
public async Task<PurchaseOrderDto> ApproveAsync(long poId, CancellationToken ct = default)
|
||||
public async Task<PurchaseOrderDto> ApproveAsync(int poId, CancellationToken ct = default)
|
||||
{
|
||||
var po = await _pos.Query()
|
||||
.Include(p => p.Lines)
|
||||
@@ -162,7 +162,7 @@ public sealed class PurchaseOrderService : IPurchaseOrderService
|
||||
return Map(po);
|
||||
}
|
||||
|
||||
public async Task<PurchaseOrderDto> CancelAsync(long poId, string? reason, CancellationToken ct = default)
|
||||
public async Task<PurchaseOrderDto> CancelAsync(int poId, string? reason, CancellationToken ct = default)
|
||||
{
|
||||
var po = await _pos.Query()
|
||||
.Include(p => p.Lines)
|
||||
@@ -211,7 +211,7 @@ public sealed class PurchaseOrderService : IPurchaseOrderService
|
||||
}
|
||||
|
||||
private async Task ValidateReferencesAsync(
|
||||
long vendorId, long? requisitionId, IReadOnlyCollection<CreatePoLineInput> lines, CancellationToken ct)
|
||||
int vendorId, int? requisitionId, IReadOnlyCollection<CreatePoLineInput> lines, CancellationToken ct)
|
||||
{
|
||||
var vendor = await _vendors.Query().AsNoTracking().FirstOrDefaultAsync(v => v.VendorId == vendorId, ct);
|
||||
if (vendor is null)
|
||||
@@ -229,7 +229,7 @@ public sealed class PurchaseOrderService : IPurchaseOrderService
|
||||
}
|
||||
|
||||
private static async Task EnsureAllExistAsync(
|
||||
IQueryable<long> keySource, IEnumerable<long> requested, string label, CancellationToken ct)
|
||||
IQueryable<int> keySource, IEnumerable<int> requested, string label, CancellationToken ct)
|
||||
{
|
||||
var ids = requested.Distinct().ToList();
|
||||
var found = await keySource.Where(k => ids.Contains(k)).ToListAsync(ct);
|
||||
|
||||
@@ -26,7 +26,7 @@ public sealed class ReorderService : IReorderService
|
||||
_requisitions = requisitions;
|
||||
}
|
||||
|
||||
public async Task<PagedResponse<ReorderAlertDto>> GetAlertsAsync(long? warehouseId, PageQuery query, CancellationToken ct = default)
|
||||
public async Task<PagedResponse<ReorderAlertDto>> GetAlertsAsync(int? warehouseId, PageQuery query, CancellationToken ct = default)
|
||||
{
|
||||
var q = _reorders.Query().AsNoTracking();
|
||||
if (warehouseId is not null) q = q.Where(r => r.WarehouseId == warehouseId);
|
||||
@@ -44,7 +44,7 @@ public sealed class ReorderService : IReorderService
|
||||
return PagedResponse<ReorderAlertDto>.Create(page, query.Page, query.PageSize, alerts.Count);
|
||||
}
|
||||
|
||||
public async Task<RequisitionDto> CreateSuggestedRequisitionAsync(long itemId, long warehouseId, CancellationToken ct = default)
|
||||
public async Task<RequisitionDto> CreateSuggestedRequisitionAsync(int itemId, int warehouseId, CancellationToken ct = default)
|
||||
{
|
||||
var policy = await _reorders.Query().AsNoTracking()
|
||||
.FirstOrDefaultAsync(r => r.ItemId == itemId && r.WarehouseId == warehouseId, ct)
|
||||
|
||||
@@ -49,7 +49,7 @@ public sealed class RequisitionService : IRequisitionService
|
||||
return PagedResponse<RequisitionSummaryDto>.Create(rows, query.Page, query.PageSize, total);
|
||||
}
|
||||
|
||||
public async Task<RequisitionDto?> GetAsync(long requisitionId, CancellationToken ct = default)
|
||||
public async Task<RequisitionDto?> GetAsync(int requisitionId, CancellationToken ct = default)
|
||||
{
|
||||
var req = await _requisitions.Query().AsNoTracking()
|
||||
.Include(r => r.Lines)
|
||||
@@ -85,7 +85,7 @@ public sealed class RequisitionService : IRequisitionService
|
||||
return Map(req);
|
||||
}
|
||||
|
||||
public async Task<RequisitionDto> SubmitAsync(long requisitionId, CancellationToken ct = default)
|
||||
public async Task<RequisitionDto> SubmitAsync(int requisitionId, CancellationToken ct = default)
|
||||
{
|
||||
var req = await _requisitions.Query()
|
||||
.Include(r => r.Lines)
|
||||
@@ -101,7 +101,7 @@ public sealed class RequisitionService : IRequisitionService
|
||||
return Map(req);
|
||||
}
|
||||
|
||||
private async Task EnsureItemsExistAsync(IEnumerable<long> itemIds, CancellationToken ct)
|
||||
private async Task EnsureItemsExistAsync(IEnumerable<int> itemIds, CancellationToken ct)
|
||||
{
|
||||
var ids = itemIds.Distinct().ToList();
|
||||
var found = await _items.Query().AsNoTracking()
|
||||
|
||||
@@ -34,7 +34,7 @@ public sealed class RfqService : IRfqService
|
||||
_uow = uow;
|
||||
}
|
||||
|
||||
public async Task<RfqDto?> GetAsync(long rfqId, CancellationToken ct = default)
|
||||
public async Task<RfqDto?> GetAsync(int rfqId, CancellationToken ct = default)
|
||||
{
|
||||
var rfq = await _rfqs.Query().AsNoTracking()
|
||||
.Include(r => r.Lines)
|
||||
@@ -68,7 +68,7 @@ public sealed class RfqService : IRfqService
|
||||
return MapRfq(rfq);
|
||||
}
|
||||
|
||||
public async Task<VendorQuotationDto> AddQuotationAsync(long rfqId, CreateQuotationRequest request, CancellationToken ct = default)
|
||||
public async Task<VendorQuotationDto> AddQuotationAsync(int rfqId, CreateQuotationRequest request, CancellationToken ct = default)
|
||||
{
|
||||
var rfq = await _rfqs.Query().AsNoTracking()
|
||||
.Include(r => r.Lines)
|
||||
@@ -106,7 +106,7 @@ public sealed class RfqService : IRfqService
|
||||
quotation.Lines.Select(l => new QuotationLineDto(l.ItemId, l.UnitPrice, l.LeadDays)).ToList());
|
||||
}
|
||||
|
||||
public async Task<RfqComparisonDto> GetComparisonAsync(long rfqId, CancellationToken ct = default)
|
||||
public async Task<RfqComparisonDto> GetComparisonAsync(int rfqId, CancellationToken ct = default)
|
||||
{
|
||||
var rfq = await _rfqs.Query().AsNoTracking()
|
||||
.Include(r => r.Lines)
|
||||
@@ -130,7 +130,7 @@ public sealed class RfqService : IRfqService
|
||||
return new RfqComparisonDto(rfqId, vendorIds, rows);
|
||||
}
|
||||
|
||||
private async Task EnsureItemsExistAsync(IEnumerable<long> itemIds, CancellationToken ct)
|
||||
private async Task EnsureItemsExistAsync(IEnumerable<int> itemIds, CancellationToken ct)
|
||||
{
|
||||
var ids = itemIds.Distinct().ToList();
|
||||
var found = await _items.Query().AsNoTracking()
|
||||
@@ -140,7 +140,7 @@ public sealed class RfqService : IRfqService
|
||||
throw new DomainException(ErrorCodes.Validation, $"Item(s) not found: {string.Join(", ", missing)}.", 422);
|
||||
}
|
||||
|
||||
private async Task EnsureVendorsExistAsync(IEnumerable<long> vendorIds, CancellationToken ct)
|
||||
private async Task EnsureVendorsExistAsync(IEnumerable<int> vendorIds, CancellationToken ct)
|
||||
{
|
||||
var ids = vendorIds.Distinct().ToList();
|
||||
if (ids.Count == 0) return;
|
||||
|
||||
@@ -39,7 +39,7 @@ public sealed class FifoCostingService : IFifoCostingService
|
||||
}
|
||||
|
||||
public async Task<StockLayer> CreateInboundLayerAsync(
|
||||
long itemId, long warehouseId, long? batchId, long? serialId, long? grnLineId,
|
||||
int itemId, int warehouseId, int? batchId, int? serialId, int? grnLineId,
|
||||
decimal qtyBase, decimal unitCost, DateTime receiptDate, CancellationToken ct = default)
|
||||
{
|
||||
var layer = new StockLayer
|
||||
@@ -59,7 +59,7 @@ public sealed class FifoCostingService : IFifoCostingService
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<ConsumedSegment>> ConsumeAsync(
|
||||
long itemId, long warehouseId, long? batchId, decimal qtyBase, CancellationToken ct = default)
|
||||
int itemId, int warehouseId, int? batchId, decimal qtyBase, CancellationToken ct = default)
|
||||
{
|
||||
var today = DateOnly.FromDateTime(DateTime.UtcNow);
|
||||
|
||||
@@ -119,9 +119,9 @@ public sealed class FifoCostingService : IFifoCostingService
|
||||
}
|
||||
|
||||
public async Task<StockLedger> PostLedgerAsync(
|
||||
long itemId, long warehouseId, long? binId, long? batchId, long? serialId, long userId,
|
||||
int itemId, int warehouseId, int? binId, int? batchId, int? serialId, int userId,
|
||||
Direction direction, decimal qtyBase, decimal unitCost, decimal runningBalance,
|
||||
string sourceDocType, long sourceDocId, DateTime createdAt, CancellationToken ct = default)
|
||||
string sourceDocType, int sourceDocId, DateTime createdAt, CancellationToken ct = default)
|
||||
{
|
||||
var entry = new StockLedger
|
||||
{
|
||||
@@ -159,12 +159,12 @@ public sealed class FifoCostingService : IFifoCostingService
|
||||
return entry;
|
||||
}
|
||||
|
||||
public async Task<decimal> GetOnHandAsync(long itemId, long warehouseId, CancellationToken ct = default)
|
||||
public async Task<decimal> GetOnHandAsync(int itemId, int warehouseId, CancellationToken ct = default)
|
||||
=> await _layers.Query().AsNoTracking()
|
||||
.Where(l => l.ItemId == itemId && l.WarehouseId == warehouseId)
|
||||
.SumAsync(l => (decimal?)l.QtyRemaining, ct) ?? 0m;
|
||||
|
||||
public async Task<StockValuationDto> GetValuationAsync(long itemId, long warehouseId, CancellationToken ct = default)
|
||||
public async Task<StockValuationDto> GetValuationAsync(int itemId, int warehouseId, CancellationToken ct = default)
|
||||
{
|
||||
var open = await _layers.Query().AsNoTracking()
|
||||
.Where(l => l.ItemId == itemId && l.WarehouseId == warehouseId && l.QtyRemaining > 0)
|
||||
|
||||
@@ -27,11 +27,11 @@ public sealed class StockMutator : IStockMutator
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<StockLedger>> ApplyAsync(
|
||||
long warehouseId, string sourceDocType, long sourceDocId, DateTime now,
|
||||
int warehouseId, string sourceDocType, int sourceDocId, DateTime now,
|
||||
IReadOnlyList<StockDelta> deltas, CancellationToken ct = default)
|
||||
{
|
||||
var actor = _currentUser.AuditUserId;
|
||||
var balances = new Dictionary<long, decimal>();
|
||||
var balances = new Dictionary<int, decimal>();
|
||||
var entries = new List<StockLedger>();
|
||||
|
||||
foreach (var d in deltas)
|
||||
@@ -69,7 +69,7 @@ public sealed class StockMutator : IStockMutator
|
||||
return entries;
|
||||
}
|
||||
|
||||
private async Task<decimal> LastCostAsync(long itemId, long warehouseId, CancellationToken ct)
|
||||
private async Task<decimal> LastCostAsync(int itemId, int warehouseId, CancellationToken ct)
|
||||
=> await _layers.Query().AsNoTracking()
|
||||
.Where(l => l.ItemId == itemId && l.WarehouseId == warehouseId)
|
||||
.OrderByDescending(l => l.ReceiptDate).ThenByDescending(l => l.LayerId)
|
||||
|
||||
@@ -25,7 +25,7 @@ public sealed class StockService : IStockService
|
||||
_transferLines = transferLines;
|
||||
}
|
||||
|
||||
public async Task<StockOnHandDto> GetOnHandAsync(long itemId, long warehouseId, CancellationToken ct = default)
|
||||
public async Task<StockOnHandDto> GetOnHandAsync(int itemId, int warehouseId, CancellationToken ct = default)
|
||||
{
|
||||
var onHand = await _fifo.GetOnHandAsync(itemId, warehouseId, ct);
|
||||
|
||||
@@ -51,7 +51,7 @@ public sealed class StockService : IStockService
|
||||
}
|
||||
|
||||
public async Task<PagedResponse<StockLedgerRowDto>> GetLedgerAsync(
|
||||
long? itemId, long? warehouseId, DateOnly? from, DateOnly? to, PageQuery query, CancellationToken ct = default)
|
||||
int? itemId, int? warehouseId, DateOnly? from, DateOnly? to, PageQuery query, CancellationToken ct = default)
|
||||
{
|
||||
var q = _ledger.Query().AsNoTracking();
|
||||
if (itemId is not null) q = q.Where(l => l.ItemId == itemId);
|
||||
@@ -71,6 +71,6 @@ public sealed class StockService : IStockService
|
||||
return PagedResponse<StockLedgerRowDto>.Create(rows, query.Page, query.PageSize, total);
|
||||
}
|
||||
|
||||
public Task<StockValuationDto> GetValuationAsync(long itemId, long warehouseId, CancellationToken ct = default)
|
||||
public Task<StockValuationDto> GetValuationAsync(int itemId, int warehouseId, CancellationToken ct = default)
|
||||
=> _fifo.GetValuationAsync(itemId, warehouseId, ct);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public sealed class TransferService : ITransferService
|
||||
_uow = uow;
|
||||
}
|
||||
|
||||
public async Task<TransferDto?> GetAsync(long transferId, CancellationToken ct = default)
|
||||
public async Task<TransferDto?> GetAsync(int transferId, CancellationToken ct = default)
|
||||
{
|
||||
var t = await _transfers.Query().AsNoTracking().Include(x => x.Lines)
|
||||
.FirstOrDefaultAsync(x => x.TransferId == transferId, ct);
|
||||
@@ -85,7 +85,7 @@ public sealed class TransferService : ITransferService
|
||||
return Map(transfer);
|
||||
}
|
||||
|
||||
public async Task<DispatchResultDto> DispatchAsync(long transferId, CancellationToken ct = default)
|
||||
public async Task<DispatchResultDto> DispatchAsync(int transferId, CancellationToken ct = default)
|
||||
{
|
||||
var transfer = await _transfers.Query().Include(t => t.Lines)
|
||||
.FirstOrDefaultAsync(t => t.TransferId == transferId, ct)
|
||||
@@ -97,7 +97,7 @@ public sealed class TransferService : ITransferService
|
||||
var now = DateTime.UtcNow;
|
||||
var consumed = new List<ConsumedLayerDto>();
|
||||
var ledgerRefs = new List<StockLedger>();
|
||||
var balances = new Dictionary<long, decimal>();
|
||||
var balances = new Dictionary<int, decimal>();
|
||||
|
||||
await _uow.ExecuteInTransactionAsync(async token =>
|
||||
{
|
||||
@@ -127,7 +127,7 @@ public sealed class TransferService : ITransferService
|
||||
return new DispatchResultDto(transfer.TransferId, transfer.Status, consumed, ledgerRefs.Select(l => l.LedgerId).ToList());
|
||||
}
|
||||
|
||||
public async Task<ReceiveResultDto> ReceiveAsync(long transferId, ReceiveTransferRequest request, CancellationToken ct = default)
|
||||
public async Task<ReceiveResultDto> ReceiveAsync(int transferId, ReceiveTransferRequest request, CancellationToken ct = default)
|
||||
{
|
||||
var transfer = await _transfers.Query().Include(t => t.Lines)
|
||||
.FirstOrDefaultAsync(t => t.TransferId == transferId, ct)
|
||||
@@ -139,7 +139,7 @@ public sealed class TransferService : ITransferService
|
||||
var now = DateTime.UtcNow;
|
||||
var createdLayers = new List<StockLayer>();
|
||||
var ledgerRefs = new List<StockLedger>();
|
||||
var balances = new Dictionary<long, decimal>();
|
||||
var balances = new Dictionary<int, decimal>();
|
||||
|
||||
await _uow.ExecuteInTransactionAsync(async token =>
|
||||
{
|
||||
@@ -183,7 +183,7 @@ public sealed class TransferService : ITransferService
|
||||
return new ReceiveResultDto(transfer.TransferId, transfer.Status, created, ledgerRefs.Select(l => l.LedgerId).ToList());
|
||||
}
|
||||
|
||||
private async Task EnsureWarehouseAsync(long warehouseId, CancellationToken ct)
|
||||
private async Task EnsureWarehouseAsync(int warehouseId, CancellationToken ct)
|
||||
{
|
||||
if (!await _warehouses.Query().AnyAsync(w => w.WarehouseId == warehouseId, ct))
|
||||
throw new DomainException(ErrorCodes.Validation, $"Warehouse {warehouseId} does not exist.", 422);
|
||||
|
||||
@@ -40,7 +40,7 @@ public sealed class VendorService : IVendorService
|
||||
return PagedResponse<VendorDto>.Create(rows.Select(Map).ToList(), query.Page, query.PageSize, total);
|
||||
}
|
||||
|
||||
public async Task<ETagged<VendorDto>?> GetAsync(long vendorId, CancellationToken ct = default)
|
||||
public async Task<ETagged<VendorDto>?> GetAsync(int vendorId, CancellationToken ct = default)
|
||||
{
|
||||
var vendor = await _vendors.Query().AsNoTracking()
|
||||
.FirstOrDefaultAsync(v => v.VendorId == vendorId, ct);
|
||||
@@ -71,7 +71,7 @@ public sealed class VendorService : IVendorService
|
||||
}
|
||||
|
||||
public async Task<ETagged<VendorDto>> UpdateAsync(
|
||||
long vendorId, UpdateVendorRequest request, uint expectedRowVersion, CancellationToken ct = default)
|
||||
int vendorId, UpdateVendorRequest request, uint expectedRowVersion, CancellationToken ct = default)
|
||||
{
|
||||
var vendor = await _vendors.GetByIdAsync(vendorId, ct)
|
||||
?? throw new NotFoundException($"Vendor {vendorId} was not found.");
|
||||
@@ -103,7 +103,7 @@ public sealed class VendorService : IVendorService
|
||||
return new ETagged<VendorDto>(Map(vendor), vendor.RowVersion);
|
||||
}
|
||||
|
||||
public async Task SetStatusAsync(long vendorId, EntityStatus status, CancellationToken ct = default)
|
||||
public async Task SetStatusAsync(int vendorId, EntityStatus status, CancellationToken ct = default)
|
||||
{
|
||||
var vendor = await _vendors.GetByIdAsync(vendorId, ct)
|
||||
?? throw new NotFoundException($"Vendor {vendorId} was not found.");
|
||||
|
||||
@@ -40,7 +40,7 @@ public sealed class WarehouseService : IWarehouseService
|
||||
return PagedResponse<WarehouseDto>.Create(rows, query.Page, query.PageSize, total);
|
||||
}
|
||||
|
||||
public async Task<WarehouseDto?> GetAsync(long warehouseId, CancellationToken ct = default)
|
||||
public async Task<WarehouseDto?> GetAsync(int warehouseId, CancellationToken ct = default)
|
||||
{
|
||||
var w = await _warehouses.Query().AsNoTracking()
|
||||
.FirstOrDefaultAsync(x => x.WarehouseId == warehouseId, ct);
|
||||
@@ -60,7 +60,7 @@ public sealed class WarehouseService : IWarehouseService
|
||||
return new WarehouseDto(warehouse.WarehouseId, warehouse.Code, warehouse.Name);
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<BinDto>> ListBinsAsync(long warehouseId, CancellationToken ct = default)
|
||||
public async Task<IReadOnlyList<BinDto>> ListBinsAsync(int warehouseId, CancellationToken ct = default)
|
||||
{
|
||||
await EnsureWarehouseExistsAsync(warehouseId, ct);
|
||||
|
||||
@@ -71,7 +71,7 @@ public sealed class WarehouseService : IWarehouseService
|
||||
.ToListAsync(ct);
|
||||
}
|
||||
|
||||
public async Task<BinDto> CreateBinAsync(long warehouseId, CreateBinRequest request, CancellationToken ct = default)
|
||||
public async Task<BinDto> CreateBinAsync(int warehouseId, CreateBinRequest request, CancellationToken ct = default)
|
||||
{
|
||||
await EnsureWarehouseExistsAsync(warehouseId, ct);
|
||||
|
||||
@@ -86,7 +86,7 @@ public sealed class WarehouseService : IWarehouseService
|
||||
return new BinDto(bin.BinId, bin.WarehouseId, bin.Code, bin.BinType);
|
||||
}
|
||||
|
||||
private async Task EnsureWarehouseExistsAsync(long warehouseId, CancellationToken ct)
|
||||
private async Task EnsureWarehouseExistsAsync(int warehouseId, CancellationToken ct)
|
||||
{
|
||||
if (!await _warehouses.Query().AnyAsync(w => w.WarehouseId == warehouseId, ct))
|
||||
throw new NotFoundException($"Warehouse {warehouseId} was not found.");
|
||||
|
||||
Reference in New Issue
Block a user