diff --git a/build-deps.sh b/build-deps.sh new file mode 100755 index 0000000..cb254b2 --- /dev/null +++ b/build-deps.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# Build all BFF proto dependencies and copy DLLs to libs folder +# This script is automatically run before build via Directory.Build.targets + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +LIBS_DIR="$SCRIPT_DIR/libs" +BFF_PROTOS_DIR="$SCRIPT_DIR/../BackOffice.BFF/src/Protobufs" + +echo "🔧 Building all proto dependencies..." + +# Create libs directory +mkdir -p "$LIBS_DIR" + +# All proto projects +PROTO_PROJECTS=( + "BackOffice.BFF.Common.Protobuf" + "BackOffice.BFF.Category.Protobuf" + "BackOffice.BFF.ClubMembership.Protobuf" + "BackOffice.BFF.Commission.Protobuf" + "BackOffice.BFF.Configuration.Protobuf" + "BackOffice.BFF.DiscountCategory.Protobuf" + "BackOffice.BFF.DiscountOrder.Protobuf" + "BackOffice.BFF.DiscountProduct.Protobuf" + "BackOffice.BFF.DiscountShoppingCart.Protobuf" + "BackOffice.BFF.Health.Protobuf" + "BackOffice.BFF.Inventory.Protobuf" + "BackOffice.BFF.ManualPayment.Protobuf" + "BackOffice.BFF.NetworkMembership.Protobuf" + "BackOffice.BFF.Otp.Protobuf" + "BackOffice.BFF.Package.Protobuf" + "BackOffice.BFF.Products.Protobuf" + "BackOffice.BFF.ProductTag.Protobuf" + "BackOffice.BFF.PublicMessage.Protobuf" + "BackOffice.BFF.Role.Protobuf" + "BackOffice.BFF.Tag.Protobuf" + "BackOffice.BFF.User.Protobuf" + "BackOffice.BFF.UserAddress.Protobuf" + "BackOffice.BFF.UserOrder.Protobuf" + "BackOffice.BFF.UserRole.Protobuf" +) + +BUILT_COUNT=0 +FAILED_COUNT=0 + +for PROJECT in "${PROTO_PROJECTS[@]}"; do + PROJECT_DIR="$BFF_PROTOS_DIR/$PROJECT" + if [ -d "$PROJECT_DIR" ]; then + echo "📦 Building $PROJECT..." + if dotnet build "$PROJECT_DIR" -c Release --verbosity quiet 2>/dev/null; then + # Copy DLL and PDB - check both net9.0 and net8.0 + if [ -f "$PROJECT_DIR/bin/Release/net9.0/$PROJECT.dll" ]; then + cp "$PROJECT_DIR/bin/Release/net9.0/$PROJECT.dll" "$LIBS_DIR/" && ((BUILT_COUNT++)) + cp "$PROJECT_DIR/bin/Release/net9.0/$PROJECT.pdb" "$LIBS_DIR/" 2>/dev/null || true + elif [ -f "$PROJECT_DIR/bin/Release/net8.0/$PROJECT.dll" ]; then + cp "$PROJECT_DIR/bin/Release/net8.0/$PROJECT.dll" "$LIBS_DIR/" && ((BUILT_COUNT++)) + cp "$PROJECT_DIR/bin/Release/net8.0/$PROJECT.pdb" "$LIBS_DIR/" 2>/dev/null || true + else + echo "⚠️ DLL not found for: $PROJECT" + ((FAILED_COUNT++)) + fi + else + echo "⚠️ Failed to build: $PROJECT" + ((FAILED_COUNT++)) + fi + else + echo "⚠️ Project not found: $PROJECT" + ((FAILED_COUNT++)) + fi +done + +echo "" +echo "✅ Build complete!" +echo " Built: $BUILT_COUNT projects" +echo " Failed: $FAILED_COUNT projects" +echo " Output: $LIBS_DIR" +echo "" +ls -la "$LIBS_DIR"/*.dll 2>/dev/null | wc -l | xargs -I {} echo " Total DLLs: {}" diff --git a/libs/BackOffice.BFF.Category.Protobuf.dll b/libs/BackOffice.BFF.Category.Protobuf.dll new file mode 100644 index 0000000..5954b99 Binary files /dev/null and b/libs/BackOffice.BFF.Category.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.ClubMembership.Protobuf.dll b/libs/BackOffice.BFF.ClubMembership.Protobuf.dll new file mode 100644 index 0000000..1f228e5 Binary files /dev/null and b/libs/BackOffice.BFF.ClubMembership.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.Commission.Protobuf.dll b/libs/BackOffice.BFF.Commission.Protobuf.dll new file mode 100644 index 0000000..5cf7a30 Binary files /dev/null and b/libs/BackOffice.BFF.Commission.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.Common.Protobuf.dll b/libs/BackOffice.BFF.Common.Protobuf.dll new file mode 100644 index 0000000..c58dbc9 Binary files /dev/null and b/libs/BackOffice.BFF.Common.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.Configuration.Protobuf.dll b/libs/BackOffice.BFF.Configuration.Protobuf.dll new file mode 100644 index 0000000..4a3701c Binary files /dev/null and b/libs/BackOffice.BFF.Configuration.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.DiscountCategory.Protobuf.dll b/libs/BackOffice.BFF.DiscountCategory.Protobuf.dll new file mode 100644 index 0000000..a07255e Binary files /dev/null and b/libs/BackOffice.BFF.DiscountCategory.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.DiscountOrder.Protobuf.dll b/libs/BackOffice.BFF.DiscountOrder.Protobuf.dll new file mode 100644 index 0000000..83516b6 Binary files /dev/null and b/libs/BackOffice.BFF.DiscountOrder.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.DiscountProduct.Protobuf.dll b/libs/BackOffice.BFF.DiscountProduct.Protobuf.dll new file mode 100644 index 0000000..e967bd9 Binary files /dev/null and b/libs/BackOffice.BFF.DiscountProduct.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.DiscountShoppingCart.Protobuf.dll b/libs/BackOffice.BFF.DiscountShoppingCart.Protobuf.dll new file mode 100644 index 0000000..22c0798 Binary files /dev/null and b/libs/BackOffice.BFF.DiscountShoppingCart.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.Health.Protobuf.dll b/libs/BackOffice.BFF.Health.Protobuf.dll new file mode 100644 index 0000000..a081b8a Binary files /dev/null and b/libs/BackOffice.BFF.Health.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.Inventory.Protobuf.dll b/libs/BackOffice.BFF.Inventory.Protobuf.dll new file mode 100644 index 0000000..c91e97f Binary files /dev/null and b/libs/BackOffice.BFF.Inventory.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.ManualPayment.Protobuf.dll b/libs/BackOffice.BFF.ManualPayment.Protobuf.dll new file mode 100644 index 0000000..80af482 Binary files /dev/null and b/libs/BackOffice.BFF.ManualPayment.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.NetworkMembership.Protobuf.dll b/libs/BackOffice.BFF.NetworkMembership.Protobuf.dll new file mode 100644 index 0000000..93d91d2 Binary files /dev/null and b/libs/BackOffice.BFF.NetworkMembership.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.Otp.Protobuf.dll b/libs/BackOffice.BFF.Otp.Protobuf.dll new file mode 100644 index 0000000..b00cfad Binary files /dev/null and b/libs/BackOffice.BFF.Otp.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.Package.Protobuf.dll b/libs/BackOffice.BFF.Package.Protobuf.dll new file mode 100644 index 0000000..e2bd99a Binary files /dev/null and b/libs/BackOffice.BFF.Package.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.ProductTag.Protobuf.dll b/libs/BackOffice.BFF.ProductTag.Protobuf.dll new file mode 100644 index 0000000..be9167b Binary files /dev/null and b/libs/BackOffice.BFF.ProductTag.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.Products.Protobuf.dll b/libs/BackOffice.BFF.Products.Protobuf.dll new file mode 100644 index 0000000..28f4832 Binary files /dev/null and b/libs/BackOffice.BFF.Products.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.PublicMessage.Protobuf.dll b/libs/BackOffice.BFF.PublicMessage.Protobuf.dll new file mode 100644 index 0000000..c90ee4d Binary files /dev/null and b/libs/BackOffice.BFF.PublicMessage.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.Role.Protobuf.dll b/libs/BackOffice.BFF.Role.Protobuf.dll new file mode 100644 index 0000000..689dfa9 Binary files /dev/null and b/libs/BackOffice.BFF.Role.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.Tag.Protobuf.dll b/libs/BackOffice.BFF.Tag.Protobuf.dll new file mode 100644 index 0000000..f969514 Binary files /dev/null and b/libs/BackOffice.BFF.Tag.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.User.Protobuf.dll b/libs/BackOffice.BFF.User.Protobuf.dll new file mode 100644 index 0000000..8e86677 Binary files /dev/null and b/libs/BackOffice.BFF.User.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.UserAddress.Protobuf.dll b/libs/BackOffice.BFF.UserAddress.Protobuf.dll new file mode 100644 index 0000000..bd65d01 Binary files /dev/null and b/libs/BackOffice.BFF.UserAddress.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.UserOrder.Protobuf.dll b/libs/BackOffice.BFF.UserOrder.Protobuf.dll new file mode 100644 index 0000000..d73a963 Binary files /dev/null and b/libs/BackOffice.BFF.UserOrder.Protobuf.dll differ diff --git a/libs/BackOffice.BFF.UserRole.Protobuf.dll b/libs/BackOffice.BFF.UserRole.Protobuf.dll new file mode 100644 index 0000000..c9a1e55 Binary files /dev/null and b/libs/BackOffice.BFF.UserRole.Protobuf.dll differ diff --git a/src/BackOffice/BackOffice.csproj b/src/BackOffice/BackOffice.csproj index 51e5f02..93a6a82 100644 --- a/src/BackOffice/BackOffice.csproj +++ b/src/BackOffice/BackOffice.csproj @@ -109,73 +109,136 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + ../../libs/BackOffice.BFF.Common.Protobuf.dll + + + ../../libs/BackOffice.BFF.Category.Protobuf.dll + + + ../../libs/BackOffice.BFF.ClubMembership.Protobuf.dll + + + ../../libs/BackOffice.BFF.Commission.Protobuf.dll + + + ../../libs/BackOffice.BFF.Configuration.Protobuf.dll + + + ../../libs/BackOffice.BFF.DiscountCategory.Protobuf.dll + + + ../../libs/BackOffice.BFF.DiscountOrder.Protobuf.dll + + + ../../libs/BackOffice.BFF.DiscountProduct.Protobuf.dll + + + ../../libs/BackOffice.BFF.DiscountShoppingCart.Protobuf.dll + + + ../../libs/BackOffice.BFF.Health.Protobuf.dll + + + ../../libs/BackOffice.BFF.Inventory.Protobuf.dll + + + ../../libs/BackOffice.BFF.ManualPayment.Protobuf.dll + + + ../../libs/BackOffice.BFF.NetworkMembership.Protobuf.dll + + + ../../libs/BackOffice.BFF.Otp.Protobuf.dll + + + ../../libs/BackOffice.BFF.Package.Protobuf.dll + + + ../../libs/BackOffice.BFF.Products.Protobuf.dll + + + ../../libs/BackOffice.BFF.ProductTag.Protobuf.dll + + + ../../libs/BackOffice.BFF.PublicMessage.Protobuf.dll + + + ../../libs/BackOffice.BFF.Role.Protobuf.dll + + + ../../libs/BackOffice.BFF.Tag.Protobuf.dll + + + ../../libs/BackOffice.BFF.User.Protobuf.dll + + + ../../libs/BackOffice.BFF.UserAddress.Protobuf.dll + + + ../../libs/BackOffice.BFF.UserOrder.Protobuf.dll + + + ../../libs/BackOffice.BFF.UserRole.Protobuf.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/BackOffice/Dockerfile b/src/BackOffice/Dockerfile index c837bd8..d053cef 100644 --- a/src/BackOffice/Dockerfile +++ b/src/BackOffice/Dockerfile @@ -5,6 +5,9 @@ WORKDIR /src COPY ["BackOffice/NuGet.config", "NuGet.config"] COPY ["BackOffice/BackOffice.csproj", "BackOffice/"] +# Copy libs folder with pre-built DLLs (built by build-deps.sh) +COPY ["libs/", "libs/"] + # Restore dependencies RUN dotnet restore "BackOffice/BackOffice.csproj" --configfile NuGet.config diff --git a/src/BackOffice/Pages/Inventory/Components/AddStockDialog.razor b/src/BackOffice/Pages/Inventory/Components/AddStockDialog.razor index 5f59e3e..a662b35 100644 --- a/src/BackOffice/Pages/Inventory/Components/AddStockDialog.razor +++ b/src/BackOffice/Pages/Inventory/Components/AddStockDialog.razor @@ -14,8 +14,8 @@ Variant="Variant.Outlined" Required="true" RequiredError="نوع محصول الزامی است"> - محصول عادی - محصول تخفیفی + محصول عادی + محصول تخفیفی @@ -102,7 +102,7 @@ private bool _formValid; private bool _isSubmitting; - private InventoryProductType _productType = InventoryProductType.Regular; + private InventoryProductType _productType = InventoryProductType.RegularProduct; private long _productId; private long? _warehouseId; private int _quantity = 1; @@ -156,15 +156,8 @@ var response = await InventoryContract.AddStockAsync(request); - if (response.Success) - { - Snackbar.Add($"موجودی جدید: {response.NewQuantity} عدد", Severity.Success); - MudDialog.Close(DialogResult.Ok(true)); - } - else - { - Snackbar.Add(response.Message ?? "خطا در ثبت موجودی", Severity.Error); - } + Snackbar.Add($"موجودی جدید: {response.NewQuantity} عدد", Severity.Success); + MudDialog.Close(DialogResult.Ok(true)); } catch (Exception ex) { diff --git a/src/BackOffice/Pages/Inventory/Components/AdjustStockDialog.razor b/src/BackOffice/Pages/Inventory/Components/AdjustStockDialog.razor index 0132af3..ee5de84 100644 --- a/src/BackOffice/Pages/Inventory/Components/AdjustStockDialog.razor +++ b/src/BackOffice/Pages/Inventory/Components/AdjustStockDialog.razor @@ -6,7 +6,7 @@ - محصول: @Item.ProductName + محصول: @Item.ProductTitle موجودی فعلی: @Item.Quantity عدد رزرو شده: @Item.ReservedQuantity عدد قابل فروش: @Item.AvailableQuantity عدد @@ -106,7 +106,7 @@ _isSubmitting = true; try { - var productId = Item.ProductType == ProductType.Regular + var productId = Item.ProductType == ProductType.RegularProduct ? (Item.ProductId ?? 0) : (Item.DiscountProductId ?? 0); @@ -115,20 +115,13 @@ ProductId = productId, ProductType = Item.ProductType, NewQuantity = _newQuantity, - Note = _note ?? string.Empty + Reason = _note ?? string.Empty }; var response = await InventoryContract.AdjustStockAsync(request); - if (response.Success) - { - Snackbar.Add(response.Message ?? "موجودی با موفقیت تنظیم شد", Severity.Success); - MudDialog.Close(DialogResult.Ok(true)); - } - else - { - Snackbar.Add(response.Message ?? "خطا در تنظیم موجودی", Severity.Error); - } + Snackbar.Add($"موجودی از {response.PreviousQuantity} به {response.NewQuantity} تغییر کرد (تفاوت: {response.Difference})", Severity.Success); + MudDialog.Close(DialogResult.Ok(true)); } catch (Exception ex) { diff --git a/src/BackOffice/Pages/Inventory/Components/InventorySettingsDialog.razor b/src/BackOffice/Pages/Inventory/Components/InventorySettingsDialog.razor index d450db5..b8d8285 100644 --- a/src/BackOffice/Pages/Inventory/Components/InventorySettingsDialog.razor +++ b/src/BackOffice/Pages/Inventory/Components/InventorySettingsDialog.razor @@ -6,7 +6,7 @@ - محصول: @Item.ProductName + محصول: @Item.ProductTitle انبار: @Item.WarehouseName @@ -110,7 +110,7 @@ { var request = new UpdateInventorySettingsRequest { - InventoryItemId = Item.Id, + Id = Item.Id, LowStockThreshold = _lowStockThreshold, ReorderPoint = _reorderPoint, MaxStockLevel = _maxStockLevel diff --git a/src/BackOffice/Pages/Inventory/Components/RecordLossDialog.razor b/src/BackOffice/Pages/Inventory/Components/RecordLossDialog.razor index 16979f0..a986123 100644 --- a/src/BackOffice/Pages/Inventory/Components/RecordLossDialog.razor +++ b/src/BackOffice/Pages/Inventory/Components/RecordLossDialog.razor @@ -6,7 +6,7 @@ - محصول: @Item.ProductName + محصول: @Item.ProductTitle موجودی فعلی: @Item.Quantity عدد @@ -33,6 +33,16 @@ Variant="Variant.Outlined" HelperText="شماره گزارش یا سند داخلی" /> + + خسارت عمومی + آسیب‌دیده + منقضی شده + + @if (_quantity > 0 && _quantity <= Item.Quantity) { @@ -73,6 +83,7 @@ private int _quantity = 1; private string _reason = string.Empty; private string _referenceNumber = string.Empty; + private StockMovementType _lossType = StockMovementType.Loss; private void Cancel() => MudDialog.Cancel(); @@ -93,7 +104,7 @@ _isSubmitting = true; try { - var productId = Item.ProductType == ProductType.Regular + var productId = Item.ProductType == ProductType.RegularProduct ? (Item.ProductId ?? 0) : (Item.DiscountProductId ?? 0); @@ -102,6 +113,7 @@ ProductId = productId, ProductType = Item.ProductType, Quantity = _quantity, + LossType = _lossType, Reason = _reason ?? string.Empty, ReferenceNumber = _referenceNumber ?? string.Empty }; diff --git a/src/BackOffice/Pages/Inventory/InventoryMainPage.razor b/src/BackOffice/Pages/Inventory/InventoryMainPage.razor index e1f950e..b9f2b8f 100644 --- a/src/BackOffice/Pages/Inventory/InventoryMainPage.razor +++ b/src/BackOffice/Pages/Inventory/InventoryMainPage.razor @@ -28,8 +28,8 @@ Variant="Variant.Outlined" Margin="Margin.Dense"> همه - محصول عادی - محصول تخفیفی + محصول عادی + محصول تخفیفی @@ -110,10 +110,10 @@ - + - @context.Item.ProductName + @context.Item.ProductTitle @GetProductTypeLabel(context.Item.ProductType) diff --git a/src/BackOffice/Pages/Inventory/InventoryMainPage.razor.cs b/src/BackOffice/Pages/Inventory/InventoryMainPage.razor.cs index 155fe0a..e9b6414 100644 --- a/src/BackOffice/Pages/Inventory/InventoryMainPage.razor.cs +++ b/src/BackOffice/Pages/Inventory/InventoryMainPage.razor.cs @@ -35,7 +35,7 @@ public partial class InventoryMainPage { var response = await InventoryContract.GetAllWarehousesAsync(new GetAllWarehousesRequest { - ActiveOnly = true + IsActive = true }); _warehouses = response.Warehouses.ToList(); } @@ -51,7 +51,8 @@ public partial class InventoryMainPage { var response = await InventoryContract.GetLowStockItemsAsync(new GetLowStockItemsRequest { - Count = 100 // Get up to 100 low stock items to count + Page = 1, + PageSize = 100 // Get up to 100 low stock items to count }); _lowStockCount = response.TotalCount; } @@ -67,10 +68,10 @@ public partial class InventoryMainPage { var request = new GetAllInventoryItemsRequest { - PageIndex = state.Page + 1, + Page = state.Page + 1, PageSize = state.PageSize, ProductType = _filterProductType, - SearchTerm = _searchTerm ?? string.Empty + Search = _searchTerm ?? string.Empty }; if (_filterWarehouseId.HasValue) @@ -103,8 +104,8 @@ public partial class InventoryMainPage { return type switch { - ProductType.Regular => "محصول عادی", - ProductType.Discount => "محصول تخفیفی", + ProductType.RegularProduct => "محصول عادی", + ProductType.DiscountProduct => "محصول تخفیفی", _ => "نامشخص" }; } @@ -153,13 +154,13 @@ public partial class InventoryMainPage var parameters = new DialogParameters { ["Warehouses"] = _warehouses, - ["ProductIdParam"] = item.ProductType == ProductType.Regular ? item.ProductId : item.DiscountProductId, + ["ProductIdParam"] = item.ProductType == ProductType.RegularProduct ? item.ProductId : item.DiscountProductId, ["ProductTypeParam"] = item.ProductType, - ["ProductName"] = item.ProductName, + ["ProductName"] = item.ProductTitle, ["WarehouseIdParam"] = item.WarehouseId }; - var dialog = await DialogService.ShowAsync($"ورود کالا - {item.ProductName}", parameters, new DialogOptions + var dialog = await DialogService.ShowAsync($"ورود کالا - {item.ProductTitle}", parameters, new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Medium, @@ -182,7 +183,7 @@ public partial class InventoryMainPage ["Item"] = item }; - var dialog = await DialogService.ShowAsync($"تنظیم موجودی - {item.ProductName}", parameters, new DialogOptions + var dialog = await DialogService.ShowAsync($"تنظیم موجودی - {item.ProductTitle}", parameters, new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Small, @@ -205,7 +206,7 @@ public partial class InventoryMainPage ["Item"] = item }; - var dialog = await DialogService.ShowAsync($"ثبت خسارت - {item.ProductName}", parameters, new DialogOptions + var dialog = await DialogService.ShowAsync($"ثبت خسارت - {item.ProductTitle}", parameters, new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Small, @@ -228,7 +229,7 @@ public partial class InventoryMainPage ["Item"] = item }; - var dialog = await DialogService.ShowAsync($"تنظیمات - {item.ProductName}", parameters, new DialogOptions + var dialog = await DialogService.ShowAsync($"تنظیمات - {item.ProductTitle}", parameters, new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Small, @@ -245,6 +246,6 @@ public partial class InventoryMainPage private void ViewMovements(InventoryItemDto item) { - Navigation.NavigateTo($"{RouteConstance.InventoryMovements}?itemId={item.Id}&productName={item.ProductName}"); + Navigation.NavigateTo($"{RouteConstance.InventoryMovements}?itemId={item.Id}&productName={item.ProductTitle}"); } } diff --git a/src/BackOffice/Pages/Inventory/LowStockPage.razor b/src/BackOffice/Pages/Inventory/LowStockPage.razor index e99e3ec..2540f2c 100644 --- a/src/BackOffice/Pages/Inventory/LowStockPage.razor +++ b/src/BackOffice/Pages/Inventory/LowStockPage.razor @@ -43,8 +43,8 @@ Variant="Variant.Outlined" Margin="Margin.Dense"> همه - محصول عادی - محصول تخفیفی + محصول عادی + محصول تخفیفی @@ -73,14 +73,14 @@ } else { - + - + - @context.Item.ProductName + @context.Item.ProductTitle @GetProductTypeLabel(context.Item.ProductType) @@ -136,7 +136,7 @@ - diff --git a/src/BackOffice/Pages/Inventory/LowStockPage.razor.cs b/src/BackOffice/Pages/Inventory/LowStockPage.razor.cs index 726dc88..0dfa1d6 100644 --- a/src/BackOffice/Pages/Inventory/LowStockPage.razor.cs +++ b/src/BackOffice/Pages/Inventory/LowStockPage.razor.cs @@ -10,7 +10,7 @@ public partial class LowStockPage { [Inject] public InventoryBFFContract.InventoryBFFContractClient InventoryContract { get; set; } = default!; - private List _items = new(); + private List _items = new(); private List _warehouses = new(); private bool _isLoading = true; @@ -30,7 +30,7 @@ public partial class LowStockPage { var response = await InventoryContract.GetAllWarehousesAsync(new GetAllWarehousesRequest { - ActiveOnly = true + IsActive = true }); _warehouses = response.Warehouses.ToList(); } @@ -49,7 +49,8 @@ public partial class LowStockPage { var request = new GetLowStockItemsRequest { - Count = 200, // Get up to 200 low stock items + Page = 1, + PageSize = 200, // Get up to 200 low stock items ProductType = _filterProductType }; @@ -77,15 +78,15 @@ public partial class LowStockPage { return type switch { - ProductType.Regular => "محصول عادی", - ProductType.Discount => "محصول تخفیفی", + ProductType.RegularProduct => "محصول عادی", + ProductType.DiscountProduct => "محصول تخفیفی", _ => "نامشخص" }; } - private async Task OpenAddStockDialog(LowStockItemDto item) + private async Task OpenAddStockDialog(InventoryItemDto item) { - var productId = item.ProductType == ProductType.Regular + var productId = item.ProductType == ProductType.RegularProduct ? (item.ProductId ?? 0) : (item.DiscountProductId ?? 0); @@ -94,11 +95,11 @@ public partial class LowStockPage ["Warehouses"] = _warehouses, ["ProductIdParam"] = productId, ["ProductTypeParam"] = item.ProductType, - ["ProductName"] = item.ProductName, + ["ProductName"] = item.ProductTitle, ["WarehouseIdParam"] = item.WarehouseId }; - var dialog = await DialogService.ShowAsync($"ورود کالا - {item.ProductName}", parameters, new DialogOptions + var dialog = await DialogService.ShowAsync($"ورود کالا - {item.ProductTitle}", parameters, new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Medium, diff --git a/src/BackOffice/Pages/Inventory/MovementsPage.razor b/src/BackOffice/Pages/Inventory/MovementsPage.razor index 92f77c9..5cae4ae 100644 --- a/src/BackOffice/Pages/Inventory/MovementsPage.razor +++ b/src/BackOffice/Pages/Inventory/MovementsPage.razor @@ -29,7 +29,7 @@ Label="نوع تغییر" Variant="Variant.Outlined" Margin="Margin.Dense"> - همه + همه موجودی اولیه ورود کالا برگشت از مشتری @@ -51,8 +51,8 @@ Variant="Variant.Outlined" Margin="Margin.Dense"> همه - محصول عادی - محصول تخفیفی + محصول عادی + محصول تخفیفی @@ -103,14 +103,14 @@ - + - + - @context.Item.MovementTypeName + @GetMovementTypeLabel(context.Item.MovementType) @@ -139,11 +139,11 @@ - + - @if (!string.IsNullOrEmpty(context.Item.PerformedByUserName)) + @if (context.Item.PerformedByUserId != null && context.Item.PerformedByUserId > 0) { - @context.Item.PerformedByUserName + کاربر #@context.Item.PerformedByUserId } else { @@ -152,12 +152,12 @@ - + - @if (context.Item.CreatedAt != null) + @if (context.Item.Created != null) { - @context.Item.CreatedAt.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd HH:mm") + @context.Item.Created.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd HH:mm") } diff --git a/src/BackOffice/Pages/Inventory/MovementsPage.razor.cs b/src/BackOffice/Pages/Inventory/MovementsPage.razor.cs index 25a9fb3..dd2f6a6 100644 --- a/src/BackOffice/Pages/Inventory/MovementsPage.razor.cs +++ b/src/BackOffice/Pages/Inventory/MovementsPage.razor.cs @@ -20,7 +20,7 @@ public partial class MovementsPage private int _totalCount; // Filter fields - private StockMovementType _filterMovementType = StockMovementType.Unspecified; + private StockMovementType _filterMovementType = StockMovementType.MovementTypeUnspecified; private ProductType _filterProductType = ProductType.Unspecified; private DateTime? _filterFromDate; private DateTime? _filterToDate; @@ -31,7 +31,7 @@ public partial class MovementsPage { var request = new GetStockMovementsRequest { - PageIndex = state.Page + 1, + Page = state.Page + 1, PageSize = state.PageSize, MovementType = _filterMovementType, ProductType = _filterProductType @@ -94,6 +94,27 @@ public partial class MovementsPage }; } + private string GetMovementTypeLabel(StockMovementType type) + { + return type switch + { + StockMovementType.InitialStock => "موجودی اولیه", + StockMovementType.Restock => "ورود کالا", + StockMovementType.Return => "برگشت از مشتری", + StockMovementType.Sale => "فروش", + StockMovementType.AdjustmentIncrease => "افزایش موجودی", + StockMovementType.AdjustmentDecrease => "کاهش موجودی", + StockMovementType.Reserved => "رزرو", + StockMovementType.Released => "آزادسازی رزرو", + StockMovementType.Loss => "خسارت", + StockMovementType.Damaged => "آسیب‌دیده", + StockMovementType.Expired => "منقضی", + StockMovementType.TransferOut => "انتقال به بیرون", + StockMovementType.TransferIn => "انتقال به داخل", + _ => "نامشخص" + }; + } + private bool IsIncreaseMovement(StockMovementType type) { return type switch @@ -118,7 +139,7 @@ public partial class MovementsPage private async Task ClearFilter() { - _filterMovementType = StockMovementType.Unspecified; + _filterMovementType = StockMovementType.MovementTypeUnspecified; _filterProductType = ProductType.Unspecified; _filterFromDate = null; _filterToDate = null; diff --git a/src/BackOffice/Pages/Inventory/WarehousesPage.razor.cs b/src/BackOffice/Pages/Inventory/WarehousesPage.razor.cs index f6949dc..42a43f4 100644 --- a/src/BackOffice/Pages/Inventory/WarehousesPage.razor.cs +++ b/src/BackOffice/Pages/Inventory/WarehousesPage.razor.cs @@ -28,7 +28,7 @@ public partial class WarehousesPage { var response = await InventoryContract.GetAllWarehousesAsync(new GetAllWarehousesRequest { - ActiveOnly = _showActiveOnly + IsActive = _showActiveOnly }); _warehouses = response.Warehouses.ToList(); }