diff --git a/Distribution/Features/SysConfig/SysConfigDTOs.cs b/Distribution/Features/SysConfig/SysConfigDTOs.cs
index 2907521..3269c26 100644
--- a/Distribution/Features/SysConfig/SysConfigDTOs.cs
+++ b/Distribution/Features/SysConfig/SysConfigDTOs.cs
@@ -7,3 +7,6 @@ public record SysConfigResponse(string Key, string Value, DateTime UpdatedAt, Gu
public record SetSysConfigRequest(string Value, Guid? UserId);
public record SetInvoiceCreationModeRequest(InvoiceCreationMode Mode);
+
+/// Which taxes apply to a GRN, whether each must be filled in, and the rate new GRNs start with.
+public record GrnTaxSettings(TaxMode VatMode, decimal VatDefaultRate, TaxMode NbtMode, decimal NbtDefaultRate);
diff --git a/Distribution/Features/SysConfig/SysConfigService.cs b/Distribution/Features/SysConfig/SysConfigService.cs
index a47bca1..1d8615b 100644
--- a/Distribution/Features/SysConfig/SysConfigService.cs
+++ b/Distribution/Features/SysConfig/SysConfigService.cs
@@ -14,6 +14,14 @@ public class SysConfigService(ISysConfigRepository repo, IUnitOfWork uow)
public const string KeyCustomWarrantyOverrideEnabled = "Feature.CustomWarrantyOverride";
public const string KeyDefaultWarrantyPeriodDays = "Feature.DefaultWarrantyPeriodDays";
+ public const string KeyGrnVatMode = "Grn.Tax.Vat.Mode";
+ public const string KeyGrnVatRate = "Grn.Tax.Vat.DefaultRate";
+ public const string KeyGrnNbtMode = "Grn.Tax.Nbt.Mode";
+ public const string KeyGrnNbtRate = "Grn.Tax.Nbt.DefaultRate";
+
+ private static readonly string[] TaxModeKeys = [KeyGrnVatMode, KeyGrnNbtMode];
+ private static readonly string[] TaxRateKeys = [KeyGrnVatRate, KeyGrnNbtRate];
+
private static readonly string[] BooleanFeatureKeys =
[
KeySerialNumberTrackingEnabled,
@@ -83,6 +91,33 @@ public class SysConfigService(ISysConfigRepository repo, IUnitOfWork uow)
return config is not null && int.TryParse(config.Value, out var days) ? days : 0;
}
+ ///
+ /// GRN tax settings. Unconfigured, VAT is Optional (how GRNs behaved before this setting existed)
+ /// and NBT is Disabled.
+ ///
+ public async Task GetGrnTaxSettingsAsync() => new(
+ await GetTaxModeAsync(KeyGrnVatMode, TaxMode.Optional),
+ await GetRateAsync(KeyGrnVatRate),
+ await GetTaxModeAsync(KeyGrnNbtMode, TaxMode.Disabled),
+ await GetRateAsync(KeyGrnNbtRate));
+
+ private async Task GetTaxModeAsync(string key, TaxMode fallback)
+ {
+ var config = await repo.GetByKeyAsync(key);
+ return config is not null && Enum.TryParse(config.Value, out var mode) && Enum.IsDefined(mode)
+ ? mode
+ : fallback;
+ }
+
+ private async Task GetRateAsync(string key)
+ {
+ var config = await repo.GetByKeyAsync(key);
+ return config is not null
+ && decimal.TryParse(config.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out var rate)
+ ? rate
+ : 0m;
+ }
+
private async Task GetBoolAsync(string key)
{
var config = await repo.GetByKeyAsync(key);
@@ -98,6 +133,15 @@ public class SysConfigService(ISysConfigRepository repo, IUnitOfWork uow)
if (BooleanFeatureKeys.Contains(key) && !bool.TryParse(value, out _))
throw new InvalidOperationException($"Invalid value '{value}' for '{key}'. Allowed values: true, false.");
+ if (TaxModeKeys.Contains(key) && (!Enum.TryParse(value, out var taxMode) || !Enum.IsDefined(taxMode)))
+ throw new InvalidOperationException(
+ $"Invalid value '{value}' for '{key}'. Allowed values: {string.Join(", ", Enum.GetNames())}.");
+
+ if (TaxRateKeys.Contains(key)
+ && (!decimal.TryParse(value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out var rate)
+ || rate < 0 || rate > 100))
+ throw new InvalidOperationException($"Invalid value '{value}' for '{key}'. Must be a percentage from 0 to 100.");
+
if (key == KeyDefaultWarrantyPeriodDays && (!int.TryParse(value, out var days) || days < 0))
throw new InvalidOperationException($"Invalid value '{value}' for '{key}'. Must be a non-negative integer.");
}
diff --git a/Distribution/Migrations/20261008060840_AddGrnNbt.Designer.cs b/Distribution/Migrations/20261008060840_AddGrnNbt.Designer.cs
new file mode 100644
index 0000000..9cabced
--- /dev/null
+++ b/Distribution/Migrations/20261008060840_AddGrnNbt.Designer.cs
@@ -0,0 +1,4423 @@
+//
+using System;
+using Distribution.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace Distribution.Migrations
+{
+ [DbContext(typeof(AppDBContext))]
+ [Migration("20261008060840_AddGrnNbt")]
+ partial class AddGrnNbt
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.0")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
+
+ modelBuilder.Entity("Distribution.Models.Brand", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("ExternalErpId")
+ .HasColumnType("int");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Brands");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("21000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ IsActive = true,
+ Name = "Coca-Cola"
+ },
+ new
+ {
+ Id = new Guid("21000000-0000-0000-0000-000000000002"),
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ IsActive = true,
+ Name = "Lays"
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.Category", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("AllowCustomerReturn")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("ExternalErpId")
+ .HasColumnType("int");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Categories");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("20000000-0000-0000-0000-000000000001"),
+ AllowCustomerReturn = false,
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ IsActive = true,
+ Name = "Beverages"
+ },
+ new
+ {
+ Id = new Guid("20000000-0000-0000-0000-000000000002"),
+ AllowCustomerReturn = false,
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ IsActive = true,
+ Name = "Snacks"
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.Claim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("Details")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("FK_AgencyUserId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("SettledAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("SettledByUserId")
+ .HasColumnType("char(36)");
+
+ b.Property("SettlementAmount")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_AgencyUserId");
+
+ b.HasIndex("SettledByUserId");
+
+ b.ToTable("Claims");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("53000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 27, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ Details = "Distributor margin claim for Q3 promotional shortfall",
+ FK_AgencyUserId = new Guid("70000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ SettledAt = new DateTime(2026, 8, 28, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ SettledByUserId = new Guid("29000000-0000-0000-0000-000000000006"),
+ SettlementAmount = 15000m,
+ Status = 1
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.CreditNote", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Amount")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_SaleReturnId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("IssuedAt")
+ .HasColumnType("datetime(6)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_SaleReturnId");
+
+ b.ToTable("CreditNotes");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("54000000-0000-0000-0000-000000000001"),
+ Amount = 300m,
+ CreatedAt = new DateTime(2026, 8, 26, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_SaleReturnId = new Guid("51000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ IssuedAt = new DateTime(2026, 8, 26, 0, 0, 0, 0, DateTimeKind.Unspecified)
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.DeliveryRun", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CancelReason")
+ .HasColumnType("longtext");
+
+ b.Property("CancelTypeCode")
+ .HasColumnType("int");
+
+ b.Property("ClosedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_DriverProfileId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_VehicleId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Meterend")
+ .HasColumnType("int");
+
+ b.Property("Meterstart")
+ .HasColumnType("int");
+
+ b.Property("StartedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_DriverProfileId");
+
+ b.HasIndex("FK_VehicleId");
+
+ b.ToTable("DeliveryRuns");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("31000000-0000-0000-0000-000000000001"),
+ ClosedAt = new DateTime(2026, 8, 25, 14, 0, 0, 0, DateTimeKind.Unspecified),
+ CreatedAt = new DateTime(2026, 8, 25, 7, 30, 0, 0, DateTimeKind.Unspecified),
+ FK_DriverProfileId = new Guid("30000000-0000-0000-0000-000000000001"),
+ FK_VehicleId = new Guid("28000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ Meterend = 10550,
+ Meterstart = 10500,
+ StartedAt = new DateTime(2026, 8, 25, 8, 0, 0, 0, DateTimeKind.Unspecified),
+ Status = 2
+ },
+ new
+ {
+ Id = new Guid("31000000-0000-0000-0000-000000000002"),
+ CreatedAt = new DateTime(2026, 8, 30, 8, 45, 0, 0, DateTimeKind.Unspecified),
+ FK_DriverProfileId = new Guid("30000000-0000-0000-0000-000000000002"),
+ FK_VehicleId = new Guid("28000000-0000-0000-0000-000000000002"),
+ IsActive = true,
+ Meterend = 0,
+ Meterstart = 20300,
+ StartedAt = new DateTime(2026, 8, 30, 9, 0, 0, 0, DateTimeKind.Unspecified),
+ Status = 0
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.DeliveryTask", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ConfirmedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CustomerConfirmed")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("FK_RideId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_ShopPOId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Note")
+ .HasColumnType("longtext");
+
+ b.Property("Sequence")
+ .HasColumnType("int");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_RideId");
+
+ b.HasIndex("FK_ShopPOId");
+
+ b.ToTable("DeliveryTasks");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("37000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 30, 10, 5, 0, 0, DateTimeKind.Unspecified),
+ CustomerConfirmed = false,
+ FK_RideId = new Guid("31000000-0000-0000-0000-000000000002"),
+ FK_ShopPOId = new Guid("33000000-0000-0000-0000-000000000002"),
+ IsActive = true,
+ Sequence = 1,
+ Status = 0
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.DriverComplianceConfig", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("EnforceLicenseExpiry")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("EnforceMedicalClearance")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.ToTable("DriverComplianceConfigs");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("64000000-0000-0000-0000-000000000001"),
+ EnforceLicenseExpiry = true,
+ EnforceMedicalClearance = true,
+ UpdatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ UpdatedBy = new Guid("29000000-0000-0000-0000-000000000001")
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.DriverProfile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_UserId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("LicenseExpiry")
+ .HasColumnType("datetime(6)");
+
+ b.Property("LicenseNumber")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("MedicalClearanceExpiry")
+ .HasColumnType("datetime(6)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_UserId")
+ .IsUnique();
+
+ b.ToTable("DriverProfiles");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("30000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_UserId = new Guid("29000000-0000-0000-0000-000000000004"),
+ IsActive = true,
+ LicenseExpiry = new DateTime(2027, 6, 30, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ LicenseNumber = "B1234567",
+ MedicalClearanceExpiry = new DateTime(2027, 1, 31, 0, 0, 0, 0, DateTimeKind.Unspecified)
+ },
+ new
+ {
+ Id = new Guid("30000000-0000-0000-0000-000000000002"),
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_UserId = new Guid("29000000-0000-0000-0000-000000000005"),
+ IsActive = true,
+ LicenseExpiry = new DateTime(2027, 9, 30, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ LicenseNumber = "B7654321",
+ MedicalClearanceExpiry = new DateTime(2027, 3, 31, 0, 0, 0, 0, DateTimeKind.Unspecified)
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.GoodsReceipt", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("DiscountPercent")
+ .HasPrecision(5, 2)
+ .HasColumnType("decimal(5,2)");
+
+ b.Property("FK_PurchaseOrderId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_ReceivedByUserId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_SupplierId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_WarehouseId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("NbtPercent")
+ .HasPrecision(5, 2)
+ .HasColumnType("decimal(5,2)");
+
+ b.Property("ReceivedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("VatPercent")
+ .HasPrecision(5, 2)
+ .HasColumnType("decimal(5,2)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_PurchaseOrderId");
+
+ b.HasIndex("FK_SupplierId");
+
+ b.HasIndex("FK_WarehouseId");
+
+ b.ToTable("GoodsReceipts");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("43000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 15, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ DiscountPercent = 0m,
+ FK_PurchaseOrderId = new Guid("41000000-0000-0000-0000-000000000001"),
+ FK_ReceivedByUserId = new Guid("29000000-0000-0000-0000-000000000001"),
+ FK_WarehouseId = new Guid("27000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ NbtPercent = 0m,
+ ReceivedAt = new DateTime(2026, 8, 15, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ VatPercent = 0m
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.GoodsReceiptItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("AcceptedQuantity")
+ .HasColumnType("int");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("DiscountPercent")
+ .HasPrecision(5, 2)
+ .HasColumnType("decimal(5,2)");
+
+ b.Property("FK_GoodsReceiptId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_ItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_PurchaseOrderItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("FreeQuantity")
+ .HasColumnType("int");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("NbtPercent")
+ .HasPrecision(5, 2)
+ .HasColumnType("decimal(5,2)");
+
+ b.Property("RejectedQuantity")
+ .HasColumnType("int");
+
+ b.Property("UnitCost")
+ .HasPrecision(18, 2)
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("VatPercent")
+ .HasPrecision(5, 2)
+ .HasColumnType("decimal(5,2)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_GoodsReceiptId");
+
+ b.HasIndex("FK_ItemId");
+
+ b.HasIndex("FK_PurchaseOrderItemId");
+
+ b.ToTable("GoodsReceiptItems");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("44000000-0000-0000-0000-000000000001"),
+ AcceptedQuantity = 200,
+ CreatedAt = new DateTime(2026, 8, 15, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ DiscountPercent = 0m,
+ FK_GoodsReceiptId = new Guid("43000000-0000-0000-0000-000000000001"),
+ FK_PurchaseOrderItemId = new Guid("42000000-0000-0000-0000-000000000001"),
+ FreeQuantity = 0,
+ IsActive = true,
+ NbtPercent = 0m,
+ RejectedQuantity = 0,
+ UnitCost = 0m,
+ VatPercent = 0m
+ },
+ new
+ {
+ Id = new Guid("44000000-0000-0000-0000-000000000002"),
+ AcceptedQuantity = 98,
+ CreatedAt = new DateTime(2026, 8, 15, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ DiscountPercent = 0m,
+ FK_GoodsReceiptId = new Guid("43000000-0000-0000-0000-000000000001"),
+ FK_PurchaseOrderItemId = new Guid("42000000-0000-0000-0000-000000000002"),
+ FreeQuantity = 0,
+ IsActive = true,
+ NbtPercent = 0m,
+ RejectedQuantity = 2,
+ UnitCost = 0m,
+ VatPercent = 0m
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.GoodsReceiptItemBatch", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_GoodsReceiptItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_ItemBatchId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Quantity")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_GoodsReceiptItemId");
+
+ b.HasIndex("FK_ItemBatchId");
+
+ b.ToTable("GoodsReceiptItemBatches");
+ });
+
+ modelBuilder.Entity("Distribution.Models.GoodsReceiptItemSerial", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_GoodsReceiptItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_ItemSerialNumberId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_GoodsReceiptItemId");
+
+ b.HasIndex("FK_ItemSerialNumberId");
+
+ b.ToTable("GoodsReceiptItemSerials");
+ });
+
+ modelBuilder.Entity("Distribution.Models.Invoice", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatedBy")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_ShopPOId")
+ .HasColumnType("char(36)");
+
+ b.Property("FinalizedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FinalizedBy")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("PaymentStatus")
+ .HasColumnType("int");
+
+ b.Property("PrintedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("PrintedBy")
+ .HasColumnType("char(36)");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("TotalAmount")
+ .HasColumnType("decimal(65,30)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_ShopPOId");
+
+ b.ToTable("Invoices");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("34500000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 25, 8, 30, 0, 0, DateTimeKind.Unspecified),
+ CreatedBy = new Guid("29000000-0000-0000-0000-000000000002"),
+ FK_ShopPOId = new Guid("33000000-0000-0000-0000-000000000001"),
+ FinalizedAt = new DateTime(2026, 8, 25, 9, 0, 0, 0, DateTimeKind.Unspecified),
+ FinalizedBy = new Guid("29000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ PaymentStatus = 2,
+ PrintedAt = new DateTime(2026, 8, 25, 8, 45, 0, 0, DateTimeKind.Unspecified),
+ PrintedBy = new Guid("29000000-0000-0000-0000-000000000002"),
+ Status = 2,
+ TotalAmount = 3000m
+ },
+ new
+ {
+ Id = new Guid("34500000-0000-0000-0000-000000000002"),
+ CreatedAt = new DateTime(2026, 8, 31, 9, 0, 0, 0, DateTimeKind.Unspecified),
+ CreatedBy = new Guid("29000000-0000-0000-0000-000000000003"),
+ FK_ShopPOId = new Guid("33000000-0000-0000-0000-000000000003"),
+ IsActive = true,
+ PaymentStatus = 1,
+ PrintedAt = new DateTime(2026, 8, 31, 9, 15, 0, 0, DateTimeKind.Unspecified),
+ PrintedBy = new Guid("29000000-0000-0000-0000-000000000003"),
+ Status = 1,
+ TotalAmount = 2400m
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.Item", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("AllowCustomWarrantyPeriod")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("CostPrice")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("ExternalErpItemId")
+ .HasColumnType("int");
+
+ b.Property("FK_BaseUomId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_BrandId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_CategoryId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_SubCategoryId")
+ .HasColumnType("char(36)");
+
+ b.Property("HasWarranty")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("LastSyncedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("ReorderLevel")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("SalePrice")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("Sku")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("SyncSource")
+ .HasColumnType("int");
+
+ b.Property("TracksBatches")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("TracksExpiryDate")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("TracksSerialNumbers")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("WarrantyPeriodDays")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_BaseUomId");
+
+ b.HasIndex("FK_BrandId");
+
+ b.HasIndex("FK_CategoryId");
+
+ b.HasIndex("FK_SubCategoryId");
+
+ b.ToTable("Items");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("23000000-0000-0000-0000-000000000001"),
+ AllowCustomWarrantyPeriod = false,
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ Description = "Coca-Cola 500ml bottle",
+ FK_BaseUomId = new Guid("22000000-0000-0000-0000-000000000001"),
+ FK_BrandId = new Guid("21000000-0000-0000-0000-000000000001"),
+ FK_CategoryId = new Guid("20000000-0000-0000-0000-000000000001"),
+ HasWarranty = false,
+ IsActive = true,
+ Name = "Coca-Cola 500ml",
+ SalePrice = 60m,
+ Sku = "BEV-COKE-500",
+ SyncSource = 0,
+ TracksBatches = false,
+ TracksExpiryDate = false,
+ TracksSerialNumbers = false
+ },
+ new
+ {
+ Id = new Guid("23000000-0000-0000-0000-000000000002"),
+ AllowCustomWarrantyPeriod = false,
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ Description = "Coca-Cola 1.5L bottle",
+ FK_BaseUomId = new Guid("22000000-0000-0000-0000-000000000001"),
+ FK_BrandId = new Guid("21000000-0000-0000-0000-000000000001"),
+ FK_CategoryId = new Guid("20000000-0000-0000-0000-000000000001"),
+ HasWarranty = false,
+ IsActive = true,
+ Name = "Coca-Cola 1.5L",
+ SalePrice = 120m,
+ Sku = "BEV-COKE-1500",
+ SyncSource = 0,
+ TracksBatches = false,
+ TracksExpiryDate = false,
+ TracksSerialNumbers = false
+ },
+ new
+ {
+ Id = new Guid("23000000-0000-0000-0000-000000000003"),
+ AllowCustomWarrantyPeriod = false,
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ Description = "Lays Classic Salted 52g pack",
+ FK_BaseUomId = new Guid("22000000-0000-0000-0000-000000000001"),
+ FK_BrandId = new Guid("21000000-0000-0000-0000-000000000002"),
+ FK_CategoryId = new Guid("20000000-0000-0000-0000-000000000002"),
+ HasWarranty = false,
+ IsActive = true,
+ Name = "Lays Classic 52g",
+ SalePrice = 50m,
+ Sku = "SNK-LAYS-52",
+ SyncSource = 0,
+ TracksBatches = false,
+ TracksExpiryDate = false,
+ TracksSerialNumbers = false
+ },
+ new
+ {
+ Id = new Guid("23000000-0000-0000-0000-000000000004"),
+ AllowCustomWarrantyPeriod = false,
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ Description = "Lays Family Pack 150g",
+ FK_BaseUomId = new Guid("22000000-0000-0000-0000-000000000001"),
+ FK_BrandId = new Guid("21000000-0000-0000-0000-000000000002"),
+ FK_CategoryId = new Guid("20000000-0000-0000-0000-000000000002"),
+ HasWarranty = false,
+ IsActive = true,
+ Name = "Lays Family Pack 150g",
+ SalePrice = 150m,
+ Sku = "SNK-LAYS-FAM",
+ SyncSource = 0,
+ TracksBatches = false,
+ TracksExpiryDate = false,
+ TracksSerialNumbers = false
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.ItemBatch", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("BatchNumber")
+ .HasColumnType("varchar(255)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("ExpiryDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_ItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("ManufactureDate")
+ .HasColumnType("datetime(6)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_ItemId", "BatchNumber");
+
+ b.ToTable("ItemBatches");
+ });
+
+ modelBuilder.Entity("Distribution.Models.ItemSerialNumber", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CurrentLocationId")
+ .HasColumnType("char(36)");
+
+ b.Property("CurrentLocationType")
+ .HasColumnType("int");
+
+ b.Property("FK_ItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("ReceivedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("SerialNumber")
+ .IsRequired()
+ .HasColumnType("varchar(255)");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("WarrantyExpiresAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("WarrantyPeriodDaysOverride")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_ItemId", "SerialNumber")
+ .IsUnique();
+
+ b.ToTable("ItemSerialNumbers");
+ });
+
+ modelBuilder.Entity("Distribution.Models.LoadingSheet", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ConfirmedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("ConfirmedBy")
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_RideId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("PopulatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("PopulatedBy")
+ .HasColumnType("char(36)");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_RideId");
+
+ b.ToTable("LoadingSheets");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("35000000-0000-0000-0000-000000000001"),
+ ConfirmedAt = new DateTime(2026, 8, 25, 7, 45, 0, 0, DateTimeKind.Unspecified),
+ ConfirmedBy = new Guid("29000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 25, 7, 30, 0, 0, DateTimeKind.Unspecified),
+ FK_RideId = new Guid("31000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ PopulatedAt = new DateTime(2026, 8, 25, 7, 30, 0, 0, DateTimeKind.Unspecified),
+ PopulatedBy = new Guid("29000000-0000-0000-0000-000000000001"),
+ Status = 1
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.LoadingSheetItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_ItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_LoadingSheetId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_ShopPOItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_WarehouseId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("QuantityDispatched")
+ .HasColumnType("decimal(65,30)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_ItemId");
+
+ b.HasIndex("FK_LoadingSheetId");
+
+ b.HasIndex("FK_ShopPOItemId");
+
+ b.HasIndex("FK_WarehouseId");
+
+ b.ToTable("LoadingSheetItems");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("36000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 25, 7, 30, 0, 0, DateTimeKind.Unspecified),
+ FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"),
+ FK_LoadingSheetId = new Guid("35000000-0000-0000-0000-000000000001"),
+ FK_WarehouseId = new Guid("27000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ QuantityDispatched = 50m
+ },
+ new
+ {
+ Id = new Guid("36000000-0000-0000-0000-000000000002"),
+ CreatedAt = new DateTime(2026, 8, 25, 7, 30, 0, 0, DateTimeKind.Unspecified),
+ FK_ItemId = new Guid("23000000-0000-0000-0000-000000000003"),
+ FK_LoadingSheetId = new Guid("35000000-0000-0000-0000-000000000001"),
+ FK_WarehouseId = new Guid("27000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ QuantityDispatched = 30m
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.LoadingSheetOrder", b =>
+ {
+ b.Property("FK_LoadingSheetId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_ShopPOId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("FK_LoadingSheetId", "FK_ShopPOId");
+
+ b.HasIndex("FK_ShopPOId");
+
+ b.ToTable("LoadingSheetOrders");
+ });
+
+ modelBuilder.Entity("Distribution.Models.Payment", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Amount")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("ChequeDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("ChequeNumber")
+ .HasColumnType("longtext");
+
+ b.Property("CollectedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CollectedBy")
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("EntryMode")
+ .HasColumnType("int");
+
+ b.Property("FK_InvoiceId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Method")
+ .HasColumnType("int");
+
+ b.Property("RecordedBy")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_InvoiceId");
+
+ b.ToTable("Payments");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("47000000-0000-0000-0000-000000000001"),
+ Amount = 3000m,
+ CollectedAt = new DateTime(2026, 8, 25, 9, 30, 0, 0, DateTimeKind.Unspecified),
+ CollectedBy = new Guid("29000000-0000-0000-0000-000000000002"),
+ CreatedAt = new DateTime(2026, 8, 25, 9, 30, 0, 0, DateTimeKind.Unspecified),
+ EntryMode = 0,
+ FK_InvoiceId = new Guid("34500000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ Method = 0
+ },
+ new
+ {
+ Id = new Guid("47000000-0000-0000-0000-000000000002"),
+ Amount = 1000m,
+ CollectedAt = new DateTime(2026, 8, 31, 9, 20, 0, 0, DateTimeKind.Unspecified),
+ CollectedBy = new Guid("29000000-0000-0000-0000-000000000003"),
+ CreatedAt = new DateTime(2026, 8, 31, 9, 20, 0, 0, DateTimeKind.Unspecified),
+ EntryMode = 0,
+ FK_InvoiceId = new Guid("34500000-0000-0000-0000-000000000002"),
+ IsActive = true,
+ Method = 0
+ },
+ new
+ {
+ Id = new Guid("47000000-0000-0000-0000-000000000003"),
+ Amount = 800m,
+ ChequeDate = new DateTime(2026, 8, 31, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ ChequeNumber = "000456",
+ CollectedAt = new DateTime(2026, 8, 31, 11, 0, 0, 0, DateTimeKind.Unspecified),
+ CollectedBy = new Guid("29000000-0000-0000-0000-000000000003"),
+ CreatedAt = new DateTime(2026, 8, 31, 18, 0, 0, 0, DateTimeKind.Unspecified),
+ EntryMode = 1,
+ FK_InvoiceId = new Guid("34500000-0000-0000-0000-000000000002"),
+ IsActive = true,
+ Method = 1,
+ RecordedBy = new Guid("29000000-0000-0000-0000-000000000001")
+ },
+ new
+ {
+ Id = new Guid("47000000-0000-0000-0000-000000000004"),
+ Amount = 300m,
+ CollectedAt = new DateTime(2026, 8, 31, 11, 5, 0, 0, DateTimeKind.Unspecified),
+ CollectedBy = new Guid("29000000-0000-0000-0000-000000000003"),
+ CreatedAt = new DateTime(2026, 8, 31, 11, 5, 0, 0, DateTimeKind.Unspecified),
+ EntryMode = 0,
+ FK_InvoiceId = new Guid("34500000-0000-0000-0000-000000000002"),
+ IsActive = true,
+ Method = 2
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.Permission", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Permissions");
+ });
+
+ modelBuilder.Entity("Distribution.Models.PriceList", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("EffectiveFrom")
+ .HasColumnType("datetime(6)");
+
+ b.Property("EffectiveTo")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_RegionId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_RegionId");
+
+ b.ToTable("PriceLists");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("39000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ EffectiveFrom = new DateTime(2026, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ EffectiveTo = new DateTime(2026, 12, 31, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_RegionId = new Guid("24000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ Name = "Western Province Price List"
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.PriceListItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("AgencyMarginPercent")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_ItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_PriceListId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("MinPrice")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("Price")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("RetailPrice")
+ .HasColumnType("decimal(65,30)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_ItemId");
+
+ b.HasIndex("FK_PriceListId", "FK_ItemId")
+ .IsUnique();
+
+ b.ToTable("PriceListItems");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("40000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"),
+ FK_PriceListId = new Guid("39000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ MinPrice = 55m,
+ Price = 60m
+ },
+ new
+ {
+ Id = new Guid("40000000-0000-0000-0000-000000000002"),
+ CreatedAt = new DateTime(2026, 8, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_ItemId = new Guid("23000000-0000-0000-0000-000000000003"),
+ FK_PriceListId = new Guid("39000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ MinPrice = 45m,
+ Price = 50m
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.PurchaseOrder", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CancelReason")
+ .HasColumnType("longtext");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_CreatedByUserId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_SupplierId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_SupplierId");
+
+ b.ToTable("PurchaseOrders");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("41000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 14, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_CreatedByUserId = new Guid("29000000-0000-0000-0000-000000000001"),
+ FK_SupplierId = new Guid("38000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ Status = 2
+ },
+ new
+ {
+ Id = new Guid("41000000-0000-0000-0000-000000000002"),
+ CreatedAt = new DateTime(2026, 8, 14, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_CreatedByUserId = new Guid("29000000-0000-0000-0000-000000000001"),
+ FK_SupplierId = new Guid("38000000-0000-0000-0000-000000000002"),
+ IsActive = true,
+ Status = 2
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.PurchaseOrderItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CancelledQuantity")
+ .HasColumnType("int");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_ItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_PurchaseOrderId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("IsCancelled")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Quantity")
+ .HasColumnType("int");
+
+ b.Property("ReceivedQuantity")
+ .HasColumnType("int");
+
+ b.Property("UnitCost")
+ .HasColumnType("decimal(65,30)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_ItemId");
+
+ b.HasIndex("FK_PurchaseOrderId");
+
+ b.ToTable("PurchaseOrderItems");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("42000000-0000-0000-0000-000000000001"),
+ CancelledQuantity = 0,
+ CreatedAt = new DateTime(2026, 8, 14, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"),
+ FK_PurchaseOrderId = new Guid("41000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ IsCancelled = false,
+ Quantity = 200,
+ ReceivedQuantity = 200,
+ UnitCost = 40m
+ },
+ new
+ {
+ Id = new Guid("42000000-0000-0000-0000-000000000002"),
+ CancelledQuantity = 0,
+ CreatedAt = new DateTime(2026, 8, 14, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_ItemId = new Guid("23000000-0000-0000-0000-000000000002"),
+ FK_PurchaseOrderId = new Guid("41000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ IsCancelled = false,
+ Quantity = 100,
+ ReceivedQuantity = 98,
+ UnitCost = 80m
+ },
+ new
+ {
+ Id = new Guid("42000000-0000-0000-0000-000000000003"),
+ CancelledQuantity = 0,
+ CreatedAt = new DateTime(2026, 8, 14, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_ItemId = new Guid("23000000-0000-0000-0000-000000000003"),
+ FK_PurchaseOrderId = new Guid("41000000-0000-0000-0000-000000000002"),
+ IsActive = true,
+ IsCancelled = false,
+ Quantity = 150,
+ ReceivedQuantity = 150,
+ UnitCost = 35m
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.PurchaseReturn", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_PurchaseOrderId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Reason")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_PurchaseOrderId");
+
+ b.ToTable("PurchaseReturns");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("45000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 16, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_PurchaseOrderId = new Guid("41000000-0000-0000-0000-000000000002"),
+ IsActive = true,
+ Reason = "Damaged in transit"
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.PurchaseReturnItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_ItemId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_PurchaseReturnId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Quantity")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_ItemId");
+
+ b.HasIndex("FK_PurchaseReturnId");
+
+ b.ToTable("PurchaseReturnItems");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("46000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 16, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_ItemId = new Guid("23000000-0000-0000-0000-000000000003"),
+ FK_PurchaseReturnId = new Guid("45000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ Quantity = 10
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.Region", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Code")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Code")
+ .IsUnique();
+
+ b.ToTable("Regions");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("24000000-0000-0000-0000-000000000001"),
+ Code = "REG-0001",
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ IsActive = true,
+ Name = "Western Province"
+ },
+ new
+ {
+ Id = new Guid("24000000-0000-0000-0000-000000000002"),
+ Code = "REG-0002",
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ IsActive = true,
+ Name = "Central Province"
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.RegionAgencyMap", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_AgencyUserId")
+ .HasColumnType("char(36)");
+
+ b.Property("FK_RegionId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_AgencyUserId");
+
+ b.HasIndex("FK_RegionId", "FK_AgencyUserId")
+ .IsUnique();
+
+ b.ToTable("RegionAgencyMaps");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("57000000-0000-0000-0000-000000000001"),
+ CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_AgencyUserId = new Guid("70000000-0000-0000-0000-000000000001"),
+ FK_RegionId = new Guid("24000000-0000-0000-0000-000000000001"),
+ IsActive = true
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.RegionalBudget", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("BudgetAmount")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_RegionId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("Period")
+ .IsRequired()
+ .HasColumnType("varchar(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FK_RegionId", "Period")
+ .IsUnique();
+
+ b.ToTable("RegionalBudgets");
+
+ b.HasData(
+ new
+ {
+ Id = new Guid("58000000-0000-0000-0000-000000000001"),
+ BudgetAmount = 200000m,
+ CreatedAt = new DateTime(2026, 8, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
+ FK_RegionId = new Guid("24000000-0000-0000-0000-000000000001"),
+ IsActive = true,
+ Period = "2026-08"
+ });
+ });
+
+ modelBuilder.Entity("Distribution.Models.RegionalTarget", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)");
+
+ b.Property("FK_RegionId")
+ .HasColumnType("char(36)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property