From 0fe4db5e77126e5f51665a1e399c2dda4d622c9d Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Sun, 22 Feb 2026 21:38:20 +0330 Subject: [PATCH] =?UTF-8?q?fix:=20StockMovement=20CHECK=20constraint=20vio?= =?UTF-8?q?lation=20=E2=80=94=20store=20Quantity=20as=20negative=20for=20r?= =?UTF-8?q?educe=20operations,=20pass=20correct=20MovementType=20from=20Re?= =?UTF-8?q?cordLoss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/ReduceInventory/ReduceInventoryCommand.cs | 6 +++++- .../ReduceInventory/ReduceInventoryCommandHandler.cs | 6 +++--- src/CMSMicroservice.WebApi/Services/InventoryService.cs | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/CMSMicroservice.Application/InventoryItemCQ/Commands/ReduceInventory/ReduceInventoryCommand.cs b/src/CMSMicroservice.Application/InventoryItemCQ/Commands/ReduceInventory/ReduceInventoryCommand.cs index 88a40b9..6e3a0a3 100644 --- a/src/CMSMicroservice.Application/InventoryItemCQ/Commands/ReduceInventory/ReduceInventoryCommand.cs +++ b/src/CMSMicroservice.Application/InventoryItemCQ/Commands/ReduceInventory/ReduceInventoryCommand.cs @@ -1,7 +1,7 @@ namespace CMSMicroservice.Application.InventoryItemCQ.Commands.ReduceInventory; /// -/// Command برای کم کردن موجودی (فروش) +/// Command برای کم کردن موجودی (فروش، خسارت، مفقودی و ...) /// public record ReduceInventoryCommand : IRequest { @@ -19,4 +19,8 @@ public record ReduceInventoryCommand : IRequest public long? PerformedByUserId { get; init; } /// آیا از موجودی رزرو شده کم شود؟ public bool FromReserved { get; init; } = true; + /// نوع حرکت انبار (پیش‌فرض: فروش) + public Domain.Enums.StockMovementType MovementType { get; init; } = Domain.Enums.StockMovementType.Sale; + /// توضیحات + public string? Note { get; init; } } diff --git a/src/CMSMicroservice.Application/InventoryItemCQ/Commands/ReduceInventory/ReduceInventoryCommandHandler.cs b/src/CMSMicroservice.Application/InventoryItemCQ/Commands/ReduceInventory/ReduceInventoryCommandHandler.cs index a4587e8..bf3df1b 100644 --- a/src/CMSMicroservice.Application/InventoryItemCQ/Commands/ReduceInventory/ReduceInventoryCommandHandler.cs +++ b/src/CMSMicroservice.Application/InventoryItemCQ/Commands/ReduceInventory/ReduceInventoryCommandHandler.cs @@ -53,11 +53,11 @@ public class ReduceInventoryCommandHandler : IRequestHandler