diff --git a/Distribution/Data/AppDBContext.cs b/Distribution/Data/AppDBContext.cs index 61404bd..4c20ce0 100644 --- a/Distribution/Data/AppDBContext.cs +++ b/Distribution/Data/AppDBContext.cs @@ -65,6 +65,10 @@ public class AppDBContext(DbContextOptions options) : DbContext(op public DbSet RegionalTaxRules { get; set; } public DbSet RouteVisitLogs { get; set; } public DbSet SysConfigs { get; set; } + public DbSet BankAccounts { get; set; } + public DbSet ChequeBooks { get; set; } + public DbSet ChequePages { get; set; } + public DbSet ReceivedCheques { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -594,6 +598,61 @@ public class AppDBContext(DbContextOptions options) : DbContext(op new SysConfig { Key = Distribution.Features.SysConfig.SysConfigService.KeyDefaultWarrantyPeriodDays, Value = "0", UpdatedAt = new DateTime(2026, 10, 1), UpdatedBy = null } ); + // --- Payment service: Bank Accounts & Cheques --- + + modelBuilder.Entity() + .Property(a => a.AccountName).HasMaxLength(200); + modelBuilder.Entity() + .Property(a => a.BankName).HasMaxLength(200); + modelBuilder.Entity() + .Property(a => a.CashAccountTypeName).HasMaxLength(100); + modelBuilder.Entity() + .Property(a => a.AccountNumber).HasMaxLength(100); + modelBuilder.Entity() + .Property(a => a.CurrencyCode).HasMaxLength(10); + modelBuilder.Entity() + .HasIndex(a => new { a.AccountType, a.AccountName }) + .IsUnique(); + + modelBuilder.Entity() + .Property(b => b.ChequeBookNo).HasMaxLength(100); + modelBuilder.Entity() + .Property(b => b.StartChequeNo).HasMaxLength(50); + modelBuilder.Entity() + .Property(b => b.EndChequeNo).HasMaxLength(50); + modelBuilder.Entity() + .HasIndex(b => b.ChequeBookNo).IsUnique(); + modelBuilder.Entity() + .HasOne(b => b.BankAccount) + .WithMany() + .HasForeignKey(b => b.FK_BankAccountId) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .Property(p => p.ChequeNo).HasMaxLength(50); + modelBuilder.Entity() + .Property(p => p.CurrencyCode).HasMaxLength(10); + modelBuilder.Entity() + .HasIndex(p => p.ChequeNo).IsUnique(); + modelBuilder.Entity() + .HasOne(p => p.ChequeBook) + .WithMany(b => b.Pages) + .HasForeignKey(p => p.FK_ChequeBookId) + .OnDelete(DeleteBehavior.Cascade); + + modelBuilder.Entity() + .Property(c => c.ChequeNo).HasMaxLength(50); + modelBuilder.Entity() + .Property(c => c.ReceivedFromName).HasMaxLength(200); + modelBuilder.Entity() + .HasIndex(c => c.ChequeNo); + modelBuilder.Entity() + .HasOne(c => c.DepositBankAccount) + .WithMany() + .HasForeignKey(c => c.FK_DepositBankAccountId) + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(false); + Seed.RoleAndPermissionSeed.Apply(modelBuilder); Seed.MasterDataSeed.Apply(modelBuilder); Seed.OperationsDataSeed.Apply(modelBuilder); diff --git a/Distribution/Features/BankAccount/BankAccountController.cs b/Distribution/Features/BankAccount/BankAccountController.cs new file mode 100644 index 0000000..8cc8699 --- /dev/null +++ b/Distribution/Features/BankAccount/BankAccountController.cs @@ -0,0 +1,66 @@ +using Distribution.Models; +using Microsoft.AspNetCore.Mvc; + +namespace Distribution.Features.BankAccount; + +[ApiController] +[Route("api")] +public class BankAccountController(BankAccountService service) : ControllerBase +{ + [HttpGet("bank-accounts")] + public async Task List([FromQuery] BankAccountType? accountType) + { + var result = await service.ListAsync(accountType); + return Ok(result); + } + + [HttpPost("bank-accounts")] + public async Task CreateBank(CreateBankAccountRequest request, CancellationToken ct) + { + try { return Ok(await service.CreateBankAsync(request, ct)); } + catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); } + } + + [HttpPost("cash-accounts")] + public async Task CreateCash(CreateCashAccountRequest request, CancellationToken ct) + { + try { return Ok(await service.CreateCashAsync(request, ct)); } + catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); } + } + + [HttpPut("cash-accounts/{id:guid}")] + public async Task UpdateCash(Guid id, UpdateCashAccountRequest request, CancellationToken ct) + { + try + { + var result = await service.UpdateCashAsync(id, request, ct); + return result is null ? NotFound() : Ok(result); + } + catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); } + } + + [HttpPatch("cash-accounts/{id:guid}/status")] + public async Task SetCashStatus(Guid id, SetCashAccountStatusRequest request, CancellationToken ct) + { + try + { + var result = await service.SetCashStatusAsync(id, request, ct); + return result is null ? NotFound() : Ok(result); + } + catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); } + } + + [HttpDelete("cash-accounts/{id:guid}")] + public async Task DeleteCash(Guid id, CancellationToken ct) + { + try + { + var ok = await service.DeleteCashAsync(id, ct); + return ok ? NoContent() : NotFound(); + } + catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); } + } + + [HttpGet("cash-account-types")] + public async Task ListCashAccountTypes() => Ok(await service.ListCashAccountTypesAsync()); +} diff --git a/Distribution/Features/BankAccount/BankAccountDTOs.cs b/Distribution/Features/BankAccount/BankAccountDTOs.cs new file mode 100644 index 0000000..987a2b9 --- /dev/null +++ b/Distribution/Features/BankAccount/BankAccountDTOs.cs @@ -0,0 +1,33 @@ +using Distribution.Models; + +namespace Distribution.Features.BankAccount; + +public record BankAccountResponse( + BankAccountType AccountType, + Guid AccountId, + string AccountName, + string? BankName, + string? CashAccountTypeName, + string? AccountNumber, + string CurrencyCode, + DateTime CreatedAt, + bool? IsActive, + bool? IsDefault); + +public record CreateBankAccountRequest( + string AccountName, + string? BankName, + string? AccountNumber, + string? CurrencyCode); + +public record CreateCashAccountRequest( + string AccountName, + string CashAccountTypeName, + string? AccountNumber, + string? CurrencyCode); + +public record UpdateCashAccountRequest(string AccountName); + +public record SetCashAccountStatusRequest(bool IsActive); + +public record CashAccountTypeDto(string Name); diff --git a/Distribution/Features/BankAccount/BankAccountRepository.cs b/Distribution/Features/BankAccount/BankAccountRepository.cs new file mode 100644 index 0000000..da014c6 --- /dev/null +++ b/Distribution/Features/BankAccount/BankAccountRepository.cs @@ -0,0 +1,40 @@ +using Distribution.Data; +using Distribution.Models; +using Microsoft.EntityFrameworkCore; + +namespace Distribution.Features.BankAccount; + +public class BankAccountRepository(AppDBContext context) : IBankAccountRepository +{ + public async Task GetByIdAsync(Guid id) => + await context.BankAccounts.FirstOrDefaultAsync(a => a.Id == id); + + public async Task> ListAsync(BankAccountType? accountType) + { + var query = context.BankAccounts.AsQueryable(); + if (accountType is not null) + query = query.Where(a => a.AccountType == accountType); + return await query.OrderByDescending(a => a.CreatedAt).ToListAsync(); + } + + public async Task> ListCashAccountTypeNamesAsync() => + await context.BankAccounts + .Where(a => a.AccountType == BankAccountType.Cash && a.CashAccountTypeName != null) + .Select(a => a.CashAccountTypeName!) + .Distinct() + .OrderBy(n => n) + .ToListAsync(); + + public async Task ExistsByNameAsync(BankAccountType type, string accountName, Guid? excludeId = null) => + await context.BankAccounts.AnyAsync(a => + a.AccountType == type && + a.AccountName == accountName && + (excludeId == null || a.Id != excludeId)); + + public async Task AddAsync(Models.BankAccount account) => + await context.BankAccounts.AddAsync(account); + + public void Update(Models.BankAccount account) => context.BankAccounts.Update(account); + + public void Remove(Models.BankAccount account) => context.BankAccounts.Remove(account); +} diff --git a/Distribution/Features/BankAccount/BankAccountService.cs b/Distribution/Features/BankAccount/BankAccountService.cs new file mode 100644 index 0000000..e17e557 --- /dev/null +++ b/Distribution/Features/BankAccount/BankAccountService.cs @@ -0,0 +1,116 @@ +using Distribution.Infra.UoW; +using Distribution.Models; + +namespace Distribution.Features.BankAccount; + +public class BankAccountService(IBankAccountRepository repo, IUnitOfWork uow) +{ + private const string DefaultCurrency = "LKR"; + + private static BankAccountResponse ToResponse(Models.BankAccount a) => + new( + a.AccountType, + a.Id, + a.AccountName, + a.AccountType == BankAccountType.Bank ? a.BankName : null, + a.AccountType == BankAccountType.Cash ? a.CashAccountTypeName : null, + a.AccountNumber, + a.CurrencyCode, + a.CreatedAt, + a.AccountType == BankAccountType.Cash ? a.IsActive : null, + a.AccountType == BankAccountType.Cash ? a.IsDefault : null); + + public async Task> ListAsync(BankAccountType? accountType) => + (await repo.ListAsync(accountType)).Select(ToResponse).ToList(); + + public async Task> ListCashAccountTypesAsync() => + (await repo.ListCashAccountTypeNamesAsync()).Select(n => new CashAccountTypeDto(n)).ToList(); + + public async Task CreateBankAsync(CreateBankAccountRequest request, CancellationToken ct = default) + { + if (string.IsNullOrWhiteSpace(request.AccountName)) + throw new InvalidOperationException("AccountName is required"); + if (await repo.ExistsByNameAsync(BankAccountType.Bank, request.AccountName)) + throw new InvalidOperationException("A bank account with this name already exists"); + + var account = new Models.BankAccount + { + AccountType = BankAccountType.Bank, + AccountName = request.AccountName, + BankName = request.BankName, + AccountNumber = request.AccountNumber, + CurrencyCode = string.IsNullOrWhiteSpace(request.CurrencyCode) ? DefaultCurrency : request.CurrencyCode!, + IsActive = true, + IsDefault = false + }; + + await repo.AddAsync(account); + await uow.CommitAsync(ct); + return ToResponse(account); + } + + public async Task CreateCashAsync(CreateCashAccountRequest request, CancellationToken ct = default) + { + if (string.IsNullOrWhiteSpace(request.AccountName)) + throw new InvalidOperationException("AccountName is required"); + if (string.IsNullOrWhiteSpace(request.CashAccountTypeName)) + throw new InvalidOperationException("CashAccountTypeName is required"); + if (await repo.ExistsByNameAsync(BankAccountType.Cash, request.AccountName)) + throw new InvalidOperationException("A cash account with this name already exists"); + + var account = new Models.BankAccount + { + AccountType = BankAccountType.Cash, + AccountName = request.AccountName, + CashAccountTypeName = request.CashAccountTypeName, + AccountNumber = request.AccountNumber, + CurrencyCode = string.IsNullOrWhiteSpace(request.CurrencyCode) ? DefaultCurrency : request.CurrencyCode!, + IsActive = true, + IsDefault = false + }; + + await repo.AddAsync(account); + await uow.CommitAsync(ct); + return ToResponse(account); + } + + public async Task UpdateCashAsync(Guid id, UpdateCashAccountRequest request, CancellationToken ct = default) + { + var account = await repo.GetByIdAsync(id); + if (account is null || account.AccountType != BankAccountType.Cash) return null; + if (string.IsNullOrWhiteSpace(request.AccountName)) + throw new InvalidOperationException("AccountName is required"); + if (await repo.ExistsByNameAsync(BankAccountType.Cash, request.AccountName, excludeId: id)) + throw new InvalidOperationException("A cash account with this name already exists"); + + account.AccountName = request.AccountName; + repo.Update(account); + await uow.CommitAsync(ct); + return ToResponse(account); + } + + public async Task SetCashStatusAsync(Guid id, SetCashAccountStatusRequest request, CancellationToken ct = default) + { + var account = await repo.GetByIdAsync(id); + if (account is null || account.AccountType != BankAccountType.Cash) return null; + if (account.IsDefault && !request.IsActive) + throw new InvalidOperationException("The default cash account cannot be deactivated"); + + account.IsActive = request.IsActive; + repo.Update(account); + await uow.CommitAsync(ct); + return ToResponse(account); + } + + public async Task DeleteCashAsync(Guid id, CancellationToken ct = default) + { + var account = await repo.GetByIdAsync(id); + if (account is null || account.AccountType != BankAccountType.Cash) return false; + if (account.IsDefault) + throw new InvalidOperationException("The default cash account cannot be deleted"); + + repo.Remove(account); + await uow.CommitAsync(ct); + return true; + } +} diff --git a/Distribution/Features/BankAccount/IBankAccountRepository.cs b/Distribution/Features/BankAccount/IBankAccountRepository.cs new file mode 100644 index 0000000..44c3a45 --- /dev/null +++ b/Distribution/Features/BankAccount/IBankAccountRepository.cs @@ -0,0 +1,14 @@ +using Distribution.Models; + +namespace Distribution.Features.BankAccount; + +public interface IBankAccountRepository +{ + Task GetByIdAsync(Guid id); + Task> ListAsync(BankAccountType? accountType); + Task> ListCashAccountTypeNamesAsync(); + Task ExistsByNameAsync(BankAccountType type, string accountName, Guid? excludeId = null); + Task AddAsync(Models.BankAccount account); + void Update(Models.BankAccount account); + void Remove(Models.BankAccount account); +} diff --git a/Distribution/Features/ChequeBook/ChequeBookController.cs b/Distribution/Features/ChequeBook/ChequeBookController.cs new file mode 100644 index 0000000..57cb149 --- /dev/null +++ b/Distribution/Features/ChequeBook/ChequeBookController.cs @@ -0,0 +1,55 @@ +using Distribution.Models; +using Microsoft.AspNetCore.Mvc; + +namespace Distribution.Features.ChequeBook; + +[ApiController] +[Route("api")] +public class ChequeBookController(ChequeBookService service) : ControllerBase +{ + [HttpGet("cheque-books")] + public async Task List( + [FromQuery] Guid? bankAccountId, + [FromQuery] int? branchId, + [FromQuery] ChequeBookStatus? status, + [FromQuery] int page = 1, + [FromQuery] int pageSize = 50) + => Ok(await service.ListAsync(bankAccountId, branchId, status, page, pageSize)); + + [HttpGet("cheque-books/{chequeBookNo}")] + public async Task Get(string chequeBookNo, [FromQuery] string? expand) + { + var expandPages = string.Equals(expand, "pages", StringComparison.OrdinalIgnoreCase); + var result = await service.GetAsync(chequeBookNo, expandPages); + return result is null ? NotFound() : Ok(result); + } + + [HttpPost("cheque-books")] + public async Task Create(CreateChequeBookRequest request, CancellationToken ct) + { + try { return Ok(await service.CreateAsync(request, ct)); } + catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); } + } + + [HttpPut("cheque-pages/{chequeNo}/issue")] + public async Task Issue(string chequeNo, IssueChequePageRequest request, CancellationToken ct) + { + try + { + var result = await service.IssueAsync(chequeNo, request, ct); + return result is null ? NotFound() : Ok(result); + } + catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); } + } + + [HttpPut("cheque-pages/{chequeNo}/status")] + public async Task UpdateStatus(string chequeNo, UpdateChequePageStatusRequest request, CancellationToken ct) + { + try + { + var result = await service.UpdatePageStatusAsync(chequeNo, request, ct); + return result is null ? NotFound() : Ok(result); + } + catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); } + } +} diff --git a/Distribution/Features/ChequeBook/ChequeBookDTOs.cs b/Distribution/Features/ChequeBook/ChequeBookDTOs.cs new file mode 100644 index 0000000..0787a7b --- /dev/null +++ b/Distribution/Features/ChequeBook/ChequeBookDTOs.cs @@ -0,0 +1,74 @@ +using Distribution.Models; + +namespace Distribution.Features.ChequeBook; + +public record ChequePageResponse( + string ChequeNo, + string ChequeBookNo, + ChequePageIssueStatus IssueStatus, + PayeeType? PayeeType, + int? PayeeId, + string? PayeeName, + DateTime? IssueDate, + decimal? Amount, + string? CurrencyCode, + int? VoucherId, + string? ReferenceNo, + string? Purpose, + bool? IsCrossCheque, + bool? IsAccountPayee, + bool? IsPostDated, + string? Notes, + string? PrintedBy, + DateTime? PrintedAt, + DateTime? ClearedDate, + bool? ClearedByBank, + string? CancelReason); + +public record ChequeBookResponse( + string ChequeBookNo, + int BranchId, + Guid BankAccountId, + string StartChequeNo, + string EndChequeNo, + int TotalLeaves, + DateTime ReceivedDate, + string? Description, + string? CreatedBy, + ChequeBookStatus Status, + List Pages); + +public record PagedResult(IReadOnlyList Items, int TotalCount, int? Page, int? PageSize); + +public record CreateChequeBookRequest( + int BranchId, + Guid BankAccountId, + string ChequeBookNo, + string StartChequeNo, + string EndChequeNo, + int TotalLeaves, + DateTime ReceivedDate, + string? Description, + string? CreatedBy); + +public record IssueChequePageRequest( + PayeeType PayeeType, + int? PayeeId, + string PayeeName, + DateTime IssueDate, + decimal Amount, + string? CurrencyCode, + int? VoucherId, + string? ReferenceNo, + string? Purpose, + bool? IsCrossCheque, + bool? IsAccountPayee, + bool? IsPostDated, + string? Notes, + string? PrintedBy); + +public record UpdateChequePageStatusRequest( + ChequePageStatusAction Action, + DateTime? ClearedDate, + string? CancelReason, + string? PerformedBy); diff --git a/Distribution/Features/ChequeBook/ChequeBookRepository.cs b/Distribution/Features/ChequeBook/ChequeBookRepository.cs new file mode 100644 index 0000000..2c215f7 --- /dev/null +++ b/Distribution/Features/ChequeBook/ChequeBookRepository.cs @@ -0,0 +1,46 @@ +using Distribution.Data; +using Distribution.Models; +using Microsoft.EntityFrameworkCore; + +namespace Distribution.Features.ChequeBook; + +public class ChequeBookRepository(AppDBContext context) : IChequeBookRepository +{ + public async Task GetByNoAsync(string chequeBookNo, bool includePages) + { + var query = context.ChequeBooks.AsQueryable(); + if (includePages) query = query.Include(b => b.Pages); + return await query.FirstOrDefaultAsync(b => b.ChequeBookNo == chequeBookNo); + } + + public async Task<(List Items, int TotalCount)> ListAsync( + Guid? bankAccountId, int? branchId, ChequeBookStatus? status, int page, int pageSize) + { + var query = context.ChequeBooks.AsQueryable(); + if (bankAccountId is not null) query = query.Where(b => b.FK_BankAccountId == bankAccountId); + if (branchId is not null) query = query.Where(b => b.BranchId == branchId); + if (status is not null) query = query.Where(b => b.Status == status); + + var total = await query.CountAsync(); + var items = await query + .OrderByDescending(b => b.CreatedAt) + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToListAsync(); + return (items, total); + } + + public async Task BookNoExistsAsync(string chequeBookNo) => + await context.ChequeBooks.AnyAsync(b => b.ChequeBookNo == chequeBookNo); + + public async Task AddAsync(Models.ChequeBook book) => await context.ChequeBooks.AddAsync(book); + + public void Update(Models.ChequeBook book) => context.ChequeBooks.Update(book); + + public async Task GetPageByNoAsync(string chequeNo) => + await context.ChequePages + .Include(p => p.ChequeBook) + .FirstOrDefaultAsync(p => p.ChequeNo == chequeNo); + + public void UpdatePage(Models.ChequePage page) => context.ChequePages.Update(page); +} diff --git a/Distribution/Features/ChequeBook/ChequeBookService.cs b/Distribution/Features/ChequeBook/ChequeBookService.cs new file mode 100644 index 0000000..6df3436 --- /dev/null +++ b/Distribution/Features/ChequeBook/ChequeBookService.cs @@ -0,0 +1,176 @@ +using Distribution.Features.BankAccount; +using Distribution.Infra.UoW; +using Distribution.Models; + +namespace Distribution.Features.ChequeBook; + +public class ChequeBookService( + IChequeBookRepository repo, + IBankAccountRepository bankAccountRepo, + IUnitOfWork uow) +{ + private const string DefaultCurrency = "LKR"; + + private static ChequePageResponse ToPageResponse(Models.ChequePage p, string chequeBookNo) => + new(p.ChequeNo, chequeBookNo, p.IssueStatus, p.PayeeType, p.PayeeId, p.PayeeName, + p.IssueDate, p.Amount, p.CurrencyCode, p.VoucherId, p.ReferenceNo, p.Purpose, + p.IsCrossCheque, p.IsAccountPayee, p.IsPostDated, p.Notes, + p.PrintedBy, p.PrintedAt, p.ClearedDate, p.ClearedByBank, p.CancelReason); + + private static ChequeBookResponse ToBookResponse(Models.ChequeBook b, bool includePages) => + new(b.ChequeBookNo, b.BranchId, b.FK_BankAccountId, b.StartChequeNo, b.EndChequeNo, + b.TotalLeaves, b.ReceivedDate, b.Description, b.CreatedBy, b.Status, + includePages ? b.Pages.OrderBy(p => p.ChequeNo).Select(p => ToPageResponse(p, b.ChequeBookNo)).ToList() : new()); + + public async Task> ListAsync( + Guid? bankAccountId, int? branchId, ChequeBookStatus? status, int page, int pageSize) + { + if (page < 1) page = 1; + if (pageSize < 1 || pageSize > 200) pageSize = 50; + + var (items, total) = await repo.ListAsync(bankAccountId, branchId, status, page, pageSize); + return new PagedResult( + items.Select(b => ToBookResponse(b, includePages: false)).ToList(), + total, page, pageSize); + } + + public async Task GetAsync(string chequeBookNo, bool expandPages) + { + var book = await repo.GetByNoAsync(chequeBookNo, includePages: expandPages); + return book is null ? null : ToBookResponse(book, includePages: expandPages); + } + + public async Task CreateAsync(CreateChequeBookRequest request, CancellationToken ct = default) + { + if (string.IsNullOrWhiteSpace(request.ChequeBookNo)) + throw new InvalidOperationException("ChequeBookNo is required"); + if (request.TotalLeaves <= 0) + throw new InvalidOperationException("TotalLeaves must be greater than zero"); + if (!long.TryParse(request.StartChequeNo, out var start) || + !long.TryParse(request.EndChequeNo, out var end)) + throw new InvalidOperationException("StartChequeNo and EndChequeNo must be numeric"); + if (end < start) + throw new InvalidOperationException("EndChequeNo must be greater than or equal to StartChequeNo"); + if (end - start + 1 != request.TotalLeaves) + throw new InvalidOperationException("TotalLeaves does not match the Start/End cheque range"); + if (await repo.BookNoExistsAsync(request.ChequeBookNo)) + throw new InvalidOperationException("A cheque book with this number already exists"); + + var bankAccount = await bankAccountRepo.GetByIdAsync(request.BankAccountId); + if (bankAccount is null || bankAccount.AccountType != BankAccountType.Bank) + throw new InvalidOperationException("BankAccountId does not reference a valid bank account"); + + var book = new Models.ChequeBook + { + ChequeBookNo = request.ChequeBookNo, + BranchId = request.BranchId, + FK_BankAccountId = request.BankAccountId, + StartChequeNo = request.StartChequeNo, + EndChequeNo = request.EndChequeNo, + TotalLeaves = request.TotalLeaves, + ReceivedDate = request.ReceivedDate, + Description = request.Description, + CreatedBy = request.CreatedBy, + Status = ChequeBookStatus.Active + }; + + var width = request.StartChequeNo.Length; + for (var n = start; n <= end; n++) + { + book.Pages.Add(new Models.ChequePage + { + ChequeNo = n.ToString().PadLeft(width, '0'), + IssueStatus = ChequePageIssueStatus.Unused + }); + } + + await uow.BeginAsync(ct); + try + { + await repo.AddAsync(book); + await uow.CommitAsync(ct); + } + catch { await uow.RollbackAsync(ct); throw; } + + return ToBookResponse(book, includePages: true); + } + + public async Task IssueAsync(string chequeNo, IssueChequePageRequest request, CancellationToken ct = default) + { + var page = await repo.GetPageByNoAsync(chequeNo); + if (page is null) return null; + if (page.IssueStatus != ChequePageIssueStatus.Unused) + throw new InvalidOperationException($"Cannot issue a cheque in status '{page.IssueStatus}'"); + if (page.ChequeBook is null || page.ChequeBook.Status != ChequeBookStatus.Active) + throw new InvalidOperationException("The cheque book is not active"); + if (request.Amount <= 0) + throw new InvalidOperationException("Amount must be greater than zero"); + if (string.IsNullOrWhiteSpace(request.PayeeName)) + throw new InvalidOperationException("PayeeName is required"); + + page.IssueStatus = ChequePageIssueStatus.Issued; + page.PayeeType = request.PayeeType; + page.PayeeId = request.PayeeId; + page.PayeeName = request.PayeeName; + page.IssueDate = request.IssueDate; + page.Amount = request.Amount; + page.CurrencyCode = string.IsNullOrWhiteSpace(request.CurrencyCode) ? DefaultCurrency : request.CurrencyCode; + page.VoucherId = request.VoucherId; + page.ReferenceNo = request.ReferenceNo; + page.Purpose = request.Purpose; + page.IsCrossCheque = request.IsCrossCheque; + page.IsAccountPayee = request.IsAccountPayee; + page.IsPostDated = request.IsPostDated; + page.Notes = request.Notes; + page.PrintedBy = request.PrintedBy; + page.PrintedAt = DateTime.Now; + + repo.UpdatePage(page); + await uow.CommitAsync(ct); + return ToPageResponse(page, page.ChequeBook!.ChequeBookNo); + } + + public async Task UpdatePageStatusAsync(string chequeNo, UpdateChequePageStatusRequest request, CancellationToken ct = default) + { + var page = await repo.GetPageByNoAsync(chequeNo); + if (page is null) return null; + + switch (request.Action) + { + case ChequePageStatusAction.Clear: + if (page.IssueStatus != ChequePageIssueStatus.Issued) + throw new InvalidOperationException("Only issued cheques can be cleared"); + if (request.ClearedDate is null) + throw new InvalidOperationException("ClearedDate is required when clearing a cheque"); + page.IssueStatus = ChequePageIssueStatus.Cleared; + page.ClearedDate = request.ClearedDate; + page.ClearedByBank = true; + break; + + case ChequePageStatusAction.Bounce: + if (page.IssueStatus != ChequePageIssueStatus.Issued) + throw new InvalidOperationException("Only issued cheques can be bounced"); + page.IssueStatus = ChequePageIssueStatus.Bounced; + break; + + case ChequePageStatusAction.Cancel: + if (page.IssueStatus != ChequePageIssueStatus.Issued) + throw new InvalidOperationException("Only issued cheques can be cancelled"); + if (string.IsNullOrWhiteSpace(request.CancelReason)) + throw new InvalidOperationException("CancelReason is required when cancelling a cheque"); + page.IssueStatus = ChequePageIssueStatus.Cancelled; + page.CancelReason = request.CancelReason; + break; + + case ChequePageStatusAction.Void: + if (page.IssueStatus != ChequePageIssueStatus.Unused) + throw new InvalidOperationException("Only unused cheques can be voided"); + page.IssueStatus = ChequePageIssueStatus.Void; + break; + } + + repo.UpdatePage(page); + await uow.CommitAsync(ct); + return ToPageResponse(page, page.ChequeBook!.ChequeBookNo); + } +} diff --git a/Distribution/Features/ChequeBook/IChequeBookRepository.cs b/Distribution/Features/ChequeBook/IChequeBookRepository.cs new file mode 100644 index 0000000..cc40b6b --- /dev/null +++ b/Distribution/Features/ChequeBook/IChequeBookRepository.cs @@ -0,0 +1,16 @@ +using Distribution.Models; + +namespace Distribution.Features.ChequeBook; + +public interface IChequeBookRepository +{ + Task GetByNoAsync(string chequeBookNo, bool includePages); + Task<(List Items, int TotalCount)> ListAsync( + Guid? bankAccountId, int? branchId, ChequeBookStatus? status, int page, int pageSize); + Task BookNoExistsAsync(string chequeBookNo); + Task AddAsync(Models.ChequeBook book); + void Update(Models.ChequeBook book); + + Task GetPageByNoAsync(string chequeNo); + void UpdatePage(Models.ChequePage page); +} diff --git a/Distribution/Features/ReceivedCheque/IReceivedChequeRepository.cs b/Distribution/Features/ReceivedCheque/IReceivedChequeRepository.cs new file mode 100644 index 0000000..d2903ce --- /dev/null +++ b/Distribution/Features/ReceivedCheque/IReceivedChequeRepository.cs @@ -0,0 +1,13 @@ +using Distribution.Models; + +namespace Distribution.Features.ReceivedCheque; + +public interface IReceivedChequeRepository +{ + Task GetByIdAsync(Guid id); + Task<(List Items, int TotalCount)> ListAsync( + int? companyId, int? branchId, ReceivedChequeStatus? status, ReceivedFromType? receivedFromType, + int page, int pageSize); + Task AddAsync(Models.ReceivedCheque cheque); + void Update(Models.ReceivedCheque cheque); +} diff --git a/Distribution/Features/ReceivedCheque/ReceivedChequeController.cs b/Distribution/Features/ReceivedCheque/ReceivedChequeController.cs new file mode 100644 index 0000000..8beb5ca --- /dev/null +++ b/Distribution/Features/ReceivedCheque/ReceivedChequeController.cs @@ -0,0 +1,37 @@ +using Distribution.Models; +using Microsoft.AspNetCore.Mvc; + +namespace Distribution.Features.ReceivedCheque; + +[ApiController] +[Route("api/received-cheques")] +public class ReceivedChequeController(ReceivedChequeService service) : ControllerBase +{ + [HttpGet] + public async Task List( + [FromQuery] int? companyId, + [FromQuery] int? branchId, + [FromQuery] ReceivedChequeStatus? status, + [FromQuery] ReceivedFromType? receivedFromType, + [FromQuery] int page = 1, + [FromQuery] int pageSize = 50) + => Ok(await service.ListAsync(companyId, branchId, status, receivedFromType, page, pageSize)); + + [HttpPost] + public async Task Create(CreateReceivedChequeRequest request, CancellationToken ct) + { + try { return Ok(await service.CreateAsync(request, ct)); } + catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); } + } + + [HttpPut("{id:guid}/status")] + public async Task UpdateStatus(Guid id, UpdateReceivedChequeStatusRequest request, CancellationToken ct) + { + try + { + var result = await service.UpdateStatusAsync(id, request, ct); + return result is null ? NotFound() : Ok(result); + } + catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); } + } +} diff --git a/Distribution/Features/ReceivedCheque/ReceivedChequeDTOs.cs b/Distribution/Features/ReceivedCheque/ReceivedChequeDTOs.cs new file mode 100644 index 0000000..5b86af1 --- /dev/null +++ b/Distribution/Features/ReceivedCheque/ReceivedChequeDTOs.cs @@ -0,0 +1,51 @@ +using Distribution.Features.ChequeBook; +using Distribution.Models; + +namespace Distribution.Features.ReceivedCheque; + +public record ReceivedChequeResponse( + Guid ReceivedChequeId, + int CompanyId, + int? BranchId, + ReceivedFromType ReceivedFromType, + int? ReceivedFromId, + string ReceivedFromName, + string? DrawerBankName, + string? DrawerBankBranch, + string? AccountHolderName, + string ChequeNo, + DateTime ChequeDate, + decimal Amount, + DateTime ReceivedDate, + string? ReferenceType, + int? ReferenceId, + string? Notes, + string? CreatedBy, + ReceivedChequeStatus Status, + Guid? DepositBankAccountId, + DateTime? DepositDate); + +public record CreateReceivedChequeRequest( + int CompanyId, + int? BranchId, + ReceivedFromType ReceivedFromType, + int? ReceivedFromId, + string ReceivedFromName, + string? DrawerBankName, + string? DrawerBankBranch, + string? AccountHolderName, + string ChequeNo, + DateTime ChequeDate, + decimal Amount, + DateTime ReceivedDate, + string? ReferenceType, + int? ReferenceId, + string? Notes, + string? CreatedBy); + +public record UpdateReceivedChequeStatusRequest( + ReceivedChequeStatusAction Action, + Guid? DepositBankAccountId, + DateTime? DepositDate, + string? Notes, + string? PerformedBy); diff --git a/Distribution/Features/ReceivedCheque/ReceivedChequeRepository.cs b/Distribution/Features/ReceivedCheque/ReceivedChequeRepository.cs new file mode 100644 index 0000000..cb00382 --- /dev/null +++ b/Distribution/Features/ReceivedCheque/ReceivedChequeRepository.cs @@ -0,0 +1,34 @@ +using Distribution.Data; +using Distribution.Models; +using Microsoft.EntityFrameworkCore; + +namespace Distribution.Features.ReceivedCheque; + +public class ReceivedChequeRepository(AppDBContext context) : IReceivedChequeRepository +{ + public async Task GetByIdAsync(Guid id) => + await context.ReceivedCheques.FirstOrDefaultAsync(c => c.Id == id); + + public async Task<(List Items, int TotalCount)> ListAsync( + int? companyId, int? branchId, ReceivedChequeStatus? status, ReceivedFromType? receivedFromType, + int page, int pageSize) + { + var query = context.ReceivedCheques.AsQueryable(); + if (companyId is not null) query = query.Where(c => c.CompanyId == companyId); + if (branchId is not null) query = query.Where(c => c.BranchId == branchId); + if (status is not null) query = query.Where(c => c.Status == status); + if (receivedFromType is not null) query = query.Where(c => c.ReceivedFromType == receivedFromType); + + var total = await query.CountAsync(); + var items = await query + .OrderByDescending(c => c.ReceivedDate) + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToListAsync(); + return (items, total); + } + + public async Task AddAsync(Models.ReceivedCheque cheque) => await context.ReceivedCheques.AddAsync(cheque); + + public void Update(Models.ReceivedCheque cheque) => context.ReceivedCheques.Update(cheque); +} diff --git a/Distribution/Features/ReceivedCheque/ReceivedChequeService.cs b/Distribution/Features/ReceivedCheque/ReceivedChequeService.cs new file mode 100644 index 0000000..bf29679 --- /dev/null +++ b/Distribution/Features/ReceivedCheque/ReceivedChequeService.cs @@ -0,0 +1,115 @@ +using Distribution.Features.BankAccount; +using Distribution.Features.ChequeBook; +using Distribution.Infra.UoW; +using Distribution.Models; + +namespace Distribution.Features.ReceivedCheque; + +public class ReceivedChequeService( + IReceivedChequeRepository repo, + IBankAccountRepository bankAccountRepo, + IUnitOfWork uow) +{ + private static ReceivedChequeResponse ToResponse(Models.ReceivedCheque c) => + new(c.Id, c.CompanyId, c.BranchId, c.ReceivedFromType, c.ReceivedFromId, c.ReceivedFromName, + c.DrawerBankName, c.DrawerBankBranch, c.AccountHolderName, + c.ChequeNo, c.ChequeDate, c.Amount, c.ReceivedDate, + c.ReferenceType, c.ReferenceId, c.Notes, c.CreatedBy, + c.Status, c.FK_DepositBankAccountId, c.DepositDate); + + public async Task> ListAsync( + int? companyId, int? branchId, ReceivedChequeStatus? status, ReceivedFromType? receivedFromType, + int page, int pageSize) + { + if (page < 1) page = 1; + if (pageSize < 1 || pageSize > 200) pageSize = 50; + + var (items, total) = await repo.ListAsync(companyId, branchId, status, receivedFromType, page, pageSize); + return new PagedResult( + items.Select(ToResponse).ToList(), total, page, pageSize); + } + + public async Task CreateAsync(CreateReceivedChequeRequest request, CancellationToken ct = default) + { + if (string.IsNullOrWhiteSpace(request.ReceivedFromName)) + throw new InvalidOperationException("ReceivedFromName is required"); + if (string.IsNullOrWhiteSpace(request.ChequeNo)) + throw new InvalidOperationException("ChequeNo is required"); + if (request.Amount <= 0) + throw new InvalidOperationException("Amount must be greater than zero"); + + var cheque = new Models.ReceivedCheque + { + CompanyId = request.CompanyId, + BranchId = request.BranchId, + ReceivedFromType = request.ReceivedFromType, + ReceivedFromId = request.ReceivedFromId, + ReceivedFromName = request.ReceivedFromName, + DrawerBankName = request.DrawerBankName, + DrawerBankBranch = request.DrawerBankBranch, + AccountHolderName = request.AccountHolderName, + ChequeNo = request.ChequeNo, + ChequeDate = request.ChequeDate, + Amount = request.Amount, + ReceivedDate = request.ReceivedDate, + ReferenceType = request.ReferenceType, + ReferenceId = request.ReferenceId, + Notes = request.Notes, + CreatedBy = request.CreatedBy, + Status = ReceivedChequeStatus.Received + }; + + await repo.AddAsync(cheque); + await uow.CommitAsync(ct); + return ToResponse(cheque); + } + + public async Task UpdateStatusAsync(Guid id, UpdateReceivedChequeStatusRequest request, CancellationToken ct = default) + { + var cheque = await repo.GetByIdAsync(id); + if (cheque is null) return null; + + switch (request.Action) + { + case ReceivedChequeStatusAction.Deposit: + if (cheque.Status != ReceivedChequeStatus.Received) + throw new InvalidOperationException("Only received cheques can be deposited"); + if (request.DepositBankAccountId is null) + throw new InvalidOperationException("DepositBankAccountId is required when depositing"); + if (request.DepositDate is null) + throw new InvalidOperationException("DepositDate is required when depositing"); + var bankAccount = await bankAccountRepo.GetByIdAsync(request.DepositBankAccountId.Value); + if (bankAccount is null || bankAccount.AccountType != BankAccountType.Bank) + throw new InvalidOperationException("DepositBankAccountId does not reference a valid bank account"); + cheque.Status = ReceivedChequeStatus.Deposited; + cheque.FK_DepositBankAccountId = request.DepositBankAccountId; + cheque.DepositDate = request.DepositDate; + break; + + case ReceivedChequeStatusAction.Clear: + if (cheque.Status != ReceivedChequeStatus.Deposited) + throw new InvalidOperationException("Only deposited cheques can be cleared"); + cheque.Status = ReceivedChequeStatus.Cleared; + break; + + case ReceivedChequeStatusAction.Return: + if (cheque.Status != ReceivedChequeStatus.Deposited) + throw new InvalidOperationException("Only deposited cheques can be returned"); + cheque.Status = ReceivedChequeStatus.Returned; + break; + + case ReceivedChequeStatusAction.Cancel: + if (cheque.Status != ReceivedChequeStatus.Received) + throw new InvalidOperationException("Only received cheques can be cancelled"); + cheque.Status = ReceivedChequeStatus.Cancelled; + break; + } + + if (!string.IsNullOrWhiteSpace(request.Notes)) + cheque.Notes = request.Notes; + + repo.Update(cheque); + await uow.CommitAsync(ct); + return ToResponse(cheque); + } +} diff --git a/Distribution/Migrations/20261019092950_AddPaymentServiceModule.Designer.cs b/Distribution/Migrations/20261019092950_AddPaymentServiceModule.Designer.cs new file mode 100644 index 0000000..00881d0 --- /dev/null +++ b/Distribution/Migrations/20261019092950_AddPaymentServiceModule.Designer.cs @@ -0,0 +1,5546 @@ +// +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("20261019092950_AddPaymentServiceModule")] + partial class AddPaymentServiceModule + { + /// + 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.BankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccountName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("AccountNumber") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("AccountType") + .HasColumnType("int"); + + b.Property("BankName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("CashAccountTypeName") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrencyCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.HasIndex("AccountType", "AccountName") + .IsUnique(); + + b.ToTable("BankAccounts"); + }); + + 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.ChequeBook", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BranchId") + .HasColumnType("int"); + + b.Property("ChequeBookNo") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedBy") + .HasColumnType("longtext"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("EndChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("FK_BankAccountId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("ReceivedDate") + .HasColumnType("datetime(6)"); + + b.Property("StartChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalLeaves") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChequeBookNo") + .IsUnique(); + + b.HasIndex("FK_BankAccountId"); + + b.ToTable("ChequeBooks"); + }); + + modelBuilder.Entity("Distribution.Models.ChequePage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CancelReason") + .HasColumnType("longtext"); + + b.Property("ChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ClearedByBank") + .HasColumnType("tinyint(1)"); + + b.Property("ClearedDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrencyCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("FK_ChequeBookId") + .HasColumnType("char(36)"); + + b.Property("IsAccountPayee") + .HasColumnType("tinyint(1)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsCrossCheque") + .HasColumnType("tinyint(1)"); + + b.Property("IsPostDated") + .HasColumnType("tinyint(1)"); + + b.Property("IssueDate") + .HasColumnType("datetime(6)"); + + b.Property("IssueStatus") + .HasColumnType("int"); + + b.Property("Notes") + .HasColumnType("longtext"); + + b.Property("PayeeId") + .HasColumnType("int"); + + b.Property("PayeeName") + .HasColumnType("longtext"); + + b.Property("PayeeType") + .HasColumnType("int"); + + b.Property("PrintedAt") + .HasColumnType("datetime(6)"); + + b.Property("PrintedBy") + .HasColumnType("longtext"); + + b.Property("Purpose") + .HasColumnType("longtext"); + + b.Property("ReferenceNo") + .HasColumnType("longtext"); + + b.Property("VoucherId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChequeNo") + .IsUnique(); + + b.HasIndex("FK_ChequeBookId"); + + b.ToTable("ChequePages"); + }); + + 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"); + + b.HasData( + new + { + Id = new Guid("20000000-0000-0000-0000-000000000001"), + Code = "orders.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View shop POs, invoices, payments and returns", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000002"), + Code = "rides.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage delivery rides and delivery tasks", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000003"), + Code = "loading.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage loading sheets", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000004"), + Code = "stores.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View store accounts, credit limits and balances", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000005"), + Code = "sales_visits.checkin", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Check in and out of scheduled store visits", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000006"), + Code = "items.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage catalogue products", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000007"), + Code = "categories.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage product categories and brands", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000008"), + Code = "warehouses.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View stock balances, movements, warehouses and reports", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000009"), + Code = "purchase_orders.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage purchase orders, GRNs and supplier claims", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000010"), + Code = "pricelists.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage regional price lists", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000011"), + Code = "schemes.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage pricing schemes and promotions", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000012"), + Code = "suppliers.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage supplier accounts", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000013"), + Code = "driver_profiles.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage driver profiles and licensing", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000014"), + Code = "compliance.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Manage driver compliance rules", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000015"), + Code = "users.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage staff user accounts", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000016"), + Code = "roles.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage roles and their permission sets", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000017"), + Code = "regions.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage regions and region configuration", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000018"), + Code = "routes.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage delivery routes", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000019"), + Code = "vehicles.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View and manage fleet vehicles", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000020"), + Code = "claim.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View agency claims and settlement status", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000021"), + Code = "claim.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and settle agency claims", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000022"), + Code = "delivery-task.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View delivery tasks within a ride", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000023"), + Code = "delivery-task.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Confirm and fail delivery tasks", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000024"), + Code = "driver.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View driver profiles and license details", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000025"), + Code = "driver.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and update driver profiles", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000026"), + Code = "grn.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View goods receipt notes", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000027"), + Code = "grn.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and confirm goods receipts", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000028"), + Code = "loading-sheet.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View loading sheets and their items", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000029"), + Code = "loading-sheet.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create, edit, and confirm loading sheets", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000030"), + Code = "price-list.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View regional price lists", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000031"), + Code = "price-list.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and manage item price lists", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000032"), + Code = "purchase-order.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View purchase orders and line items", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000033"), + Code = "purchase-order.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create, confirm, and close purchase orders", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000034"), + Code = "purchase-return.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and manage purchase returns to suppliers", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000035"), + Code = "region.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View regions and their configuration", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000036"), + Code = "region.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and update regions, targets, and budgets", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000037"), + Code = "return.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View order returns", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000038"), + Code = "return.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and manage order returns", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000039"), + Code = "route.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View delivery routes", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000040"), + Code = "route.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and manage delivery routes", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000041"), + Code = "scheme.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View pricing schemes and promotions", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000042"), + Code = "scheme.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and configure pricing schemes", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000043"), + Code = "stock.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View stock balances and movements", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000044"), + Code = "stock.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Transfer stock and record damage or adjustments", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000045"), + Code = "store.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View store accounts and balances", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000046"), + Code = "store.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and update store accounts", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000047"), + Code = "supplier-claim.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View supplier claims", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000048"), + Code = "supplier-claim.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Create and resolve supplier claims", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000049"), + Code = "sys-config.view", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "View system configuration settings", + IsActive = true + }, + new + { + Id = new Guid("20000000-0000-0000-0000-000000000050"), + Code = "sys-config.manage", + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Update system configuration settings", + IsActive = true + }); + }); + + 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.ReceivedCheque", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccountHolderName") + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("BranchId") + .HasColumnType("int"); + + b.Property("ChequeDate") + .HasColumnType("datetime(6)"); + + b.Property("ChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedBy") + .HasColumnType("longtext"); + + b.Property("DepositDate") + .HasColumnType("datetime(6)"); + + b.Property("DrawerBankBranch") + .HasColumnType("longtext"); + + b.Property("DrawerBankName") + .HasColumnType("longtext"); + + b.Property("FK_DepositBankAccountId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Notes") + .HasColumnType("longtext"); + + b.Property("ReceivedDate") + .HasColumnType("datetime(6)"); + + b.Property("ReceivedFromId") + .HasColumnType("int"); + + b.Property("ReceivedFromName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ReceivedFromType") + .HasColumnType("int"); + + b.Property("ReferenceId") + .HasColumnType("int"); + + b.Property("ReferenceType") + .HasColumnType("longtext"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChequeNo"); + + b.HasIndex("FK_DepositBankAccountId"); + + b.ToTable("ReceivedCheques"); + }); + + 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("Period") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("TargetValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("Id"); + + b.HasIndex("FK_RegionId", "Period") + .IsUnique(); + + b.ToTable("RegionalTargets"); + + b.HasData( + new + { + Id = new Guid("59000000-0000-0000-0000-000000000001"), + 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", + TargetValue = 500000m + }); + }); + + modelBuilder.Entity("Distribution.Models.RegionalTaxRule", 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("RuleConfig") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("FK_RegionId") + .IsUnique(); + + b.ToTable("RegionalTaxRules"); + + b.HasData( + new + { + Id = new Guid("60000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_RegionId = new Guid("24000000-0000-0000-0000-000000000001"), + IsActive = true, + RuleConfig = "{\"rate\": 0.15}" + }); + }); + + modelBuilder.Entity("Distribution.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + + b.HasData( + new + { + Id = new Guid("10000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Level = 10, + Name = "SalesRep" + }, + new + { + Id = new Guid("10000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Level = 20, + Name = "Supervisor" + }, + new + { + Id = new Guid("10000000-0000-0000-0000-000000000003"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Level = 30, + Name = "AreaManager" + }, + new + { + Id = new Guid("10000000-0000-0000-0000-000000000004"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Level = 40, + Name = "AreaSupervisor" + }, + new + { + Id = new Guid("10000000-0000-0000-0000-000000000005"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Level = 50, + Name = "RegionalManager" + }, + new + { + Id = new Guid("10000000-0000-0000-0000-000000000006"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Level = 60, + Name = "RegionalAgency" + }, + new + { + Id = new Guid("10000000-0000-0000-0000-000000000007"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Level = 100, + Name = "SuperAdmin" + }); + }); + + modelBuilder.Entity("Distribution.Models.RolePermission", b => + { + b.Property("FK_RoleId") + .HasColumnType("char(36)"); + + b.Property("FK_PermissionId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.HasKey("FK_RoleId", "FK_PermissionId"); + + b.HasIndex("FK_PermissionId"); + + b.ToTable("RolePermissions"); + + b.HasData( + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("8c43c584-0f65-496d-a77c-a7df46bb175d"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("25576a9d-38cb-4ff5-b8ca-08df43d8a5a6"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000003"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("e47016c1-a014-476f-ba87-4b3d438de62a"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000004"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("a24c0e9e-0194-4f96-823c-bdbdcd122d85"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000005"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("e76ef6e2-67ba-462f-a954-b1dbc5a95d8c"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000006"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("bba4fdaa-fd0e-43dc-aedf-331212bd06cd"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000007"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("bc66d450-af6b-426e-9d05-266ceba21fac"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000008"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("9ee2196c-1e4b-452d-aaf6-7c55e3d2be2b"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000009"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("63508590-7a30-4640-9fc9-d3d54978f581"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000010"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("82802a3f-23bc-45db-a531-d7e880dd7970"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000011"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("65ccf5b6-754a-431a-81bf-d8e0587c956e"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000012"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("6c713413-362b-475a-846b-9f3382cf7a35"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000013"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("6dfe68ff-f5a3-41a8-981b-ac108a81408e"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000014"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("09c6b812-dc14-44a2-9362-429dfef3942d"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000015"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("bf29a1bb-234e-47a3-922f-f0fb3a1daba0"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000016"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("0d2f3497-4852-453e-a451-275e945b6c1d"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000017"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("41c13dbc-4f51-4134-891c-b6955f728d65"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000018"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("29bc0291-7a91-4fc5-840b-9420b64b86fc"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000019"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("8ae0c386-d206-4580-890f-c1673c1dfeb2"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000020"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("5db4bd09-9481-4608-9dec-3412ba7f3f69"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000021"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("c1840bd7-88fd-496a-8d88-aef3d886e1ec"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000022"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("af97d659-c040-4fdc-beeb-62fc8334f95c"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000023"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("a6443517-3c2a-4407-a3bd-5497e053b0d6"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000024"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("2f540d56-bff4-41fe-9181-4a423c1da51c"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000025"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("db18cfb8-a56c-46bc-baff-298e6204c455"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000026"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("fe209c12-1189-485b-920e-ce6db3c132b9"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000027"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("fedef395-394d-4237-b5aa-8254603ed304"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000028"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("7cc47626-65b8-44b0-83fb-a5dff96c39f6"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000029"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("cf04aea5-3f47-4717-95aa-8dab547f9cfb"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000030"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("c2906d62-9eea-4d08-b904-86a3f8b04a20"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000031"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("7a546bf9-c2f3-4d23-a38e-a068da53dfeb"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000032"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("19c916c3-7b17-42e0-b4b6-89b8cb6475f4"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000033"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("e6805dbe-a931-4e2a-b08f-83e8760d4968"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000034"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("7d991f5c-16db-46c5-863c-93063c2e7382"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000035"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("513c50d0-5d7b-426d-beef-f14bdea626bc"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000036"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("638a6a60-25da-425c-bdec-683431c26d62"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000037"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("b00bfae6-92bb-48cb-99d9-f2814baae47d"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000038"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("6562c9b4-0673-4ce0-8805-03734bc889ce"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000039"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("6601e0fe-83dd-4307-be91-38dae998cc9c"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000040"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("c4848449-9678-4fa6-8a00-db4e504b57d6"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000041"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("91c02c24-12a3-48d5-9d19-174c8e764152"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000042"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("0f00477f-5120-40ba-a0e6-0406e47d1c80"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000043"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("db135a10-6335-478d-b2f8-3b5934cd142b"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000044"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("5c219dd9-9ff3-4541-a708-cc7e4bd4dd25"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000045"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("086e7b93-079d-49d0-90e9-95899b53be52"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000046"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("f0b3d172-cb32-4606-8272-00feaf4067a2"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000047"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("75a882c0-b2e9-4efa-a64c-b5d530d42194"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000048"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("03540f63-d811-4436-869f-2f76995bbb19"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000049"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("73894d9f-a823-4b5b-b809-5cc0aa716a70"), + IsActive = true + }, + new + { + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000050"), + CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("1ad4bfb8-cde6-4623-a21d-9a78af0026d6"), + IsActive = true + }); + }); + + modelBuilder.Entity("Distribution.Models.Route", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EndPoint") + .HasColumnType("longtext"); + + b.Property("FK_OwnerUserId") + .HasColumnType("char(36)"); + + b.Property("FK_RegionId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Length") + .HasColumnType("decimal(65,30)"); + + b.Property("RouteName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartPoint") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("FK_OwnerUserId"); + + b.HasIndex("FK_RegionId"); + + b.ToTable("Routes"); + + b.HasData( + new + { + Id = new Guid("25000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndPoint = "Dehiwala", + FK_OwnerUserId = new Guid("29000000-0000-0000-0000-000000000002"), + FK_RegionId = new Guid("24000000-0000-0000-0000-000000000001"), + IsActive = true, + Length = 18.5m, + RouteName = "Colombo City Route", + StartPoint = "Colombo Fort" + }, + new + { + Id = new Guid("25000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndPoint = "Negombo", + FK_OwnerUserId = new Guid("29000000-0000-0000-0000-000000000002"), + FK_RegionId = new Guid("24000000-0000-0000-0000-000000000001"), + IsActive = true, + Length = 32.0m, + RouteName = "Negombo Coastal Route", + StartPoint = "Wattala" + }, + new + { + Id = new Guid("25000000-0000-0000-0000-000000000003"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndPoint = "Peradeniya", + FK_OwnerUserId = new Guid("29000000-0000-0000-0000-000000000003"), + FK_RegionId = new Guid("24000000-0000-0000-0000-000000000002"), + IsActive = true, + Length = 12.0m, + RouteName = "Kandy Town Route", + StartPoint = "Kandy Lake" + }, + new + { + Id = new Guid("25000000-0000-0000-0000-000000000004"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndPoint = "Matale", + FK_OwnerUserId = new Guid("29000000-0000-0000-0000-000000000003"), + FK_RegionId = new Guid("24000000-0000-0000-0000-000000000002"), + IsActive = true, + Length = 26.0m, + RouteName = "Matale Route", + StartPoint = "Kandy" + }); + }); + + modelBuilder.Entity("Distribution.Models.RouteVisitLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CheckInAt") + .HasColumnType("datetime(6)"); + + b.Property("CheckInLatitude") + .HasColumnType("decimal(65,30)"); + + b.Property("CheckInLongitude") + .HasColumnType("decimal(65,30)"); + + b.Property("CheckOutAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FK_RouteId") + .HasColumnType("char(36)"); + + b.Property("FK_StoreId") + .HasColumnType("char(36)"); + + b.Property("FK_UserId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeviationFlagged") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.HasIndex("FK_RouteId"); + + b.HasIndex("FK_StoreId"); + + b.HasIndex("FK_UserId"); + + b.ToTable("RouteVisitLogs"); + + b.HasData( + new + { + Id = new Guid("66000000-0000-0000-0000-000000000001"), + CheckInAt = new DateTime(2026, 8, 25, 9, 0, 0, 0, DateTimeKind.Unspecified), + CheckInLatitude = 6.9344m, + CheckInLongitude = 79.8428m, + CheckOutAt = new DateTime(2026, 8, 25, 9, 25, 0, 0, DateTimeKind.Unspecified), + CreatedAt = new DateTime(2026, 8, 25, 9, 0, 0, 0, DateTimeKind.Unspecified), + FK_RouteId = new Guid("25000000-0000-0000-0000-000000000001"), + FK_StoreId = new Guid("26000000-0000-0000-0000-000000000001"), + FK_UserId = new Guid("29000000-0000-0000-0000-000000000002"), + IsActive = true, + IsDeviationFlagged = false + }, + new + { + Id = new Guid("66000000-0000-0000-0000-000000000002"), + CheckInAt = new DateTime(2026, 8, 25, 10, 0, 0, 0, DateTimeKind.Unspecified), + CheckInLatitude = 6.9000m, + CheckInLongitude = 79.8654m, + CreatedAt = new DateTime(2026, 8, 25, 10, 0, 0, 0, DateTimeKind.Unspecified), + FK_RouteId = new Guid("25000000-0000-0000-0000-000000000001"), + FK_StoreId = new Guid("26000000-0000-0000-0000-000000000002"), + FK_UserId = new Guid("29000000-0000-0000-0000-000000000002"), + IsActive = true, + IsDeviationFlagged = true + }); + }); + + modelBuilder.Entity("Distribution.Models.SaleReturn", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedByUserId") + .HasColumnType("char(36)"); + + b.Property("FK_ShopPOId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Mode") + .HasColumnType("int"); + + b.Property("TotalCreditAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("FK_ShopPOId"); + + b.ToTable("SaleReturns"); + + b.HasData( + new + { + Id = new Guid("51000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 26, 0, 0, 0, 0, DateTimeKind.Unspecified), + CreatedByUserId = new Guid("29000000-0000-0000-0000-000000000002"), + FK_ShopPOId = new Guid("33000000-0000-0000-0000-000000000001"), + IsActive = true, + Mode = 0, + TotalCreditAmount = 300m + }); + }); + + modelBuilder.Entity("Distribution.Models.SaleReturnItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FK_ItemId") + .HasColumnType("char(36)"); + + b.Property("FK_SaleReturnId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Quantity") + .HasColumnType("decimal(65,30)"); + + b.Property("ReasonCode") + .HasColumnType("int"); + + b.Property("UnitPrice") + .HasColumnType("decimal(65,30)"); + + b.HasKey("Id"); + + b.HasIndex("FK_ItemId"); + + b.HasIndex("FK_SaleReturnId"); + + b.ToTable("SaleReturnItems"); + + b.HasData( + new + { + Id = new Guid("52000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 26, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"), + FK_SaleReturnId = new Guid("51000000-0000-0000-0000-000000000001"), + IsActive = true, + Quantity = 5m, + ReasonCode = 1, + UnitPrice = 60m + }); + }); + + modelBuilder.Entity("Distribution.Models.SaleRoute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("SaleRoutes"); + + b.HasData( + new + { + Id = new Guid("69000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true + }, + new + { + Id = new Guid("69000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true + }); + }); + + modelBuilder.Entity("Distribution.Models.Scheme", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AgentLimitExempt") + .HasColumnType("tinyint(1)"); + + b.Property("BaselineExpectedSales") + .HasColumnType("decimal(65,30)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DateRangeFrom") + .HasColumnType("datetime(6)"); + + b.Property("DateRangeTo") + .HasColumnType("datetime(6)"); + + b.Property("EligibleSegment") + .HasColumnType("longtext"); + + b.Property("FK_FreeItemId") + .HasColumnType("char(36)"); + + b.Property("FK_RegionId") + .HasColumnType("char(36)"); + + b.Property("FK_TriggerItemId") + .HasColumnType("char(36)"); + + b.Property("FreeQty") + .HasColumnType("decimal(65,30)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RegionId") + .HasColumnType("char(36)"); + + b.Property("RuleConfig") + .HasColumnType("longtext"); + + b.Property("RuleType") + .HasColumnType("int"); + + b.Property("TriggerQty") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FK_FreeItemId"); + + b.HasIndex("FK_TriggerItemId"); + + b.HasIndex("RegionId"); + + b.ToTable("Schemes"); + + b.HasData( + new + { + Id = new Guid("48000000-0000-0000-0000-000000000001"), + AgentLimitExempt = false, + BaselineExpectedSales = 500000m, + CreatedAt = new DateTime(2026, 8, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + DateRangeFrom = new DateTime(2026, 8, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + DateRangeTo = new DateTime(2026, 12, 31, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_FreeItemId = new Guid("23000000-0000-0000-0000-000000000001"), + FK_RegionId = new Guid("24000000-0000-0000-0000-000000000001"), + FK_TriggerItemId = new Guid("23000000-0000-0000-0000-000000000001"), + FreeQty = 1m, + IsActive = true, + Name = "Buy 10 Coke Get 1 Free", + RuleType = 0, + TriggerQty = 10 + }, + new + { + Id = new Guid("48000000-0000-0000-0000-000000000002"), + AgentLimitExempt = false, + CreatedAt = new DateTime(2026, 8, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + DateRangeFrom = new DateTime(2026, 8, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + DateRangeTo = new DateTime(2026, 12, 31, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_FreeItemId = new Guid("23000000-0000-0000-0000-000000000004"), + FK_RegionId = new Guid("24000000-0000-0000-0000-000000000002"), + FreeQty = 1m, + IsActive = true, + Name = "Snack Combo Bundle", + RuleType = 3 + }); + }); + + modelBuilder.Entity("Distribution.Models.SchemeBundleComponent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("FK_ItemId") + .HasColumnType("char(36)"); + + b.Property("FK_SchemeId") + .HasColumnType("char(36)"); + + b.Property("Qty") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FK_ItemId"); + + b.HasIndex("FK_SchemeId", "FK_ItemId") + .IsUnique(); + + b.ToTable("SchemeBundleComponents"); + + b.HasData( + new + { + Id = new Guid("49000000-0000-0000-0000-000000000001"), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000003"), + FK_SchemeId = new Guid("48000000-0000-0000-0000-000000000002"), + Qty = 5 + }); + }); + + modelBuilder.Entity("Distribution.Models.SchemeRedemption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DiscountAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("FK_FreeItemId") + .HasColumnType("char(36)"); + + b.Property("FK_SchemeId") + .HasColumnType("char(36)"); + + b.Property("FK_ShopPOId") + .HasColumnType("char(36)"); + + b.Property("FieldInvoiceId") + .HasColumnType("char(36)"); + + b.Property("FreeItemCostValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FreeQty") + .HasColumnType("decimal(65,30)"); + + b.Property("RedeemedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("FK_FreeItemId"); + + b.HasIndex("FK_SchemeId"); + + b.HasIndex("FK_ShopPOId"); + + b.ToTable("SchemeRedemptions"); + + b.HasData( + new + { + Id = new Guid("50000000-0000-0000-0000-000000000001"), + DiscountAmount = 0m, + FK_FreeItemId = new Guid("23000000-0000-0000-0000-000000000001"), + FK_SchemeId = new Guid("48000000-0000-0000-0000-000000000001"), + FK_ShopPOId = new Guid("33000000-0000-0000-0000-000000000001"), + FreeItemCostValue = 40m, + FreeQty = 1m, + RedeemedAt = new DateTime(2026, 8, 25, 9, 30, 0, 0, DateTimeKind.Unspecified) + }); + }); + + modelBuilder.Entity("Distribution.Models.ShopPO", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CancelReason") + .HasColumnType("longtext"); + + b.Property("CancelledAt") + .HasColumnType("datetime(6)"); + + b.Property("CancelledBy") + .HasColumnType("char(36)"); + + b.Property("ConfirmedAt") + .HasColumnType("datetime(6)"); + + b.Property("ConfirmedBy") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FK_StoreId") + .HasColumnType("char(36)"); + + b.Property("FulfilledAt") + .HasColumnType("datetime(6)"); + + b.Property("InvoiceId") + .HasColumnType("char(36)") + .HasColumnName("InvoiceId"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("RaisedById") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("Id"); + + b.HasIndex("FK_StoreId"); + + b.ToTable("ShopPOs"); + + b.HasData( + new + { + Id = new Guid("33000000-0000-0000-0000-000000000001"), + ConfirmedAt = new DateTime(2026, 8, 25, 8, 30, 0, 0, DateTimeKind.Unspecified), + ConfirmedBy = new Guid("29000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 25, 9, 0, 0, 0, DateTimeKind.Unspecified), + FK_StoreId = new Guid("26000000-0000-0000-0000-000000000001"), + FulfilledAt = new DateTime(2026, 8, 25, 13, 0, 0, 0, DateTimeKind.Unspecified), + InvoiceId = new Guid("34500000-0000-0000-0000-000000000001"), + IsActive = true, + RaisedById = new Guid("29000000-0000-0000-0000-000000000002"), + Status = 2, + TotalAmount = 3000m + }, + new + { + Id = new Guid("33000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 30, 10, 0, 0, 0, DateTimeKind.Unspecified), + FK_StoreId = new Guid("26000000-0000-0000-0000-000000000005"), + IsActive = true, + RaisedById = new Guid("29000000-0000-0000-0000-000000000003"), + Status = 0, + TotalAmount = 1200m + }, + new + { + Id = new Guid("33000000-0000-0000-0000-000000000003"), + ConfirmedAt = new DateTime(2026, 8, 31, 8, 30, 0, 0, DateTimeKind.Unspecified), + ConfirmedBy = new Guid("29000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 31, 9, 0, 0, 0, DateTimeKind.Unspecified), + FK_StoreId = new Guid("26000000-0000-0000-0000-000000000005"), + FulfilledAt = new DateTime(2026, 8, 31, 13, 0, 0, 0, DateTimeKind.Unspecified), + InvoiceId = new Guid("34500000-0000-0000-0000-000000000002"), + IsActive = true, + RaisedById = new Guid("29000000-0000-0000-0000-000000000003"), + Status = 2, + TotalAmount = 2400m + }); + }); + + modelBuilder.Entity("Distribution.Models.ShopPOItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FK_ItemId") + .HasColumnType("char(36)"); + + b.Property("FK_ShopPOId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("QuantityFulfilled") + .HasColumnType("int"); + + b.Property("UnitPrice") + .HasColumnType("decimal(65,30)"); + + b.HasKey("Id"); + + b.HasIndex("FK_ItemId"); + + b.HasIndex("FK_ShopPOId"); + + b.ToTable("ShopPOItems"); + + b.HasData( + new + { + Id = new Guid("34000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 25, 9, 0, 0, 0, DateTimeKind.Unspecified), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"), + FK_ShopPOId = new Guid("33000000-0000-0000-0000-000000000001"), + IsActive = true, + Quantity = 30, + QuantityFulfilled = 30, + UnitPrice = 60m + }, + new + { + Id = new Guid("34000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 25, 9, 0, 0, 0, DateTimeKind.Unspecified), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000003"), + FK_ShopPOId = new Guid("33000000-0000-0000-0000-000000000001"), + IsActive = true, + Quantity = 24, + QuantityFulfilled = 24, + UnitPrice = 50m + }, + new + { + Id = new Guid("34000000-0000-0000-0000-000000000003"), + CreatedAt = new DateTime(2026, 8, 30, 10, 0, 0, 0, DateTimeKind.Unspecified), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000002"), + FK_ShopPOId = new Guid("33000000-0000-0000-0000-000000000002"), + IsActive = true, + Quantity = 10, + QuantityFulfilled = 0, + UnitPrice = 120m + }, + new + { + Id = new Guid("34000000-0000-0000-0000-000000000004"), + CreatedAt = new DateTime(2026, 8, 31, 9, 0, 0, 0, DateTimeKind.Unspecified), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000002"), + FK_ShopPOId = new Guid("33000000-0000-0000-0000-000000000003"), + IsActive = true, + Quantity = 20, + QuantityFulfilled = 20, + UnitPrice = 120m + }); + }); + + modelBuilder.Entity("Distribution.Models.StockBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("FK_ItemBatchId") + .HasColumnType("char(36)"); + + b.Property("FK_ItemId") + .HasColumnType("char(36)"); + + b.Property("FK_ItemSerialNumberId") + .HasColumnType("char(36)"); + + b.Property("LocationId") + .HasColumnType("char(36)"); + + b.Property("LocationType") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("decimal(65,30)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("FK_ItemBatchId"); + + b.HasIndex("FK_ItemSerialNumberId"); + + b.HasIndex("FK_ItemId", "LocationId", "FK_ItemBatchId", "FK_ItemSerialNumberId") + .IsUnique(); + + b.ToTable("StockBalances"); + + b.HasData( + new + { + Id = new Guid("61000000-0000-0000-0000-000000000001"), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"), + LocationId = new Guid("27000000-0000-0000-0000-000000000001"), + LocationType = 0, + Quantity = 150m, + UpdatedAt = new DateTime(2026, 8, 25, 9, 30, 0, 0, DateTimeKind.Unspecified) + }, + new + { + Id = new Guid("61000000-0000-0000-0000-000000000002"), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000003"), + LocationId = new Guid("27000000-0000-0000-0000-000000000001"), + LocationType = 0, + Quantity = 90m, + UpdatedAt = new DateTime(2026, 8, 25, 9, 30, 0, 0, DateTimeKind.Unspecified) + }, + new + { + Id = new Guid("61000000-0000-0000-0000-000000000003"), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"), + LocationId = new Guid("28000000-0000-0000-0000-000000000001"), + LocationType = 1, + Quantity = 20m, + UpdatedAt = new DateTime(2026, 8, 25, 9, 30, 0, 0, DateTimeKind.Unspecified) + }); + }); + + modelBuilder.Entity("Distribution.Models.StockMovement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedBy") + .HasColumnType("char(36)"); + + b.Property("FK_ItemBatchId") + .HasColumnType("char(36)"); + + b.Property("FK_ItemId") + .HasColumnType("char(36)"); + + b.Property("FK_ItemSerialNumberId") + .HasColumnType("char(36)"); + + b.Property("FromLocationId") + .HasColumnType("char(36)"); + + b.Property("FromLocationType") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("decimal(65,30)"); + + b.Property("ReasonCode") + .HasColumnType("longtext"); + + b.Property("ReferenceId") + .HasColumnType("char(36)"); + + b.Property("ToLocationId") + .HasColumnType("char(36)"); + + b.Property("ToLocationType") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FK_ItemBatchId"); + + b.HasIndex("FK_ItemId"); + + b.HasIndex("FK_ItemSerialNumberId"); + + b.ToTable("StockMovements"); + + b.HasData( + new + { + Id = new Guid("62000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 15, 0, 0, 0, 0, DateTimeKind.Unspecified), + CreatedBy = new Guid("29000000-0000-0000-0000-000000000001"), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"), + FromLocationId = new Guid("00000000-0000-0000-0000-000000000000"), + FromLocationType = 2, + Quantity = 200m, + ReferenceId = new Guid("43000000-0000-0000-0000-000000000001"), + ToLocationId = new Guid("27000000-0000-0000-0000-000000000001"), + ToLocationType = 0, + Type = 6 + }, + new + { + Id = new Guid("62000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 25, 7, 30, 0, 0, DateTimeKind.Unspecified), + CreatedBy = new Guid("29000000-0000-0000-0000-000000000001"), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"), + FromLocationId = new Guid("27000000-0000-0000-0000-000000000001"), + FromLocationType = 0, + Quantity = 50m, + ReferenceId = new Guid("35000000-0000-0000-0000-000000000001"), + ToLocationId = new Guid("28000000-0000-0000-0000-000000000001"), + ToLocationType = 1, + Type = 5 + }, + new + { + Id = new Guid("62000000-0000-0000-0000-000000000003"), + CreatedAt = new DateTime(2026, 8, 25, 9, 30, 0, 0, DateTimeKind.Unspecified), + CreatedBy = new Guid("29000000-0000-0000-0000-000000000002"), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"), + FromLocationId = new Guid("28000000-0000-0000-0000-000000000001"), + FromLocationType = 1, + Quantity = 30m, + ReferenceId = new Guid("32000000-0000-0000-0000-000000000001"), + ToLocationId = new Guid("00000000-0000-0000-0000-000000000000"), + ToLocationType = 2, + Type = 0 + }); + }); + + modelBuilder.Entity("Distribution.Models.Store", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContactNumber") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreditAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("CreditLimit") + .HasColumnType("decimal(65,30)"); + + b.Property("FK_RouteId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Latitude") + .HasColumnType("decimal(65,30)"); + + b.Property("Longitude") + .HasColumnType("decimal(65,30)"); + + b.Property("OneTimeAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutstandingBalance") + .HasColumnType("decimal(65,30)"); + + b.Property("OwnerName") + .HasColumnType("longtext"); + + b.Property("Segment") + .HasColumnType("longtext"); + + b.Property("StoreAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StoreName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("FK_RouteId"); + + b.ToTable("Stores"); + + b.HasData( + new + { + Id = new Guid("26000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + CreditAmount = 0m, + CreditLimit = 50000m, + FK_RouteId = new Guid("25000000-0000-0000-0000-000000000001"), + IsActive = true, + Latitude = 6.9344m, + Longitude = 79.8428m, + OneTimeAmount = 0m, + OutstandingBalance = 0m, + OwnerName = "Saman Kumara", + Segment = "Gold", + StoreAddress = "12 York Street, Colombo Fort", + StoreName = "Fort Mini Mart" + }, + new + { + Id = new Guid("26000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + CreditAmount = 0m, + CreditLimit = 30000m, + FK_RouteId = new Guid("25000000-0000-0000-0000-000000000001"), + IsActive = true, + Latitude = 6.8508m, + Longitude = 79.8654m, + OneTimeAmount = 0m, + OutstandingBalance = 5000m, + OwnerName = "Nadeesha Silva", + Segment = "Silver", + StoreAddress = "45 Galle Road, Dehiwala", + StoreName = "Dehiwala Grocery" + }, + new + { + Id = new Guid("26000000-0000-0000-0000-000000000003"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + CreditAmount = 0m, + CreditLimit = 40000m, + FK_RouteId = new Guid("25000000-0000-0000-0000-000000000002"), + IsActive = true, + Latitude = 6.9890m, + Longitude = 79.8912m, + OneTimeAmount = 0m, + OutstandingBalance = 1200m, + OwnerName = "Ruwan Gunasekara", + Segment = "Gold", + StoreAddress = "88 Negombo Road, Wattala", + StoreName = "Wattala Supermarket" + }, + new + { + Id = new Guid("26000000-0000-0000-0000-000000000004"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + CreditAmount = 0m, + CreditLimit = 25000m, + FK_RouteId = new Guid("25000000-0000-0000-0000-000000000002"), + IsActive = true, + Latitude = 7.2094m, + Longitude = 79.8380m, + OneTimeAmount = 0m, + OutstandingBalance = 0m, + OwnerName = "Chamari Peiris", + StoreAddress = "5 Beach Road, Negombo", + StoreName = "Negombo Beach Store" + }, + new + { + Id = new Guid("26000000-0000-0000-0000-000000000005"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + CreditAmount = 0m, + CreditLimit = 35000m, + FK_RouteId = new Guid("25000000-0000-0000-0000-000000000003"), + IsActive = true, + Latitude = 7.2906m, + Longitude = 80.6337m, + OneTimeAmount = 0m, + OutstandingBalance = 0m, + OwnerName = "Dinesh Wickramasinghe", + Segment = "Key Account", + StoreAddress = "3 Lake Road, Kandy", + StoreName = "Kandy Lake View Store" + }, + new + { + Id = new Guid("26000000-0000-0000-0000-000000000006"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + CreditAmount = 0m, + CreditLimit = 20000m, + FK_RouteId = new Guid("25000000-0000-0000-0000-000000000004"), + IsActive = true, + Latitude = 7.4675m, + Longitude = 80.6234m, + OneTimeAmount = 0m, + OutstandingBalance = 0m, + OwnerName = "Ishara Bandara", + StoreAddress = "20 Main Street, Matale", + StoreName = "Matale Central Store" + }); + }); + + modelBuilder.Entity("Distribution.Models.SubCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExternalErpId") + .HasColumnType("int"); + + b.Property("FK_CategoryId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("FK_CategoryId"); + + b.ToTable("SubCategories"); + }); + + modelBuilder.Entity("Distribution.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContactInfo") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PerformanceScore") + .HasColumnType("decimal(65,30)"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + + b.HasData( + new + { + Id = new Guid("38000000-0000-0000-0000-000000000001"), + ContactInfo = "+94 11 234 5678", + CreatedAt = new DateTime(2026, 8, 14, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Name = "Ceylon Beverages Ltd", + PerformanceScore = 4.2m + }, + new + { + Id = new Guid("38000000-0000-0000-0000-000000000002"), + ContactInfo = "+94 11 876 5432", + CreatedAt = new DateTime(2026, 8, 14, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Name = "Snack Foods (Pvt) Ltd" + }); + }); + + modelBuilder.Entity("Distribution.Models.SupplierClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Details") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EvidenceUrl") + .HasColumnType("longtext"); + + b.Property("FK_GoodsReceiptId") + .HasColumnType("char(36)"); + + b.Property("FK_PurchaseOrderId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("RaisedByUserId") + .HasColumnType("char(36)"); + + b.Property("ResolutionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("ResolutionNotes") + .HasColumnType("longtext"); + + b.Property("ResolutionType") + .HasColumnType("int"); + + b.Property("ResolvedAt") + .HasColumnType("datetime(6)"); + + b.Property("ResolvedByUserId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FK_GoodsReceiptId"); + + b.HasIndex("FK_PurchaseOrderId"); + + b.HasIndex("RaisedByUserId"); + + b.HasIndex("ResolvedByUserId"); + + b.ToTable("SupplierClaims"); + + b.HasData( + new + { + Id = new Guid("55000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 15, 0, 0, 0, 0, DateTimeKind.Unspecified), + Details = "2 units of Coke 1.5L received damaged", + FK_GoodsReceiptId = new Guid("43000000-0000-0000-0000-000000000001"), + FK_PurchaseOrderId = new Guid("41000000-0000-0000-0000-000000000001"), + IsActive = true, + RaisedByUserId = new Guid("29000000-0000-0000-0000-000000000001"), + ResolutionAmount = 160m, + ResolutionNotes = "Credited against next invoice", + ResolutionType = 1, + ResolvedAt = new DateTime(2026, 8, 16, 0, 0, 0, 0, DateTimeKind.Unspecified), + ResolvedByUserId = new Guid("29000000-0000-0000-0000-000000000006"), + Status = 1 + }); + }); + + modelBuilder.Entity("Distribution.Models.SupplierClaimItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FK_ItemId") + .HasColumnType("char(36)"); + + b.Property("FK_SupplierClaimId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IssueType") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("decimal(65,30)"); + + b.HasKey("Id"); + + b.HasIndex("FK_ItemId"); + + b.HasIndex("FK_SupplierClaimId"); + + b.ToTable("SupplierClaimItems"); + + b.HasData( + new + { + Id = new Guid("56000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 15, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000002"), + FK_SupplierClaimId = new Guid("55000000-0000-0000-0000-000000000001"), + IsActive = true, + IssueType = 0, + Quantity = 2m + }); + }); + + modelBuilder.Entity("Distribution.Models.SysConfig", b => + { + b.Property("Key") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("UpdatedBy") + .HasColumnType("char(36)"); + + b.Property("Value") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Key"); + + b.ToTable("SysConfigs"); + + b.HasData( + new + { + Key = "InvoiceCreationMode", + UpdatedAt = new DateTime(2026, 9, 17, 0, 0, 0, 0, DateTimeKind.Unspecified), + Value = "ModeB" + }, + new + { + Key = "Feature.SerialNumberTracking", + UpdatedAt = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Value = "false" + }, + new + { + Key = "Feature.BatchTracking", + UpdatedAt = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Value = "false" + }, + new + { + Key = "Feature.ExpiryDateTracking", + UpdatedAt = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Value = "false" + }, + new + { + Key = "Feature.WarrantyTracking", + UpdatedAt = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Value = "false" + }, + new + { + Key = "Feature.CustomWarrantyOverride", + UpdatedAt = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Value = "false" + }, + new + { + Key = "Feature.DefaultWarrantyPeriodDays", + UpdatedAt = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Value = "0" + }); + }); + + modelBuilder.Entity("Distribution.Models.Uom", 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("Uoms"); + + b.HasData( + new + { + Id = new Guid("22000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Name = "Piece" + }, + new + { + Id = new Guid("67000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Name = "Case" + }); + }); + + modelBuilder.Entity("Distribution.Models.UomConversion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("FK_FromUomId") + .HasColumnType("char(36)"); + + b.Property("FK_ItemId") + .HasColumnType("char(36)"); + + b.Property("FK_ToUomId") + .HasColumnType("char(36)"); + + b.Property("Factor") + .HasColumnType("decimal(65,30)"); + + b.HasKey("Id"); + + b.HasIndex("FK_FromUomId"); + + b.HasIndex("FK_ItemId"); + + b.HasIndex("FK_ToUomId"); + + b.ToTable("UomConversions"); + + b.HasData( + new + { + Id = new Guid("67000000-0000-0000-0000-000000000002"), + FK_FromUomId = new Guid("67000000-0000-0000-0000-000000000001"), + FK_ItemId = new Guid("23000000-0000-0000-0000-000000000001"), + FK_ToUomId = new Guid("22000000-0000-0000-0000-000000000001"), + Factor = 24m + }); + }); + + modelBuilder.Entity("Distribution.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FK_ReportsToUserId") + .HasColumnType("char(36)"); + + b.Property("FK_RoleId") + .HasColumnType("char(36)"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Username") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("FK_ReportsToUserId"); + + b.HasIndex("FK_RoleId"); + + b.ToTable("Users"); + + b.HasData( + new + { + Id = new Guid("29000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000002"), + FullName = "Sunil Fernando", + IsActive = true, + Username = "sunil.fernando" + }, + new + { + Id = new Guid("29000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_ReportsToUserId = new Guid("29000000-0000-0000-0000-000000000001"), + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000001"), + FullName = "Nimal Perera", + IsActive = true, + Username = "nimal.perera" + }, + new + { + Id = new Guid("29000000-0000-0000-0000-000000000003"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_ReportsToUserId = new Guid("29000000-0000-0000-0000-000000000001"), + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000001"), + FullName = "Kamal Silva", + IsActive = true, + Username = "kamal.silva" + }, + new + { + Id = new Guid("29000000-0000-0000-0000-000000000004"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_ReportsToUserId = new Guid("29000000-0000-0000-0000-000000000001"), + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000001"), + FullName = "Ruwan Jayasuriya", + IsActive = true, + Username = "ruwan.jayasuriya" + }, + new + { + Id = new Guid("29000000-0000-0000-0000-000000000005"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_ReportsToUserId = new Guid("29000000-0000-0000-0000-000000000001"), + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000001"), + FullName = "Priyantha Kumara", + IsActive = true, + Username = "priyantha.kumara" + }, + new + { + Id = new Guid("29000000-0000-0000-0000-000000000006"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000005"), + FullName = "Priya Rajapaksa", + IsActive = true, + Username = "priya.rajapaksa" + }, + new + { + Id = new Guid("70000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000006"), + FullName = "Channa De Silva", + IsActive = true, + Username = "channa.desilva" + }, + new + { + Id = new Guid("00000001-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 10, 13, 0, 0, 0, 0, DateTimeKind.Unspecified), + FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), + FullName = "Super Admin", + IsActive = true, + Username = "superadmin" + }); + }); + + modelBuilder.Entity("Distribution.Models.UserRegionScope", b => + { + b.Property("FK_UserId") + .HasColumnType("char(36)"); + + b.Property("FK_RegionId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.HasKey("FK_UserId", "FK_RegionId"); + + b.HasIndex("FK_RegionId"); + + b.ToTable("UserRegionScopes"); + + b.HasData( + new + { + FK_UserId = new Guid("29000000-0000-0000-0000-000000000006"), + FK_RegionId = new Guid("24000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("68000000-0000-0000-0000-000000000001"), + IsActive = true + }); + }); + + modelBuilder.Entity("Distribution.Models.UserRouteScope", b => + { + b.Property("FK_UserId") + .HasColumnType("char(36)"); + + b.Property("FK_RouteId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.HasKey("FK_UserId", "FK_RouteId"); + + b.HasIndex("FK_RouteId"); + + b.ToTable("UserRouteScopes"); + + b.HasData( + new + { + FK_UserId = new Guid("29000000-0000-0000-0000-000000000001"), + FK_RouteId = new Guid("25000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("68000000-0000-0000-0000-000000000002"), + IsActive = true + }); + }); + + modelBuilder.Entity("Distribution.Models.UserStoreScope", b => + { + b.Property("FK_UserId") + .HasColumnType("char(36)"); + + b.Property("FK_StoreId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Id") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.HasKey("FK_UserId", "FK_StoreId"); + + b.HasIndex("FK_StoreId"); + + b.ToTable("UserStoreScopes"); + + b.HasData( + new + { + FK_UserId = new Guid("29000000-0000-0000-0000-000000000003"), + FK_StoreId = new Guid("26000000-0000-0000-0000-000000000005"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + Id = new Guid("68000000-0000-0000-0000-000000000003"), + IsActive = true + }); + }); + + modelBuilder.Entity("Distribution.Models.Vehicle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DefaultWarehouseId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("NumberPlate") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RegNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DefaultWarehouseId"); + + b.ToTable("Vehicles"); + + b.HasData( + new + { + Id = new Guid("28000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + DefaultWarehouseId = new Guid("27000000-0000-0000-0000-000000000001"), + IsActive = true, + NumberPlate = "CAB-1234", + RegNumber = "WP-CAB-1234", + Type = 2 + }, + new + { + Id = new Guid("28000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + DefaultWarehouseId = new Guid("27000000-0000-0000-0000-000000000002"), + IsActive = true, + NumberPlate = "KY-5678", + RegNumber = "CP-KY-5678", + Type = 1 + }); + }); + + modelBuilder.Entity("Distribution.Models.Warehouse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Location") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("VehicleId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("VehicleId"); + + b.ToTable("Warehouses"); + + b.HasData( + new + { + Id = new Guid("27000000-0000-0000-0000-000000000001"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Location = "Peliyagoda, Colombo", + Name = "Colombo Distribution Center", + Type = 0 + }, + new + { + Id = new Guid("27000000-0000-0000-0000-000000000002"), + CreatedAt = new DateTime(2026, 8, 20, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsActive = true, + Location = "Katugastota, Kandy", + Name = "Kandy Fulfillment Center", + Type = 1 + }); + }); + + modelBuilder.Entity("Distribution.Models.ChequeBook", b => + { + b.HasOne("Distribution.Models.BankAccount", "BankAccount") + .WithMany() + .HasForeignKey("FK_BankAccountId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("BankAccount"); + }); + + modelBuilder.Entity("Distribution.Models.ChequePage", b => + { + b.HasOne("Distribution.Models.ChequeBook", "ChequeBook") + .WithMany("Pages") + .HasForeignKey("FK_ChequeBookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChequeBook"); + }); + + modelBuilder.Entity("Distribution.Models.Claim", b => + { + b.HasOne("Distribution.Models.User", "AgencyUser") + .WithMany() + .HasForeignKey("FK_AgencyUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.User", "SettledByUser") + .WithMany() + .HasForeignKey("SettledByUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("AgencyUser"); + + b.Navigation("SettledByUser"); + }); + + modelBuilder.Entity("Distribution.Models.CreditNote", b => + { + b.HasOne("Distribution.Models.SaleReturn", "SaleReturn") + .WithMany() + .HasForeignKey("FK_SaleReturnId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("SaleReturn"); + }); + + modelBuilder.Entity("Distribution.Models.DeliveryRun", b => + { + b.HasOne("Distribution.Models.DriverProfile", "DriverProfile") + .WithMany() + .HasForeignKey("FK_DriverProfileId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.Vehicle", "Vehicle") + .WithMany() + .HasForeignKey("FK_VehicleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DriverProfile"); + + b.Navigation("Vehicle"); + }); + + modelBuilder.Entity("Distribution.Models.DeliveryTask", b => + { + b.HasOne("Distribution.Models.DeliveryRun", "Ride") + .WithMany() + .HasForeignKey("FK_RideId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.ShopPO", "ShopPO") + .WithMany() + .HasForeignKey("FK_ShopPOId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Ride"); + + b.Navigation("ShopPO"); + }); + + modelBuilder.Entity("Distribution.Models.DriverProfile", b => + { + b.HasOne("Distribution.Models.User", "User") + .WithMany() + .HasForeignKey("FK_UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Distribution.Models.GoodsReceipt", b => + { + b.HasOne("Distribution.Models.PurchaseOrder", "PurchaseOrder") + .WithMany() + .HasForeignKey("FK_PurchaseOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Distribution.Models.Supplier", "Supplier") + .WithMany() + .HasForeignKey("FK_SupplierId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Distribution.Models.Warehouse", "Warehouse") + .WithMany() + .HasForeignKey("FK_WarehouseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("PurchaseOrder"); + + b.Navigation("Supplier"); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("Distribution.Models.GoodsReceiptItem", b => + { + b.HasOne("Distribution.Models.GoodsReceipt", "GoodsReceipt") + .WithMany("Items") + .HasForeignKey("FK_GoodsReceiptId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Distribution.Models.PurchaseOrderItem", "PurchaseOrderItem") + .WithMany() + .HasForeignKey("FK_PurchaseOrderItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("GoodsReceipt"); + + b.Navigation("Item"); + + b.Navigation("PurchaseOrderItem"); + }); + + modelBuilder.Entity("Distribution.Models.GoodsReceiptItemBatch", b => + { + b.HasOne("Distribution.Models.GoodsReceiptItem", "GoodsReceiptItem") + .WithMany("Batches") + .HasForeignKey("FK_GoodsReceiptItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.ItemBatch", "ItemBatch") + .WithMany() + .HasForeignKey("FK_ItemBatchId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("GoodsReceiptItem"); + + b.Navigation("ItemBatch"); + }); + + modelBuilder.Entity("Distribution.Models.GoodsReceiptItemSerial", b => + { + b.HasOne("Distribution.Models.GoodsReceiptItem", "GoodsReceiptItem") + .WithMany("Serials") + .HasForeignKey("FK_GoodsReceiptItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.ItemSerialNumber", "ItemSerialNumber") + .WithMany() + .HasForeignKey("FK_ItemSerialNumberId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("GoodsReceiptItem"); + + b.Navigation("ItemSerialNumber"); + }); + + modelBuilder.Entity("Distribution.Models.Invoice", b => + { + b.HasOne("Distribution.Models.ShopPO", "ShopPO") + .WithMany() + .HasForeignKey("FK_ShopPOId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ShopPO"); + }); + + modelBuilder.Entity("Distribution.Models.Item", b => + { + b.HasOne("Distribution.Models.Uom", "BaseUom") + .WithMany() + .HasForeignKey("FK_BaseUomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.Brand", "Brand") + .WithMany() + .HasForeignKey("FK_BrandId"); + + b.HasOne("Distribution.Models.Category", "Category") + .WithMany() + .HasForeignKey("FK_CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.SubCategory", "SubCategory") + .WithMany() + .HasForeignKey("FK_SubCategoryId"); + + b.Navigation("BaseUom"); + + b.Navigation("Brand"); + + b.Navigation("Category"); + + b.Navigation("SubCategory"); + }); + + modelBuilder.Entity("Distribution.Models.ItemBatch", b => + { + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Item"); + }); + + modelBuilder.Entity("Distribution.Models.ItemSerialNumber", b => + { + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Item"); + }); + + modelBuilder.Entity("Distribution.Models.LoadingSheet", b => + { + b.HasOne("Distribution.Models.DeliveryRun", "Ride") + .WithMany() + .HasForeignKey("FK_RideId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Ride"); + }); + + modelBuilder.Entity("Distribution.Models.LoadingSheetItem", b => + { + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.LoadingSheet", "LoadingSheet") + .WithMany("Items") + .HasForeignKey("FK_LoadingSheetId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.ShopPOItem", "ShopPOItem") + .WithMany() + .HasForeignKey("FK_ShopPOItemId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Distribution.Models.Warehouse", "Warehouse") + .WithMany() + .HasForeignKey("FK_WarehouseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Item"); + + b.Navigation("LoadingSheet"); + + b.Navigation("ShopPOItem"); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("Distribution.Models.LoadingSheetOrder", b => + { + b.HasOne("Distribution.Models.LoadingSheet", "LoadingSheet") + .WithMany("Orders") + .HasForeignKey("FK_LoadingSheetId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.ShopPO", "ShopPO") + .WithMany() + .HasForeignKey("FK_ShopPOId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("LoadingSheet"); + + b.Navigation("ShopPO"); + }); + + modelBuilder.Entity("Distribution.Models.Payment", b => + { + b.HasOne("Distribution.Models.Invoice", "Invoice") + .WithMany("Payments") + .HasForeignKey("FK_InvoiceId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Invoice"); + }); + + modelBuilder.Entity("Distribution.Models.PriceList", b => + { + b.HasOne("Distribution.Models.Region", "Region") + .WithMany() + .HasForeignKey("FK_RegionId"); + + b.Navigation("Region"); + }); + + modelBuilder.Entity("Distribution.Models.PriceListItem", b => + { + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.PriceList", "PriceList") + .WithMany("Items") + .HasForeignKey("FK_PriceListId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Item"); + + b.Navigation("PriceList"); + }); + + modelBuilder.Entity("Distribution.Models.PurchaseOrder", b => + { + b.HasOne("Distribution.Models.Supplier", "Supplier") + .WithMany() + .HasForeignKey("FK_SupplierId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Supplier"); + }); + + modelBuilder.Entity("Distribution.Models.PurchaseOrderItem", b => + { + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.PurchaseOrder", "PurchaseOrder") + .WithMany("Items") + .HasForeignKey("FK_PurchaseOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Item"); + + b.Navigation("PurchaseOrder"); + }); + + modelBuilder.Entity("Distribution.Models.PurchaseReturn", b => + { + b.HasOne("Distribution.Models.PurchaseOrder", "PurchaseOrder") + .WithMany() + .HasForeignKey("FK_PurchaseOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("PurchaseOrder"); + }); + + modelBuilder.Entity("Distribution.Models.PurchaseReturnItem", b => + { + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.PurchaseReturn", "PurchaseReturn") + .WithMany("Items") + .HasForeignKey("FK_PurchaseReturnId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Item"); + + b.Navigation("PurchaseReturn"); + }); + + modelBuilder.Entity("Distribution.Models.ReceivedCheque", b => + { + b.HasOne("Distribution.Models.BankAccount", "DepositBankAccount") + .WithMany() + .HasForeignKey("FK_DepositBankAccountId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DepositBankAccount"); + }); + + modelBuilder.Entity("Distribution.Models.RegionAgencyMap", b => + { + b.HasOne("Distribution.Models.User", "AgencyUser") + .WithMany() + .HasForeignKey("FK_AgencyUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.Region", "Region") + .WithMany() + .HasForeignKey("FK_RegionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AgencyUser"); + + b.Navigation("Region"); + }); + + modelBuilder.Entity("Distribution.Models.RegionalBudget", b => + { + b.HasOne("Distribution.Models.Region", "Region") + .WithMany() + .HasForeignKey("FK_RegionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Region"); + }); + + modelBuilder.Entity("Distribution.Models.RegionalTarget", b => + { + b.HasOne("Distribution.Models.Region", "Region") + .WithMany() + .HasForeignKey("FK_RegionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Region"); + }); + + modelBuilder.Entity("Distribution.Models.RegionalTaxRule", b => + { + b.HasOne("Distribution.Models.Region", "Region") + .WithMany() + .HasForeignKey("FK_RegionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Region"); + }); + + modelBuilder.Entity("Distribution.Models.RolePermission", b => + { + b.HasOne("Distribution.Models.Permission", "Permission") + .WithMany() + .HasForeignKey("FK_PermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.Role", "Role") + .WithMany() + .HasForeignKey("FK_RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Permission"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Distribution.Models.Route", b => + { + b.HasOne("Distribution.Models.User", "OwnerUser") + .WithMany() + .HasForeignKey("FK_OwnerUserId"); + + b.HasOne("Distribution.Models.Region", "Region") + .WithMany() + .HasForeignKey("FK_RegionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OwnerUser"); + + b.Navigation("Region"); + }); + + modelBuilder.Entity("Distribution.Models.RouteVisitLog", b => + { + b.HasOne("Distribution.Models.Route", "Route") + .WithMany() + .HasForeignKey("FK_RouteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.Store", "Store") + .WithMany() + .HasForeignKey("FK_StoreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.User", "User") + .WithMany() + .HasForeignKey("FK_UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Route"); + + b.Navigation("Store"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Distribution.Models.SaleReturn", b => + { + b.HasOne("Distribution.Models.User", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.ShopPO", "ShopPO") + .WithMany() + .HasForeignKey("FK_ShopPOId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedByUser"); + + b.Navigation("ShopPO"); + }); + + modelBuilder.Entity("Distribution.Models.SaleReturnItem", b => + { + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.SaleReturn", "SaleReturn") + .WithMany("Items") + .HasForeignKey("FK_SaleReturnId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Item"); + + b.Navigation("SaleReturn"); + }); + + modelBuilder.Entity("Distribution.Models.Scheme", b => + { + b.HasOne("Distribution.Models.Item", "FreeItem") + .WithMany() + .HasForeignKey("FK_FreeItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Distribution.Models.Item", "TriggerItem") + .WithMany() + .HasForeignKey("FK_TriggerItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Distribution.Models.Region", "Region") + .WithMany() + .HasForeignKey("RegionId"); + + b.Navigation("FreeItem"); + + b.Navigation("Region"); + + b.Navigation("TriggerItem"); + }); + + modelBuilder.Entity("Distribution.Models.SchemeBundleComponent", b => + { + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.Scheme", "Scheme") + .WithMany("BundleComponents") + .HasForeignKey("FK_SchemeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Item"); + + b.Navigation("Scheme"); + }); + + modelBuilder.Entity("Distribution.Models.SchemeRedemption", b => + { + b.HasOne("Distribution.Models.Item", "FreeItem") + .WithMany() + .HasForeignKey("FK_FreeItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Distribution.Models.Scheme", "Scheme") + .WithMany("Redemptions") + .HasForeignKey("FK_SchemeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.ShopPO", "ShopPO") + .WithMany() + .HasForeignKey("FK_ShopPOId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("FreeItem"); + + b.Navigation("Scheme"); + + b.Navigation("ShopPO"); + }); + + modelBuilder.Entity("Distribution.Models.ShopPO", b => + { + b.HasOne("Distribution.Models.Store", "Store") + .WithMany() + .HasForeignKey("FK_StoreId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Store"); + }); + + modelBuilder.Entity("Distribution.Models.ShopPOItem", b => + { + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.ShopPO", "ShopPO") + .WithMany("Items") + .HasForeignKey("FK_ShopPOId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Item"); + + b.Navigation("ShopPO"); + }); + + modelBuilder.Entity("Distribution.Models.StockBalance", b => + { + b.HasOne("Distribution.Models.ItemBatch", "ItemBatch") + .WithMany() + .HasForeignKey("FK_ItemBatchId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.ItemSerialNumber", "ItemSerialNumber") + .WithMany() + .HasForeignKey("FK_ItemSerialNumberId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Item"); + + b.Navigation("ItemBatch"); + + b.Navigation("ItemSerialNumber"); + }); + + modelBuilder.Entity("Distribution.Models.StockMovement", b => + { + b.HasOne("Distribution.Models.ItemBatch", "ItemBatch") + .WithMany() + .HasForeignKey("FK_ItemBatchId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.ItemSerialNumber", "ItemSerialNumber") + .WithMany() + .HasForeignKey("FK_ItemSerialNumberId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Item"); + + b.Navigation("ItemBatch"); + + b.Navigation("ItemSerialNumber"); + }); + + modelBuilder.Entity("Distribution.Models.Store", b => + { + b.HasOne("Distribution.Models.Route", "Route") + .WithMany() + .HasForeignKey("FK_RouteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Route"); + }); + + modelBuilder.Entity("Distribution.Models.SubCategory", b => + { + b.HasOne("Distribution.Models.Category", "Category") + .WithMany() + .HasForeignKey("FK_CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("Distribution.Models.SupplierClaim", b => + { + b.HasOne("Distribution.Models.GoodsReceipt", "GoodsReceipt") + .WithMany() + .HasForeignKey("FK_GoodsReceiptId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Distribution.Models.PurchaseOrder", "PurchaseOrder") + .WithMany() + .HasForeignKey("FK_PurchaseOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.User", "RaisedByUser") + .WithMany() + .HasForeignKey("RaisedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.User", "ResolvedByUser") + .WithMany() + .HasForeignKey("ResolvedByUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("GoodsReceipt"); + + b.Navigation("PurchaseOrder"); + + b.Navigation("RaisedByUser"); + + b.Navigation("ResolvedByUser"); + }); + + modelBuilder.Entity("Distribution.Models.SupplierClaimItem", b => + { + b.HasOne("Distribution.Models.Item", "Item") + .WithMany() + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Distribution.Models.SupplierClaim", "SupplierClaim") + .WithMany("Items") + .HasForeignKey("FK_SupplierClaimId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Item"); + + b.Navigation("SupplierClaim"); + }); + + modelBuilder.Entity("Distribution.Models.UomConversion", b => + { + b.HasOne("Distribution.Models.Uom", "FromUom") + .WithMany() + .HasForeignKey("FK_FromUomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.Item", "Item") + .WithMany("Conversions") + .HasForeignKey("FK_ItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.Uom", "ToUom") + .WithMany() + .HasForeignKey("FK_ToUomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FromUom"); + + b.Navigation("Item"); + + b.Navigation("ToUom"); + }); + + modelBuilder.Entity("Distribution.Models.User", b => + { + b.HasOne("Distribution.Models.User", "ReportsTo") + .WithMany() + .HasForeignKey("FK_ReportsToUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Distribution.Models.Role", "Role") + .WithMany() + .HasForeignKey("FK_RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ReportsTo"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Distribution.Models.UserRegionScope", b => + { + b.HasOne("Distribution.Models.Region", "Region") + .WithMany() + .HasForeignKey("FK_RegionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.User", "User") + .WithMany() + .HasForeignKey("FK_UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Region"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Distribution.Models.UserRouteScope", b => + { + b.HasOne("Distribution.Models.Route", "Route") + .WithMany() + .HasForeignKey("FK_RouteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.User", "User") + .WithMany() + .HasForeignKey("FK_UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Route"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Distribution.Models.UserStoreScope", b => + { + b.HasOne("Distribution.Models.Store", "Store") + .WithMany() + .HasForeignKey("FK_StoreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Distribution.Models.User", "User") + .WithMany() + .HasForeignKey("FK_UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Store"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Distribution.Models.Vehicle", b => + { + b.HasOne("Distribution.Models.Warehouse", null) + .WithMany() + .HasForeignKey("DefaultWarehouseId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Distribution.Models.Warehouse", b => + { + b.HasOne("Distribution.Models.Vehicle", "Vehicle") + .WithMany() + .HasForeignKey("VehicleId"); + + b.Navigation("Vehicle"); + }); + + modelBuilder.Entity("Distribution.Models.ChequeBook", b => + { + b.Navigation("Pages"); + }); + + modelBuilder.Entity("Distribution.Models.GoodsReceipt", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("Distribution.Models.GoodsReceiptItem", b => + { + b.Navigation("Batches"); + + b.Navigation("Serials"); + }); + + modelBuilder.Entity("Distribution.Models.Invoice", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Distribution.Models.Item", b => + { + b.Navigation("Conversions"); + }); + + modelBuilder.Entity("Distribution.Models.LoadingSheet", b => + { + b.Navigation("Items"); + + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Distribution.Models.PriceList", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("Distribution.Models.PurchaseOrder", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("Distribution.Models.PurchaseReturn", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("Distribution.Models.SaleReturn", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("Distribution.Models.Scheme", b => + { + b.Navigation("BundleComponents"); + + b.Navigation("Redemptions"); + }); + + modelBuilder.Entity("Distribution.Models.ShopPO", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("Distribution.Models.SupplierClaim", b => + { + b.Navigation("Items"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Distribution/Migrations/20261019092950_AddPaymentServiceModule.cs b/Distribution/Migrations/20261019092950_AddPaymentServiceModule.cs new file mode 100644 index 0000000..f69f024 --- /dev/null +++ b/Distribution/Migrations/20261019092950_AddPaymentServiceModule.cs @@ -0,0 +1,926 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Distribution.Migrations +{ + /// + public partial class AddPaymentServiceModule : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "BankAccounts", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + AccountType = table.Column(type: "int", nullable: false), + AccountName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + BankName = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CashAccountTypeName = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AccountNumber = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CurrencyCode = table.Column(type: "varchar(10)", maxLength: 10, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsDefault = table.Column(type: "tinyint(1)", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + IsActive = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BankAccounts", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ChequeBooks", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ChequeBookNo = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + BranchId = table.Column(type: "int", nullable: false), + FK_BankAccountId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + StartChequeNo = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + EndChequeNo = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TotalLeaves = table.Column(type: "int", nullable: false), + ReceivedDate = table.Column(type: "datetime(6)", nullable: false), + Description = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedBy = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Status = table.Column(type: "int", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + IsActive = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChequeBooks", x => x.Id); + table.ForeignKey( + name: "FK_ChequeBooks_BankAccounts_FK_BankAccountId", + column: x => x.FK_BankAccountId, + principalTable: "BankAccounts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ReceivedCheques", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CompanyId = table.Column(type: "int", nullable: false), + BranchId = table.Column(type: "int", nullable: true), + ReceivedFromType = table.Column(type: "int", nullable: false), + ReceivedFromId = table.Column(type: "int", nullable: true), + ReceivedFromName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DrawerBankName = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DrawerBankBranch = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AccountHolderName = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ChequeNo = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ChequeDate = table.Column(type: "datetime(6)", nullable: false), + Amount = table.Column(type: "decimal(65,30)", nullable: false), + ReceivedDate = table.Column(type: "datetime(6)", nullable: false), + ReferenceType = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ReferenceId = table.Column(type: "int", nullable: true), + Notes = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedBy = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Status = table.Column(type: "int", nullable: false), + FK_DepositBankAccountId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DepositDate = table.Column(type: "datetime(6)", nullable: true), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + IsActive = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ReceivedCheques", x => x.Id); + table.ForeignKey( + name: "FK_ReceivedCheques_BankAccounts_FK_DepositBankAccountId", + column: x => x.FK_DepositBankAccountId, + principalTable: "BankAccounts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ChequePages", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ChequeNo = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + FK_ChequeBookId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + IssueStatus = table.Column(type: "int", nullable: false), + PayeeType = table.Column(type: "int", nullable: true), + PayeeId = table.Column(type: "int", nullable: true), + PayeeName = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IssueDate = table.Column(type: "datetime(6)", nullable: true), + Amount = table.Column(type: "decimal(65,30)", nullable: true), + CurrencyCode = table.Column(type: "varchar(10)", maxLength: 10, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + VoucherId = table.Column(type: "int", nullable: true), + ReferenceNo = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Purpose = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IsCrossCheque = table.Column(type: "tinyint(1)", nullable: true), + IsAccountPayee = table.Column(type: "tinyint(1)", nullable: true), + IsPostDated = table.Column(type: "tinyint(1)", nullable: true), + Notes = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PrintedBy = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PrintedAt = table.Column(type: "datetime(6)", nullable: true), + ClearedDate = table.Column(type: "datetime(6)", nullable: true), + ClearedByBank = table.Column(type: "tinyint(1)", nullable: true), + CancelReason = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + IsActive = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChequePages", x => x.Id); + table.ForeignKey( + name: "FK_ChequePages_ChequeBooks_FK_ChequeBookId", + column: x => x.FK_ChequeBookId, + principalTable: "ChequeBooks", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("8c43c584-0f65-496d-a77c-a7df46bb175d")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("25576a9d-38cb-4ff5-b8ca-08df43d8a5a6")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("e47016c1-a014-476f-ba87-4b3d438de62a")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("a24c0e9e-0194-4f96-823c-bdbdcd122d85")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("e76ef6e2-67ba-462f-a954-b1dbc5a95d8c")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("bba4fdaa-fd0e-43dc-aedf-331212bd06cd")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("bc66d450-af6b-426e-9d05-266ceba21fac")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("9ee2196c-1e4b-452d-aaf6-7c55e3d2be2b")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("63508590-7a30-4640-9fc9-d3d54978f581")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("82802a3f-23bc-45db-a531-d7e880dd7970")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("65ccf5b6-754a-431a-81bf-d8e0587c956e")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("6c713413-362b-475a-846b-9f3382cf7a35")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("6dfe68ff-f5a3-41a8-981b-ac108a81408e")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("09c6b812-dc14-44a2-9362-429dfef3942d")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("bf29a1bb-234e-47a3-922f-f0fb3a1daba0")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("0d2f3497-4852-453e-a451-275e945b6c1d")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("41c13dbc-4f51-4134-891c-b6955f728d65")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("29bc0291-7a91-4fc5-840b-9420b64b86fc")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("8ae0c386-d206-4580-890f-c1673c1dfeb2")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000020"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("5db4bd09-9481-4608-9dec-3412ba7f3f69")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000021"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("c1840bd7-88fd-496a-8d88-aef3d886e1ec")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000022"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("af97d659-c040-4fdc-beeb-62fc8334f95c")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000023"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("a6443517-3c2a-4407-a3bd-5497e053b0d6")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000024"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("2f540d56-bff4-41fe-9181-4a423c1da51c")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000025"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("db18cfb8-a56c-46bc-baff-298e6204c455")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000026"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("fe209c12-1189-485b-920e-ce6db3c132b9")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000027"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("fedef395-394d-4237-b5aa-8254603ed304")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000028"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("7cc47626-65b8-44b0-83fb-a5dff96c39f6")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000029"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("cf04aea5-3f47-4717-95aa-8dab547f9cfb")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000030"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("c2906d62-9eea-4d08-b904-86a3f8b04a20")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000031"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("7a546bf9-c2f3-4d23-a38e-a068da53dfeb")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000032"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("19c916c3-7b17-42e0-b4b6-89b8cb6475f4")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000033"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("e6805dbe-a931-4e2a-b08f-83e8760d4968")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000034"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("7d991f5c-16db-46c5-863c-93063c2e7382")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000035"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("513c50d0-5d7b-426d-beef-f14bdea626bc")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000036"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("638a6a60-25da-425c-bdec-683431c26d62")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000037"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("b00bfae6-92bb-48cb-99d9-f2814baae47d")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000038"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("6562c9b4-0673-4ce0-8805-03734bc889ce")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000039"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("6601e0fe-83dd-4307-be91-38dae998cc9c")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000040"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("c4848449-9678-4fa6-8a00-db4e504b57d6")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000041"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("91c02c24-12a3-48d5-9d19-174c8e764152")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000042"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("0f00477f-5120-40ba-a0e6-0406e47d1c80")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000043"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("db135a10-6335-478d-b2f8-3b5934cd142b")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000044"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("5c219dd9-9ff3-4541-a708-cc7e4bd4dd25")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000045"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("086e7b93-079d-49d0-90e9-95899b53be52")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000046"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("f0b3d172-cb32-4606-8272-00feaf4067a2")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000047"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("75a882c0-b2e9-4efa-a64c-b5d530d42194")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000048"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("03540f63-d811-4436-869f-2f76995bbb19")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000049"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("73894d9f-a823-4b5b-b809-5cc0aa716a70")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000050"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("1ad4bfb8-cde6-4623-a21d-9a78af0026d6")); + + migrationBuilder.CreateIndex( + name: "IX_BankAccounts_AccountType_AccountName", + table: "BankAccounts", + columns: new[] { "AccountType", "AccountName" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ChequeBooks_ChequeBookNo", + table: "ChequeBooks", + column: "ChequeBookNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ChequeBooks_FK_BankAccountId", + table: "ChequeBooks", + column: "FK_BankAccountId"); + + migrationBuilder.CreateIndex( + name: "IX_ChequePages_ChequeNo", + table: "ChequePages", + column: "ChequeNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ChequePages_FK_ChequeBookId", + table: "ChequePages", + column: "FK_ChequeBookId"); + + migrationBuilder.CreateIndex( + name: "IX_ReceivedCheques_ChequeNo", + table: "ReceivedCheques", + column: "ChequeNo"); + + migrationBuilder.CreateIndex( + name: "IX_ReceivedCheques_FK_DepositBankAccountId", + table: "ReceivedCheques", + column: "FK_DepositBankAccountId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ChequePages"); + + migrationBuilder.DropTable( + name: "ReceivedCheques"); + + migrationBuilder.DropTable( + name: "ChequeBooks"); + + migrationBuilder.DropTable( + name: "BankAccounts"); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("db785a23-5337-4fc8-b460-80c30b707d79")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("b07b73f9-2c8b-4dff-af5c-42622b026321")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("2e867ba5-2739-4ce4-b8d7-25b14ed392c1")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("203d855d-f2d0-43d0-9d4f-9c4d0e8e7566")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("edd2a0ee-1ca9-47ff-9df6-7254929aef80")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("644b5ee5-f2c5-4187-a3d4-322cdd5c95d7")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("70fdf921-f3fd-4e66-bfd2-cb7bb156fa34")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("e2de5341-4146-4c84-a584-8788774c14df")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("ece07436-4a0b-435c-888b-a22c14612dc4")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("b72f8737-7a21-48c0-809a-bc0d3fdd7063")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("fe1efed0-271f-45e3-a58b-244f1115246f")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("1b58e809-e4a0-4108-af6e-fd0dac7b3163")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("881e8e67-e2ee-47be-94f7-77da73a05365")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("e5d0baa8-9def-4b81-8727-5886b2906eaf")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("a46ec771-5e79-4595-bb40-91e8a954a792")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("ef8b1808-3b14-43a8-ba75-30551e643cc5")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("50142904-8d40-424b-aeb3-53e8cb110445")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("4bd67f53-7f84-492c-83f9-fd6488fa88b7")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("d9a0eb59-600e-47e9-8e07-8b7bffc93f8b")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000020"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("e5a9d4da-9497-4e7e-8fb9-796927cbb510")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000021"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("ffa29833-505e-4f56-9a4d-58f5df844af2")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000022"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("4e54994b-7ce1-4b99-aa98-de00c1d205fa")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000023"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("f45b7352-f42a-4bb3-9d1e-d7cbe2665c0c")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000024"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("27744965-334b-4da2-8a2d-5d7433d11b9d")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000025"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("cec1991b-ea93-45b0-b380-01cf0d36fc17")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000026"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("25675bb4-2ab5-437c-bee8-1b1ec1741736")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000027"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("5fc66d40-1960-4028-af48-cf51a80bff04")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000028"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("bd4e1740-a8b6-4a53-8633-a68c9858b3f5")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000029"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("9de97081-77d7-43c3-90b9-af3bc9d4bbef")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000030"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("6ae05e16-95e5-4d43-bfa0-56991393d76f")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000031"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("eb096aea-92c9-4556-ba4f-3084da223c7d")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000032"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("6c9dac72-200a-46eb-b49e-699b1ca775b5")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000033"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("8c8d0c74-40f6-4164-a6a7-6d2374ef162a")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000034"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("4a0d8cea-c33d-45a6-bd42-d8a51ce321c8")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000035"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("a0ea0280-8e40-45bc-88e4-c3feb92e36d4")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000036"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("61da4c55-4f19-4ce4-bfc9-3fa9073365a2")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000037"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("fbab8f2e-f224-42a0-be16-b7ea4e24eec5")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000038"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("bcf7f883-e6c8-4a97-8a27-6814b0ed9144")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000039"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("13c01d81-198b-45cb-9de9-f25130e16313")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000040"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("667c3022-ea0d-4d1c-8ae4-b64e2f104295")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000041"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("78607299-2f5c-4edb-9143-c4a83395f731")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000042"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("e53313fd-c6d4-4d52-827f-14cfd55401eb")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000043"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("c2521113-60f4-41fa-8ded-6b6a6b91a584")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000044"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("14532efd-d9f9-4a46-a7c3-fbfbe85a6f13")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000045"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("438bbd52-ee61-4afc-9d59-7d0407da4f1d")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000046"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("3e3d0cd9-f95e-4c1c-b829-cd02f1bad987")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000047"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("84daf87e-d3e1-4f4e-9a57-ec9996fff41d")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000048"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("ddcb8caf-106e-4072-b48e-a2542de51211")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000049"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("95d39d28-c5c7-4e82-87eb-40570db1c1f5")); + + migrationBuilder.UpdateData( + table: "RolePermissions", + keyColumns: new[] { "FK_PermissionId", "FK_RoleId" }, + keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000050"), new Guid("10000000-0000-0000-0000-000000000007") }, + column: "Id", + value: new Guid("b8e7b327-33c9-4420-b4d1-0071c58a5c95")); + } + } +} diff --git a/Distribution/Migrations/AppDBContextModelSnapshot.cs b/Distribution/Migrations/AppDBContextModelSnapshot.cs index 2cd1e5e..658e3dc 100644 --- a/Distribution/Migrations/AppDBContextModelSnapshot.cs +++ b/Distribution/Migrations/AppDBContextModelSnapshot.cs @@ -22,6 +22,54 @@ namespace Distribution.Migrations MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + modelBuilder.Entity("Distribution.Models.BankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccountName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("AccountNumber") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("AccountType") + .HasColumnType("int"); + + b.Property("BankName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("CashAccountTypeName") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrencyCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.HasIndex("AccountType", "AccountName") + .IsUnique(); + + b.ToTable("BankAccounts"); + }); + modelBuilder.Entity("Distribution.Models.Brand", b => { b.Property("Id") @@ -107,6 +155,152 @@ namespace Distribution.Migrations }); }); + modelBuilder.Entity("Distribution.Models.ChequeBook", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BranchId") + .HasColumnType("int"); + + b.Property("ChequeBookNo") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedBy") + .HasColumnType("longtext"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("EndChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("FK_BankAccountId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("ReceivedDate") + .HasColumnType("datetime(6)"); + + b.Property("StartChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalLeaves") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChequeBookNo") + .IsUnique(); + + b.HasIndex("FK_BankAccountId"); + + b.ToTable("ChequeBooks"); + }); + + modelBuilder.Entity("Distribution.Models.ChequePage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CancelReason") + .HasColumnType("longtext"); + + b.Property("ChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ClearedByBank") + .HasColumnType("tinyint(1)"); + + b.Property("ClearedDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrencyCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("FK_ChequeBookId") + .HasColumnType("char(36)"); + + b.Property("IsAccountPayee") + .HasColumnType("tinyint(1)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsCrossCheque") + .HasColumnType("tinyint(1)"); + + b.Property("IsPostDated") + .HasColumnType("tinyint(1)"); + + b.Property("IssueDate") + .HasColumnType("datetime(6)"); + + b.Property("IssueStatus") + .HasColumnType("int"); + + b.Property("Notes") + .HasColumnType("longtext"); + + b.Property("PayeeId") + .HasColumnType("int"); + + b.Property("PayeeName") + .HasColumnType("longtext"); + + b.Property("PayeeType") + .HasColumnType("int"); + + b.Property("PrintedAt") + .HasColumnType("datetime(6)"); + + b.Property("PrintedBy") + .HasColumnType("longtext"); + + b.Property("Purpose") + .HasColumnType("longtext"); + + b.Property("ReferenceNo") + .HasColumnType("longtext"); + + b.Property("VoucherId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChequeNo") + .IsUnique(); + + b.HasIndex("FK_ChequeBookId"); + + b.ToTable("ChequePages"); + }); + modelBuilder.Entity("Distribution.Models.Claim", b => { b.Property("Id") @@ -1914,6 +2108,88 @@ namespace Distribution.Migrations }); }); + modelBuilder.Entity("Distribution.Models.ReceivedCheque", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccountHolderName") + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("BranchId") + .HasColumnType("int"); + + b.Property("ChequeDate") + .HasColumnType("datetime(6)"); + + b.Property("ChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedBy") + .HasColumnType("longtext"); + + b.Property("DepositDate") + .HasColumnType("datetime(6)"); + + b.Property("DrawerBankBranch") + .HasColumnType("longtext"); + + b.Property("DrawerBankName") + .HasColumnType("longtext"); + + b.Property("FK_DepositBankAccountId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Notes") + .HasColumnType("longtext"); + + b.Property("ReceivedDate") + .HasColumnType("datetime(6)"); + + b.Property("ReceivedFromId") + .HasColumnType("int"); + + b.Property("ReceivedFromName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ReceivedFromType") + .HasColumnType("int"); + + b.Property("ReferenceId") + .HasColumnType("int"); + + b.Property("ReferenceType") + .HasColumnType("longtext"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChequeNo"); + + b.HasIndex("FK_DepositBankAccountId"); + + b.ToTable("ReceivedCheques"); + }); + modelBuilder.Entity("Distribution.Models.Region", b => { b.Property("Id") @@ -2229,7 +2505,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000001"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("db785a23-5337-4fc8-b460-80c30b707d79"), + Id = new Guid("8c43c584-0f65-496d-a77c-a7df46bb175d"), IsActive = true }, new @@ -2237,7 +2513,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000002"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("b07b73f9-2c8b-4dff-af5c-42622b026321"), + Id = new Guid("25576a9d-38cb-4ff5-b8ca-08df43d8a5a6"), IsActive = true }, new @@ -2245,7 +2521,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000003"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("2e867ba5-2739-4ce4-b8d7-25b14ed392c1"), + Id = new Guid("e47016c1-a014-476f-ba87-4b3d438de62a"), IsActive = true }, new @@ -2253,7 +2529,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000004"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("203d855d-f2d0-43d0-9d4f-9c4d0e8e7566"), + Id = new Guid("a24c0e9e-0194-4f96-823c-bdbdcd122d85"), IsActive = true }, new @@ -2261,7 +2537,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000005"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("edd2a0ee-1ca9-47ff-9df6-7254929aef80"), + Id = new Guid("e76ef6e2-67ba-462f-a954-b1dbc5a95d8c"), IsActive = true }, new @@ -2269,7 +2545,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000006"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("644b5ee5-f2c5-4187-a3d4-322cdd5c95d7"), + Id = new Guid("bba4fdaa-fd0e-43dc-aedf-331212bd06cd"), IsActive = true }, new @@ -2277,7 +2553,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000007"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("70fdf921-f3fd-4e66-bfd2-cb7bb156fa34"), + Id = new Guid("bc66d450-af6b-426e-9d05-266ceba21fac"), IsActive = true }, new @@ -2285,7 +2561,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000008"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("e2de5341-4146-4c84-a584-8788774c14df"), + Id = new Guid("9ee2196c-1e4b-452d-aaf6-7c55e3d2be2b"), IsActive = true }, new @@ -2293,7 +2569,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000009"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("ece07436-4a0b-435c-888b-a22c14612dc4"), + Id = new Guid("63508590-7a30-4640-9fc9-d3d54978f581"), IsActive = true }, new @@ -2301,7 +2577,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000010"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("b72f8737-7a21-48c0-809a-bc0d3fdd7063"), + Id = new Guid("82802a3f-23bc-45db-a531-d7e880dd7970"), IsActive = true }, new @@ -2309,7 +2585,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000011"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("fe1efed0-271f-45e3-a58b-244f1115246f"), + Id = new Guid("65ccf5b6-754a-431a-81bf-d8e0587c956e"), IsActive = true }, new @@ -2317,7 +2593,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000012"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("1b58e809-e4a0-4108-af6e-fd0dac7b3163"), + Id = new Guid("6c713413-362b-475a-846b-9f3382cf7a35"), IsActive = true }, new @@ -2325,7 +2601,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000013"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("881e8e67-e2ee-47be-94f7-77da73a05365"), + Id = new Guid("6dfe68ff-f5a3-41a8-981b-ac108a81408e"), IsActive = true }, new @@ -2333,7 +2609,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000014"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("e5d0baa8-9def-4b81-8727-5886b2906eaf"), + Id = new Guid("09c6b812-dc14-44a2-9362-429dfef3942d"), IsActive = true }, new @@ -2341,7 +2617,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000015"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("a46ec771-5e79-4595-bb40-91e8a954a792"), + Id = new Guid("bf29a1bb-234e-47a3-922f-f0fb3a1daba0"), IsActive = true }, new @@ -2349,7 +2625,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000016"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("ef8b1808-3b14-43a8-ba75-30551e643cc5"), + Id = new Guid("0d2f3497-4852-453e-a451-275e945b6c1d"), IsActive = true }, new @@ -2357,7 +2633,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000017"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("50142904-8d40-424b-aeb3-53e8cb110445"), + Id = new Guid("41c13dbc-4f51-4134-891c-b6955f728d65"), IsActive = true }, new @@ -2365,7 +2641,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000018"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("4bd67f53-7f84-492c-83f9-fd6488fa88b7"), + Id = new Guid("29bc0291-7a91-4fc5-840b-9420b64b86fc"), IsActive = true }, new @@ -2373,7 +2649,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000019"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("d9a0eb59-600e-47e9-8e07-8b7bffc93f8b"), + Id = new Guid("8ae0c386-d206-4580-890f-c1673c1dfeb2"), IsActive = true }, new @@ -2381,7 +2657,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000020"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("e5a9d4da-9497-4e7e-8fb9-796927cbb510"), + Id = new Guid("5db4bd09-9481-4608-9dec-3412ba7f3f69"), IsActive = true }, new @@ -2389,7 +2665,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000021"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("ffa29833-505e-4f56-9a4d-58f5df844af2"), + Id = new Guid("c1840bd7-88fd-496a-8d88-aef3d886e1ec"), IsActive = true }, new @@ -2397,7 +2673,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000022"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("4e54994b-7ce1-4b99-aa98-de00c1d205fa"), + Id = new Guid("af97d659-c040-4fdc-beeb-62fc8334f95c"), IsActive = true }, new @@ -2405,7 +2681,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000023"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("f45b7352-f42a-4bb3-9d1e-d7cbe2665c0c"), + Id = new Guid("a6443517-3c2a-4407-a3bd-5497e053b0d6"), IsActive = true }, new @@ -2413,7 +2689,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000024"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("27744965-334b-4da2-8a2d-5d7433d11b9d"), + Id = new Guid("2f540d56-bff4-41fe-9181-4a423c1da51c"), IsActive = true }, new @@ -2421,7 +2697,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000025"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("cec1991b-ea93-45b0-b380-01cf0d36fc17"), + Id = new Guid("db18cfb8-a56c-46bc-baff-298e6204c455"), IsActive = true }, new @@ -2429,7 +2705,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000026"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("25675bb4-2ab5-437c-bee8-1b1ec1741736"), + Id = new Guid("fe209c12-1189-485b-920e-ce6db3c132b9"), IsActive = true }, new @@ -2437,7 +2713,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000027"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("5fc66d40-1960-4028-af48-cf51a80bff04"), + Id = new Guid("fedef395-394d-4237-b5aa-8254603ed304"), IsActive = true }, new @@ -2445,7 +2721,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000028"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("bd4e1740-a8b6-4a53-8633-a68c9858b3f5"), + Id = new Guid("7cc47626-65b8-44b0-83fb-a5dff96c39f6"), IsActive = true }, new @@ -2453,7 +2729,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000029"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("9de97081-77d7-43c3-90b9-af3bc9d4bbef"), + Id = new Guid("cf04aea5-3f47-4717-95aa-8dab547f9cfb"), IsActive = true }, new @@ -2461,7 +2737,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000030"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("6ae05e16-95e5-4d43-bfa0-56991393d76f"), + Id = new Guid("c2906d62-9eea-4d08-b904-86a3f8b04a20"), IsActive = true }, new @@ -2469,7 +2745,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000031"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("eb096aea-92c9-4556-ba4f-3084da223c7d"), + Id = new Guid("7a546bf9-c2f3-4d23-a38e-a068da53dfeb"), IsActive = true }, new @@ -2477,7 +2753,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000032"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("6c9dac72-200a-46eb-b49e-699b1ca775b5"), + Id = new Guid("19c916c3-7b17-42e0-b4b6-89b8cb6475f4"), IsActive = true }, new @@ -2485,7 +2761,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000033"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("8c8d0c74-40f6-4164-a6a7-6d2374ef162a"), + Id = new Guid("e6805dbe-a931-4e2a-b08f-83e8760d4968"), IsActive = true }, new @@ -2493,7 +2769,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000034"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("4a0d8cea-c33d-45a6-bd42-d8a51ce321c8"), + Id = new Guid("7d991f5c-16db-46c5-863c-93063c2e7382"), IsActive = true }, new @@ -2501,7 +2777,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000035"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("a0ea0280-8e40-45bc-88e4-c3feb92e36d4"), + Id = new Guid("513c50d0-5d7b-426d-beef-f14bdea626bc"), IsActive = true }, new @@ -2509,7 +2785,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000036"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("61da4c55-4f19-4ce4-bfc9-3fa9073365a2"), + Id = new Guid("638a6a60-25da-425c-bdec-683431c26d62"), IsActive = true }, new @@ -2517,7 +2793,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000037"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("fbab8f2e-f224-42a0-be16-b7ea4e24eec5"), + Id = new Guid("b00bfae6-92bb-48cb-99d9-f2814baae47d"), IsActive = true }, new @@ -2525,7 +2801,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000038"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("bcf7f883-e6c8-4a97-8a27-6814b0ed9144"), + Id = new Guid("6562c9b4-0673-4ce0-8805-03734bc889ce"), IsActive = true }, new @@ -2533,7 +2809,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000039"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("13c01d81-198b-45cb-9de9-f25130e16313"), + Id = new Guid("6601e0fe-83dd-4307-be91-38dae998cc9c"), IsActive = true }, new @@ -2541,7 +2817,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000040"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("667c3022-ea0d-4d1c-8ae4-b64e2f104295"), + Id = new Guid("c4848449-9678-4fa6-8a00-db4e504b57d6"), IsActive = true }, new @@ -2549,7 +2825,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000041"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("78607299-2f5c-4edb-9143-c4a83395f731"), + Id = new Guid("91c02c24-12a3-48d5-9d19-174c8e764152"), IsActive = true }, new @@ -2557,7 +2833,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000042"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("e53313fd-c6d4-4d52-827f-14cfd55401eb"), + Id = new Guid("0f00477f-5120-40ba-a0e6-0406e47d1c80"), IsActive = true }, new @@ -2565,7 +2841,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000043"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("c2521113-60f4-41fa-8ded-6b6a6b91a584"), + Id = new Guid("db135a10-6335-478d-b2f8-3b5934cd142b"), IsActive = true }, new @@ -2573,7 +2849,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000044"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("14532efd-d9f9-4a46-a7c3-fbfbe85a6f13"), + Id = new Guid("5c219dd9-9ff3-4541-a708-cc7e4bd4dd25"), IsActive = true }, new @@ -2581,7 +2857,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000045"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("438bbd52-ee61-4afc-9d59-7d0407da4f1d"), + Id = new Guid("086e7b93-079d-49d0-90e9-95899b53be52"), IsActive = true }, new @@ -2589,7 +2865,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000046"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("3e3d0cd9-f95e-4c1c-b829-cd02f1bad987"), + Id = new Guid("f0b3d172-cb32-4606-8272-00feaf4067a2"), IsActive = true }, new @@ -2597,7 +2873,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000047"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("84daf87e-d3e1-4f4e-9a57-ec9996fff41d"), + Id = new Guid("75a882c0-b2e9-4efa-a64c-b5d530d42194"), IsActive = true }, new @@ -2605,7 +2881,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000048"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("ddcb8caf-106e-4072-b48e-a2542de51211"), + Id = new Guid("03540f63-d811-4436-869f-2f76995bbb19"), IsActive = true }, new @@ -2613,7 +2889,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000049"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("95d39d28-c5c7-4e82-87eb-40570db1c1f5"), + Id = new Guid("73894d9f-a823-4b5b-b809-5cc0aa716a70"), IsActive = true }, new @@ -2621,7 +2897,7 @@ namespace Distribution.Migrations FK_RoleId = new Guid("10000000-0000-0000-0000-000000000007"), FK_PermissionId = new Guid("20000000-0000-0000-0000-000000000050"), CreatedAt = new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = new Guid("b8e7b327-33c9-4420-b4d1-0071c58a5c95"), + Id = new Guid("1ad4bfb8-cde6-4623-a21d-9a78af0026d6"), IsActive = true }); }); @@ -4273,6 +4549,28 @@ namespace Distribution.Migrations }); }); + modelBuilder.Entity("Distribution.Models.ChequeBook", b => + { + b.HasOne("Distribution.Models.BankAccount", "BankAccount") + .WithMany() + .HasForeignKey("FK_BankAccountId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("BankAccount"); + }); + + modelBuilder.Entity("Distribution.Models.ChequePage", b => + { + b.HasOne("Distribution.Models.ChequeBook", "ChequeBook") + .WithMany("Pages") + .HasForeignKey("FK_ChequeBookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChequeBook"); + }); + modelBuilder.Entity("Distribution.Models.Claim", b => { b.HasOne("Distribution.Models.User", "AgencyUser") @@ -4666,6 +4964,16 @@ namespace Distribution.Migrations b.Navigation("PurchaseReturn"); }); + modelBuilder.Entity("Distribution.Models.ReceivedCheque", b => + { + b.HasOne("Distribution.Models.BankAccount", "DepositBankAccount") + .WithMany() + .HasForeignKey("FK_DepositBankAccountId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DepositBankAccount"); + }); + modelBuilder.Entity("Distribution.Models.RegionAgencyMap", b => { b.HasOne("Distribution.Models.User", "AgencyUser") @@ -5159,6 +5467,11 @@ namespace Distribution.Migrations b.Navigation("Vehicle"); }); + modelBuilder.Entity("Distribution.Models.ChequeBook", b => + { + b.Navigation("Pages"); + }); + modelBuilder.Entity("Distribution.Models.GoodsReceipt", b => { b.Navigation("Items"); diff --git a/Distribution/Models/BankAccount.cs b/Distribution/Models/BankAccount.cs new file mode 100644 index 0000000..da0e4ee --- /dev/null +++ b/Distribution/Models/BankAccount.cs @@ -0,0 +1,17 @@ +namespace Distribution.Models +{ + public class BankAccount : Template + { + public BankAccountType AccountType { get; set; } + public string AccountName { get; set; } = string.Empty; + + public string? BankName { get; set; } + + public string? CashAccountTypeName { get; set; } + + public string? AccountNumber { get; set; } + public string CurrencyCode { get; set; } = "LKR"; + + public bool IsDefault { get; set; } + } +} diff --git a/Distribution/Models/ChequeBook.cs b/Distribution/Models/ChequeBook.cs new file mode 100644 index 0000000..ef611eb --- /dev/null +++ b/Distribution/Models/ChequeBook.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace Distribution.Models +{ + public class ChequeBook : Template + { + public string ChequeBookNo { get; set; } = string.Empty; + + public int BranchId { get; set; } + + public Guid FK_BankAccountId { get; set; } + [ForeignKey("FK_BankAccountId")] + public BankAccount? BankAccount { get; set; } + + public string StartChequeNo { get; set; } = string.Empty; + public string EndChequeNo { get; set; } = string.Empty; + public int TotalLeaves { get; set; } + public DateTime ReceivedDate { get; set; } + public string? Description { get; set; } + public string? CreatedBy { get; set; } + + public ChequeBookStatus Status { get; set; } = ChequeBookStatus.Active; + + public List Pages { get; set; } = new(); + } +} diff --git a/Distribution/Models/ChequePage.cs b/Distribution/Models/ChequePage.cs new file mode 100644 index 0000000..d567726 --- /dev/null +++ b/Distribution/Models/ChequePage.cs @@ -0,0 +1,38 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace Distribution.Models +{ + public class ChequePage : Template + { + public string ChequeNo { get; set; } = string.Empty; + + public Guid FK_ChequeBookId { get; set; } + [ForeignKey("FK_ChequeBookId")] + public ChequeBook? ChequeBook { get; set; } + + public ChequePageIssueStatus IssueStatus { get; set; } = ChequePageIssueStatus.Unused; + + public PayeeType? PayeeType { get; set; } + public int? PayeeId { get; set; } + public string? PayeeName { get; set; } + + public DateTime? IssueDate { get; set; } + public decimal? Amount { get; set; } + public string? CurrencyCode { get; set; } + + public int? VoucherId { get; set; } + public string? ReferenceNo { get; set; } + public string? Purpose { get; set; } + + public bool? IsCrossCheque { get; set; } + public bool? IsAccountPayee { get; set; } + public bool? IsPostDated { get; set; } + public string? Notes { get; set; } + + public string? PrintedBy { get; set; } + public DateTime? PrintedAt { get; set; } + public DateTime? ClearedDate { get; set; } + public bool? ClearedByBank { get; set; } + public string? CancelReason { get; set; } + } +} diff --git a/Distribution/Models/Enums.cs b/Distribution/Models/Enums.cs index f74a70b..77053f5 100644 --- a/Distribution/Models/Enums.cs +++ b/Distribution/Models/Enums.cs @@ -49,4 +49,20 @@ namespace Distribution.Models public enum TaxMode { Disabled, Optional, Mandatory } public enum SerialStatus { InStock, Sold, Returned, Damaged } + + public enum BankAccountType { Cash, Bank } + + public enum ChequeBookStatus { Active, Completed, Cancelled } + + public enum ChequePageIssueStatus { Unused, Issued, Cleared, Bounced, Cancelled, Void } + + public enum ChequePageStatusAction { Clear, Bounce, Cancel, Void } + + public enum PayeeType { Supplier, Customer, Employee, Other } + + public enum ReceivedChequeStatus { Received, Deposited, Cleared, Returned, Cancelled } + + public enum ReceivedChequeStatusAction { Deposit, Clear, Return, Cancel } + + public enum ReceivedFromType { Customer, Supplier, Other } } diff --git a/Distribution/Models/ReceivedCheque.cs b/Distribution/Models/ReceivedCheque.cs new file mode 100644 index 0000000..1bff4ad --- /dev/null +++ b/Distribution/Models/ReceivedCheque.cs @@ -0,0 +1,36 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace Distribution.Models +{ + public class ReceivedCheque : Template + { + public int CompanyId { get; set; } + public int? BranchId { get; set; } + + public ReceivedFromType ReceivedFromType { get; set; } + public int? ReceivedFromId { get; set; } + public string ReceivedFromName { get; set; } = string.Empty; + + public string? DrawerBankName { get; set; } + public string? DrawerBankBranch { get; set; } + public string? AccountHolderName { get; set; } + + public string ChequeNo { get; set; } = string.Empty; + public DateTime ChequeDate { get; set; } + public decimal Amount { get; set; } + public DateTime ReceivedDate { get; set; } + + public string? ReferenceType { get; set; } + public int? ReferenceId { get; set; } + public string? Notes { get; set; } + public string? CreatedBy { get; set; } + + public ReceivedChequeStatus Status { get; set; } = ReceivedChequeStatus.Received; + + public Guid? FK_DepositBankAccountId { get; set; } + [ForeignKey("FK_DepositBankAccountId")] + public BankAccount? DepositBankAccount { get; set; } + + public DateTime? DepositDate { get; set; } + } +} diff --git a/Distribution/Program.cs b/Distribution/Program.cs index e59efe5..b975c43 100644 --- a/Distribution/Program.cs +++ b/Distribution/Program.cs @@ -6,6 +6,9 @@ using Distribution.Features.Brand; using Distribution.Features.Category; using Distribution.Features.DeliveryRide; using Distribution.Features.Payment; +using Distribution.Features.BankAccount; +using Distribution.Features.ChequeBook; +using Distribution.Features.ReceivedCheque; using Distribution.Features.DriverComplianceConfig; using Distribution.Features.DriverProfile; using Distribution.Features.Grn; @@ -89,6 +92,9 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -124,6 +130,9 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddMemoryCache(); diff --git a/accounts-module-migration-plan.md b/accounts-module-migration-plan.md new file mode 100644 index 0000000..1c893c3 --- /dev/null +++ b/accounts-module-migration-plan.md @@ -0,0 +1,185 @@ +# Plan: Clone Accounts Module from ERP-core to Distribution + +## Context +The ERP-core system has a fully implemented Accounts module (7 features) visible in the sidebar. The goal is to replicate all 7 features — with identical UI and independent backend — in the Distribution project (`ERP_Distribution`). Distribution will get its own C# controllers, services, EF entities, and migrations rather than sharing ERP-core's backend. + +## Scope: All 7 Features +1. Cash / Bank Accounts (via GL service proxy) +2. Cheque Books (via GL service proxy) +3. Received Cheques (via GL service proxy) +4. Expenses (own ERP-core controllers) +5. Expense Setup (own ERP-core controllers) +6. Bank Deposits (own ERP-core controllers) +7. Opening Balances (own ERP-core controllers) + +> **Important note:** Features 1–3 go through a separate General Ledger (GL) microservice proxied at `/api/v1/gl/*` in ERP-core. The Distribution backend must also proxy to this same GL service, OR the GL service must be updated to support the distribution context. Confirm with the team whether the GL service is shared infrastructure or ERP-specific before implementing features 1–3. + +--- + +## Source Files (ERP-core) + +### Frontend — `Frontend/erp-system/` +| Type | Path | +|------|------| +| Sidebar nav | `components/Layouts/AppSidebar.tsx` (lines 209–222) | +| Pages | `app/dashboard/accounts/**` (7 feature directories) | +| Shared components | `components/accounts/*.tsx` (8 files) | +| API clients | `lib/api/expenses.ts`, `bank-deposits.ts`, `general-ledger.ts`, `opening-balances.ts` | +| Types | `types/expenses.ts`, `bank-deposits.ts`, `general-ledger.ts`, `opening-balances.ts` | +| Route guard | `lib/nav-routes.ts` | + +### Backend — `Backend/ERPCore/` +| Type | Path | +|------|------| +| Controllers | `Controllers/ExpensesController.cs`, `ExpenseSetupController.cs`, `BankDepositsController.cs`, `OpeningBalancesController.cs`, `GlAccountConfigController.cs` | +| Services | `Services/ExpenseService.cs`, `ExpensePaymentService.cs`, `ExpenseSetupService.cs`, `BankDepositService.cs`, `CashInHandService.cs`, `OpeningBalanceService.cs`, `GlAccountConfigService.cs` | +| Entities | `Domain/Entities/Expense.cs`, `ExpenseCategory.cs`, `BankDeposit.cs`, `GlAccountConfig.cs`, `OpeningBalanceRun.cs` | +| DTOs | `Dtos/Expenses/ExpenseDtos.cs`, `Dtos/Accounts/BankDepositDtos.cs`, `Dtos/OpeningBalances/` | +| Migrations | `Migrations/20261007*`, `20261008*`, `20261018*` | + +--- + +## Target: Distribution Project — `C:\Users\lenovo\Desktop\NEWGITEA\ERP_Distribution` + +--- + +## Implementation Phases + +### Phase 1 — Explore Distribution Project Structure (Read-only prerequisite) +Before coding, read these files to confirm conventions: +- `ERP_Distribution/Distribution/Program.cs` — DI registration pattern +- `ERP_Distribution/Distribution/Controllers/` (any existing controller) — naming convention +- `ERP_Distribution/distribution_fe/components/Layouts/` — sidebar/nav structure +- `ERP_Distribution/distribution_fe/lib/api.ts` — API client pattern (may differ from ERP-core's per-feature files) +- `ERP_Distribution/distribution_fe/app/dashboard/` — existing route structure + +### Phase 2 — Backend: Domain Entities & DTOs +In `ERP_Distribution/Distribution/`: + +1. **Create entity files** (copy + namespace-adjust from ERP-core): + - `Domain/Entities/Expense.cs` + - `Domain/Entities/ExpenseCategory.cs` + - `Domain/Entities/BankDeposit.cs` + - `Domain/Entities/GlAccountConfig.cs` + - `Domain/Entities/OpeningBalanceRun.cs` + - Status enums: `ExpenseStatus.cs`, `BankDepositStatus.cs` + +2. **Create DTO files**: + - `Dtos/Expenses/ExpenseDtos.cs` + - `Dtos/Accounts/BankDepositDtos.cs` + - `Dtos/OpeningBalances/OpeningBalanceDtos.cs` + - `Dtos/GlAccountConfig/GlAccountConfigDtos.cs` + +3. **Register entities in DbContext** — add `DbSet<>` entries to the existing EF DbContext + +4. **Create EF migration** — `add-migration AddAccountsModule` in Distribution project + +### Phase 3 — Backend: Services & Controllers +In `ERP_Distribution/Distribution/`: + +1. **Create service interfaces and implementations** (copy + namespace-adjust): + - `Services/IExpenseServices.cs` + `ExpenseService.cs` + - `Services/IExpenseServices.cs` + `ExpensePaymentService.cs` + - `Services/ExpenseSetupService.cs` + - `Services/IBankDepositServices.cs` + `BankDepositService.cs` + - `Services/CashInHandService.cs` + - `Services/IOpeningBalanceService.cs` + `OpeningBalanceService.cs` + - `Services/IGlAccountConfigService.cs` + `GlAccountConfigService.cs` + +2. **Create controllers** (copy + namespace-adjust, update route prefix if needed): + - `Controllers/ExpensesController.cs` + - `Controllers/ExpenseSetupController.cs` + - `Controllers/BankDepositsController.cs` + - `Controllers/OpeningBalancesController.cs` + - `Controllers/GlAccountConfigController.cs` + - **GL Proxy controller** — a new controller that proxies `/api/v1/gl/*` to the shared GL microservice (same pattern as ERP-core) + +3. **Register services in DI** — add to `Program.cs`: + ```csharp + builder.Services.AddScoped(); + builder.Services.AddScoped(); + // ... etc. + ``` + +4. **Add permissions/policies** — mirror `NavPolicies` from ERP-core for accounts permission codes + +### Phase 4 — Frontend: Types & API Clients +In `ERP_Distribution/distribution_fe/`: + +1. **Copy type files** to `types/`: + - `types/expenses.ts` + - `types/bank-deposits.ts` + - `types/general-ledger.ts` + - `types/opening-balances.ts` + +2. **Copy API client files** to `lib/api/` (update base URL to distribution backend): + - `lib/api/expenses.ts` + - `lib/api/bank-deposits.ts` + - `lib/api/general-ledger.ts` + - `lib/api/opening-balances.ts` + - Adjust any `NEXT_PUBLIC_API_URL` references to point to Distribution backend + +### Phase 5 — Frontend: Components & Pages +In `ERP_Distribution/distribution_fe/`: + +1. **Copy shared account components** to `components/accounts/`: + - `OpeningCashBankPanel.tsx` + - `OpeningStockPanel.tsx` + - `ExpenseForm.tsx` + - `ExpensePaymentDialog.tsx` + - `ChequePageDialog.tsx` + - `ReceivedChequeDialog.tsx` + - `expense-badges.tsx` + - `bank-deposit-badges.tsx` + +2. **Create page directory structure** under `app/dashboard/accounts/`: + ``` + accounts/ + ├── page.tsx (hub page) + ├── bank-accounts/page.tsx + ├── bank-accounts/new/page.tsx + ├── cheque-books/page.tsx + ├── cheque-books/new/page.tsx + ├── cheque-books/[chequeBookNo]/page.tsx + ├── received-cheques/page.tsx + ├── received-cheques/new/page.tsx + ├── expenses/page.tsx + ├── expenses/new/page.tsx + ├── expenses/[id]/page.tsx + ├── expense-setup/page.tsx + ├── bank-deposits/page.tsx + ├── bank-deposits/new/page.tsx + ├── bank-deposits/[id]/page.tsx + └── opening-balances/page.tsx + ``` + +3. Copy each page from ERP-core's equivalent path, adjusting import paths as needed + +### Phase 6 — Frontend: Sidebar Navigation & Route Guard +1. **Add Accounts menu** to Distribution's sidebar/nav config (mirror ERP-core `AppSidebar.tsx` lines 209–222) +2. **Update route guard** — add accounts permission codes to `nav-routes.ts` (or equivalent) in the distribution frontend +3. **Add permission codes** to auth context/provider if Distribution uses role-based nav gating + +--- + +## Key Decisions & Risks +| Item | Risk | Mitigation | +|------|------|------------| +| GL service shared vs. ERP-only | GL proxy may not accept Distribution's auth tokens or branch context | Confirm with team; may need a dedicated Distribution GL proxy config | +| DB schema differences | Distribution's EF context may have different conventions | Review existing migrations before adding new entities | +| API client base URL | Distribution frontend may use a different env var for the backend URL | Check `lib/api.ts` pattern before copying API clients | +| Permission system | Distribution may use different permission codes/claims | Match Distribution's existing RBAC pattern | + +--- + +## Verification +1. **Backend**: Run `dotnet build` in `ERP_Distribution/Distribution` — zero errors +2. **Migration**: Run `dotnet ef database update` — schema applied cleanly +3. **API smoke test**: Hit `GET /api/v1/expenses`, `GET /api/v1/bank-deposits` via Swagger/Postman +4. **Frontend**: Run `npm run dev` in `distribution_fe` — Accounts menu appears in sidebar +5. **E2E flow**: + - Create an expense (Draft → Post → Pay) + - Record a bank deposit and verify cash-in-hand updates + - Open a cheque book and issue a page + - Enter opening balances +6. **Permissions**: Log in as a role without `accounts.*` codes — verify Accounts menu is hidden diff --git a/distribution_fe/app/(dashboard)/payments/bank-accounts/new/page.tsx b/distribution_fe/app/(dashboard)/payments/bank-accounts/new/page.tsx new file mode 100644 index 0000000..9cf326b --- /dev/null +++ b/distribution_fe/app/(dashboard)/payments/bank-accounts/new/page.tsx @@ -0,0 +1,180 @@ +'use client' + +import { useEffect, useState } from 'react' +import Link from 'next/link' +import { useRouter } from 'next/navigation' +import { ArrowLeft } from 'lucide-react' + +import { bankAccounts as bankAccountsApi, getApiError } from '@/lib/api/index' +import { cn } from '@/lib/utils' +import { BankAccountType, type CashAccountTypeDto } from '@/types/payments' + +import { Button, buttonVariants } from '@/components/ui/button' +import { Field, FieldError, FieldLabel } from '@/components/ui/field' +import { Input } from '@/components/ui/input' +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' +import { toast } from '@/components/ui/toast' + +const OTHER_CASH_TYPE = '__other__' + +export default function NewBankAccountPage() { + const router = useRouter() + const [accountType, setAccountType] = useState(BankAccountType.Bank) + + const [cashAccountTypes, setCashAccountTypes] = useState(null) + const [cashAccountTypesError, setCashAccountTypesError] = useState(null) + + const [accountName, setAccountName] = useState('') + const [bankName, setBankName] = useState('') + const [cashAccountTypeChoice, setCashAccountTypeChoice] = useState('') + const [customCashAccountTypeName, setCustomCashAccountTypeName] = useState('') + const [accountNumber, setAccountNumber] = useState('') + const [currencyCode, setCurrencyCode] = useState('LKR') + const [errors, setErrors] = useState>({}) + const [submitting, setSubmitting] = useState(false) + + useEffect(() => { + if (accountType !== BankAccountType.Cash || cashAccountTypes !== null) return + bankAccountsApi.cashAccountTypes() + .then(setCashAccountTypes) + .catch(err => setCashAccountTypesError(getApiError(err))) + }, [accountType, cashAccountTypes]) + + const cashAccountTypeName = + cashAccountTypeChoice === OTHER_CASH_TYPE ? customCashAccountTypeName.trim() : cashAccountTypeChoice + + async function handleSubmit() { + const next: Record = {} + if (!accountName.trim()) next.accountName = 'Account name is required' + if (accountType === BankAccountType.Cash && !cashAccountTypeName) { + next.cashAccountTypeName = 'Select or enter a cash account type' + } + setErrors(next) + if (Object.keys(next).length > 0) return + + setSubmitting(true) + try { + const created = + accountType === BankAccountType.Bank + ? await bankAccountsApi.createBank({ + accountName, + bankName: bankName || null, + accountNumber: accountNumber || null, + currencyCode: currencyCode || undefined, + }) + : await bankAccountsApi.createCash({ + accountName, + cashAccountTypeName, + accountNumber: accountNumber || null, + currencyCode: currencyCode || undefined, + }) + toast.add({ title: `${accountType} account created`, description: created.accountName, type: 'success' }) + router.push('/payments/bank-accounts') + } catch (err) { + toast.add({ title: `Could not create ${accountType.toLowerCase()} account`, description: getApiError(err), type: 'error' }) + } finally { + setSubmitting(false) + } + } + + return ( +
+
+ + + +
+

New Cash / Bank Account

+

Record a new cash or bank account for use in payments.

+
+
+ +
+
+ + +
+ +
+ + Account name + setAccountName(e.target.value)} + placeholder={accountType === BankAccountType.Bank ? 'Main Account' : 'Head Office Petty Cash'} + aria-invalid={!!errors.accountName} + /> + + + + {accountType === BankAccountType.Bank ? ( + <> + + Bank name (optional) + setBankName(e.target.value)} placeholder="Commercial Bank" /> + + + Account number (optional) + setAccountNumber(e.target.value)} placeholder="8001234567" /> + + + ) : ( + <> + + Cash account type + value={cashAccountTypeChoice} onValueChange={(v) => setCashAccountTypeChoice(v ?? '')}> + + + + + {(cashAccountTypes ?? []).map(t => ( + {t.name} + ))} + Other, please specify… + + + {cashAccountTypeChoice === OTHER_CASH_TYPE && ( + setCustomCashAccountTypeName(e.target.value)} + placeholder="e.g. Site Cash" + className="mt-2" + /> + )} + {cashAccountTypesError && ( +

{cashAccountTypesError}

+ )} + +
+ + Account number (optional) + setAccountNumber(e.target.value)} /> + + + )} + + + Currency + setCurrencyCode(e.target.value)} maxLength={3} placeholder="LKR" /> + +
+ +
+ Cancel + +
+
+
+ ) +} diff --git a/distribution_fe/app/(dashboard)/payments/bank-accounts/page.tsx b/distribution_fe/app/(dashboard)/payments/bank-accounts/page.tsx new file mode 100644 index 0000000..76efcd2 --- /dev/null +++ b/distribution_fe/app/(dashboard)/payments/bank-accounts/page.tsx @@ -0,0 +1,276 @@ +'use client' + +import { useEffect, useMemo, useState } from 'react' +import Link from 'next/link' +import { CheckCircle2, Pencil, Plus, Search, Trash2, Wallet, XCircle } from 'lucide-react' + +import { bankAccounts as bankAccountsApi, getApiError } from '@/lib/api/index' +import { cn } from '@/lib/utils' +import { BankAccountType, type BankAccountResponse } from '@/types/payments' + +import { Badge } from '@/components/ui/badge' +import { Button, buttonVariants } from '@/components/ui/button' +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog' +import { Field, FieldError, FieldGroup, FieldLabel } from '@/components/ui/field' +import { Input } from '@/components/ui/input' +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' +import { Skeleton } from '@/components/ui/skeleton' +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table' +import { toast } from '@/components/ui/toast' + +type AccountTypeFilter = BankAccountType | 'All' + +function formatDate(value: string): string { + return new Date(value).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }) +} + +export default function BankAccountsPage() { + const [accounts, setAccounts] = useState(null) + const [error, setError] = useState(null) + const [search, setSearch] = useState('') + const [accountType, setAccountType] = useState('All') + + const [editTarget, setEditTarget] = useState(null) + const [editName, setEditName] = useState('') + const [editError, setEditError] = useState(null) + const [editSubmitting, setEditSubmitting] = useState(false) + const [statusPendingId, setStatusPendingId] = useState(null) + const [deletingId, setDeletingId] = useState(null) + const [confirmDelete, setConfirmDelete] = useState(null) + + function load() { + const filter = accountType === 'All' ? undefined : accountType + bankAccountsApi + .list(filter) + .then(setAccounts) + .catch(err => setError(getApiError(err))) + } + + useEffect(load, [accountType]) + + const filtered = useMemo(() => { + if (!accounts) return null + const q = search.trim().toLowerCase() + if (!q) return accounts + return accounts.filter(a => + a.accountName.toLowerCase().includes(q) || + (a.bankName ?? '').toLowerCase().includes(q) || + (a.cashAccountTypeName ?? '').toLowerCase().includes(q) || + (a.accountNumber ?? '').toLowerCase().includes(q) || + a.currencyCode.toLowerCase().includes(q), + ) + }, [accounts, search]) + + function openEdit(a: BankAccountResponse) { + setEditTarget(a) + setEditName(a.accountName) + setEditError(null) + } + + async function handleRename() { + if (!editTarget) return + if (!editName.trim()) { + setEditError('Account name is required') + return + } + setEditSubmitting(true) + try { + await bankAccountsApi.updateCash(editTarget.accountId, editName.trim()) + toast.add({ title: 'Cash account renamed', type: 'success' }) + setEditTarget(null) + load() + } catch (err) { + setEditError(getApiError(err)) + } finally { + setEditSubmitting(false) + } + } + + async function toggleStatus(a: BankAccountResponse) { + setStatusPendingId(a.accountId) + try { + await bankAccountsApi.setCashStatus(a.accountId, !a.isActive) + toast.add({ title: a.isActive ? 'Cash account deactivated' : 'Cash account activated', type: 'success' }) + load() + } catch (err) { + toast.add({ title: 'Could not update status', description: getApiError(err), type: 'error' }) + } finally { + setStatusPendingId(null) + } + } + + async function handleDelete(a: BankAccountResponse) { + setDeletingId(a.accountId) + try { + await bankAccountsApi.deleteCash(a.accountId) + toast.add({ title: 'Cash account deleted', type: 'success' }) + load() + } catch (err) { + toast.add({ title: 'Could not delete cash account', description: getApiError(err), type: 'error' }) + } finally { + setDeletingId(null) + setConfirmDelete(null) + } + } + + return ( +
+
+
+

Cash / Bank Accounts

+

Cash and bank accounts used for payments, deposits, and cheques.

+
+ + + New Account + +
+ +
+
+ + setSearch(e.target.value)} + placeholder="Search name, bank/type, account no. or currency…" + className="pl-9" + aria-label="Search cash/bank accounts" + /> +
+ value={accountType} onValueChange={(v) => setAccountType(v ?? 'All')}> + + + + + All types + Bank + Cash + + +
+ + {error && ( +
{error}
+ )} + + {!error && filtered === null && ( +
+ {Array.from({ length: 4 }).map((_, i) => )} +
+ )} + + {!error && filtered !== null && filtered.length === 0 && ( +
+ +

+ {search ? 'No accounts match your search.' : 'No cash/bank accounts yet.'} +

+
+ )} + + {!error && filtered !== null && filtered.length > 0 && ( + + + + Type + Account name + Bank / Cash type + Account no. + Currency + Created + Actions + + + + {filtered.map(a => ( + + + + {a.accountType} + + + {a.accountName} + {a.bankName ?? a.cashAccountTypeName ?? '—'} + {a.accountNumber ?? '—'} + {a.currencyCode} + {formatDate(a.createdAt)} + + {a.accountType === BankAccountType.Cash ? ( +
+ + + +
+ ) : ( + — + )} +
+
+ ))} +
+
+ )} + + { if (!v) setEditTarget(null) }}> + + + Rename cash account + + {editTarget?.isDefault ? 'This is the default cash account — only its name can be changed.' : "Update this cash account's display name."} + + + + + Account name + setEditName(e.target.value)} aria-invalid={!!editError} /> + + + +
+ + +
+
+
+ + { if (!v) setConfirmDelete(null) }}> + + + Delete {confirmDelete?.accountName}? + This permanently removes the cash account. Accounts referenced elsewhere cannot be deleted. + +
+ + +
+
+
+
+ ) +} + diff --git a/distribution_fe/app/(dashboard)/payments/cheque-books/[chequeBookNo]/page.tsx b/distribution_fe/app/(dashboard)/payments/cheque-books/[chequeBookNo]/page.tsx new file mode 100644 index 0000000..fec72b7 --- /dev/null +++ b/distribution_fe/app/(dashboard)/payments/cheque-books/[chequeBookNo]/page.tsx @@ -0,0 +1,397 @@ +'use client' + +import { useEffect, useState } from 'react' +import Link from 'next/link' +import { useParams } from 'next/navigation' +import { ArrowLeft, BookText } from 'lucide-react' + +import { bankAccounts as bankAccountsApi, chequeBooks as chequeBooksApi, chequePages as chequePagesApi, getApiError } from '@/lib/api/index' +import { cn } from '@/lib/utils' +import { + BankAccountType, + ChequePageIssueStatus, + ChequePageStatusAction, + PayeeType, + type BankAccountResponse, + type ChequeBookResponse, + type ChequePageResponse, +} from '@/types/payments' + +import { Badge } from '@/components/ui/badge' +import { Button, buttonVariants } from '@/components/ui/button' +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog' +import { Field, FieldError, FieldLabel } from '@/components/ui/field' +import { Input } from '@/components/ui/input' +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' +import { Skeleton } from '@/components/ui/skeleton' +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table' +import { toast } from '@/components/ui/toast' + +const STATUS_BADGE_VARIANT: Record = { + [ChequePageIssueStatus.Unused]: 'outline', + [ChequePageIssueStatus.Issued]: 'default', + [ChequePageIssueStatus.Cleared]: 'secondary', + [ChequePageIssueStatus.Bounced]: 'destructive', + [ChequePageIssueStatus.Cancelled]: 'destructive', + [ChequePageIssueStatus.Void]: 'outline', +} + +function formatDate(value: string | null): string { + if (!value) return '—' + return new Date(value).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }) +} + +function formatAmount(value: number | null): string { + if (value === null) return '—' + return value.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) +} + +export default function ChequeBookDetailPage() { + const params = useParams<{ chequeBookNo: string }>() + const chequeBookNo = decodeURIComponent(params.chequeBookNo) + + const [book, setBook] = useState(null) + const [bankAccount, setBankAccount] = useState(null) + const [error, setError] = useState(null) + const [selectedPage, setSelectedPage] = useState(null) + + useEffect(() => { + let cancelled = false + chequeBooksApi + .get(chequeBookNo, true) + .then(async res => { + if (cancelled) return + setBook(res) + try { + const banks = await bankAccountsApi.list(BankAccountType.Bank) + if (!cancelled) setBankAccount(banks.find(b => b.accountId === res.bankAccountId) ?? null) + } catch { /* ignore */ } + }) + .catch(err => { if (!cancelled) setError(getApiError(err)) }) + return () => { cancelled = true } + }, [chequeBookNo]) + + function handlePageUpdated(updated: ChequePageResponse) { + setBook(prev => prev ? { ...prev, pages: prev.pages.map(p => p.chequeNo === updated.chequeNo ? updated : p) } : prev) + setSelectedPage(updated) + } + + return ( +
+
+ + + +
+

Cheque Book {chequeBookNo}

+

Every leaf in this book — click one to view or take an action.

+
+
+ + {error && ( +
{error}
+ )} + + {!error && book === null && ( +
+ {Array.from({ length: 4 }).map((_, i) => )} +
+ )} + + {!error && book !== null && ( + <> +
+
+

Bank account

+

{bankAccount ? bankAccount.accountName : `#${book.bankAccountId.slice(0, 8)}`}

+
+
+

Branch

+

{book.branchId}

+
+
+

Range

+

{book.startChequeNo} – {book.endChequeNo}

+
+
+

Received

+

{formatDate(book.receivedDate)}

+
+
+ + {book.pages.length === 0 ? ( +
+ +

No pages found for this book.

+
+ ) : ( + + + + Cheque no. + Status + Payee + Issue date + Amount + + + + {book.pages.map(p => ( + setSelectedPage(p)}> + {p.chequeNo} + + {p.issueStatus} + + {p.payeeName ?? '—'} + {formatDate(p.issueDate)} + {formatAmount(p.amount)} + + ))} + +
+ )} + + )} + + setSelectedPage(null)} onUpdated={handlePageUpdated} /> +
+ ) +} + +// Inline cheque page action dialog — Distribution doesn't ship a shared ChequePageDialog component. +function ChequePageDialog({ + page, + onClose, + onUpdated, +}: { + page: ChequePageResponse | null + onClose: () => void + onUpdated: (p: ChequePageResponse) => void +}) { + const open = page !== null + const [mode, setMode] = useState<'view' | 'issue' | 'status'>('view') + const [submitting, setSubmitting] = useState(false) + + // Issue form + const [payeeType, setPayeeType] = useState(PayeeType.Supplier) + const [payeeName, setPayeeName] = useState('') + const [issueDate, setIssueDate] = useState('') + const [amount, setAmount] = useState('') + const [purpose, setPurpose] = useState('') + const [issueErrors, setIssueErrors] = useState>({}) + + // Status form + const [action, setAction] = useState(ChequePageStatusAction.Clear) + const [clearedDate, setClearedDate] = useState('') + const [cancelReason, setCancelReason] = useState('') + + useEffect(() => { + if (!page) return + setMode('view') + setPayeeType(page.payeeType ?? PayeeType.Supplier) + setPayeeName(page.payeeName ?? '') + setIssueDate(page.issueDate ? page.issueDate.slice(0, 10) : '') + setAmount(page.amount != null ? String(page.amount) : '') + setPurpose(page.purpose ?? '') + setIssueErrors({}) + setAction(ChequePageStatusAction.Clear) + setClearedDate('') + setCancelReason('') + }, [page]) + + if (!page) return null + + async function handleIssue() { + if (!page) return + const next: Record = {} + if (!payeeName.trim()) next.payeeName = 'Payee name is required' + if (!issueDate) next.issueDate = 'Issue date is required' + const amountNum = Number(amount) + if (!amount || Number.isNaN(amountNum) || amountNum <= 0) next.amount = 'Amount must be greater than zero' + setIssueErrors(next) + if (Object.keys(next).length > 0) return + + setSubmitting(true) + try { + const updated = await chequePagesApi.issue(page.chequeNo, { + payeeType, + payeeName, + issueDate, + amount: amountNum, + purpose: purpose || undefined, + }) + toast.add({ title: 'Cheque issued', description: `${updated.chequeNo} — ${updated.payeeName}`, type: 'success' }) + onUpdated(updated) + setMode('view') + } catch (err) { + toast.add({ title: 'Could not issue cheque', description: getApiError(err), type: 'error' }) + } finally { + setSubmitting(false) + } + } + + async function handleStatus() { + if (!page) return + if (action === ChequePageStatusAction.Clear && !clearedDate) { + toast.add({ title: 'Cleared date is required', type: 'error' }) + return + } + if (action === ChequePageStatusAction.Cancel && !cancelReason.trim()) { + toast.add({ title: 'Cancel reason is required', type: 'error' }) + return + } + + setSubmitting(true) + try { + const updated = await chequePagesApi.updateStatus(page.chequeNo, { + action, + clearedDate: action === ChequePageStatusAction.Clear ? clearedDate : undefined, + cancelReason: action === ChequePageStatusAction.Cancel ? cancelReason : undefined, + }) + toast.add({ title: `Cheque ${action.toLowerCase()}ed`, type: 'success' }) + onUpdated(updated) + setMode('view') + } catch (err) { + toast.add({ title: 'Could not update status', description: getApiError(err), type: 'error' }) + } finally { + setSubmitting(false) + } + } + + const canIssue = page.issueStatus === ChequePageIssueStatus.Unused + const canChangeStatus = page.issueStatus === ChequePageIssueStatus.Issued || page.issueStatus === ChequePageIssueStatus.Unused + + const availableActions: ChequePageStatusAction[] = + page.issueStatus === ChequePageIssueStatus.Issued + ? [ChequePageStatusAction.Clear, ChequePageStatusAction.Bounce, ChequePageStatusAction.Cancel] + : page.issueStatus === ChequePageIssueStatus.Unused + ? [ChequePageStatusAction.Void] + : [] + + return ( + { if (!v) onClose() }}> + + + Cheque {page.chequeNo} + + Status: {page.issueStatus} + + + + {mode === 'view' && ( +
+
+
+

Payee

+

{page.payeeName ?? '—'}

+
+
+

Payee type

+

{page.payeeType ?? '—'}

+
+
+

Issue date

+

{formatDate(page.issueDate)}

+
+
+

Amount

+

{formatAmount(page.amount)}

+
+ {page.purpose && ( +
+

Purpose

+

{page.purpose}

+
+ )} + {page.cancelReason && ( +
+

Cancel reason

+

{page.cancelReason}

+
+ )} +
+
+ {canIssue && } + {canChangeStatus && availableActions.length > 0 && ( + + )} +
+
+ )} + + {mode === 'issue' && ( +
+ + Payee type + value={payeeType} onValueChange={(v) => setPayeeType(v ?? PayeeType.Supplier)}> + + + {Object.values(PayeeType).map(t => ( + {t} + ))} + + + + + Payee name + setPayeeName(e.target.value)} aria-invalid={!!issueErrors.payeeName} /> + + + + Issue date + setIssueDate(e.target.value)} aria-invalid={!!issueErrors.issueDate} /> + + + + Amount + setAmount(e.target.value)} aria-invalid={!!issueErrors.amount} /> + + + + Purpose (optional) + setPurpose(e.target.value)} /> + +
+ + +
+
+ )} + + {mode === 'status' && ( +
+ + Action + value={action} onValueChange={(v) => setAction(v ?? availableActions[0])}> + + + {availableActions.map(a => ( + {a} + ))} + + + + {action === ChequePageStatusAction.Clear && ( + + Cleared date + setClearedDate(e.target.value)} /> + + )} + {action === ChequePageStatusAction.Cancel && ( + + Cancel reason + setCancelReason(e.target.value)} /> + + )} +
+ + +
+
+ )} +
+
+ ) +} diff --git a/distribution_fe/app/(dashboard)/payments/cheque-books/new/page.tsx b/distribution_fe/app/(dashboard)/payments/cheque-books/new/page.tsx new file mode 100644 index 0000000..b2fc05e --- /dev/null +++ b/distribution_fe/app/(dashboard)/payments/cheque-books/new/page.tsx @@ -0,0 +1,167 @@ +'use client' + +import { useEffect, useState } from 'react' +import Link from 'next/link' +import { useRouter } from 'next/navigation' +import { ArrowLeft } from 'lucide-react' + +import { bankAccounts as bankAccountsApi, chequeBooks as chequeBooksApi, getApiError } from '@/lib/api/index' +import { cn } from '@/lib/utils' +import { BankAccountType, type BankAccountResponse } from '@/types/payments' + +import { Button, buttonVariants } from '@/components/ui/button' +import { Field, FieldError, FieldLabel } from '@/components/ui/field' +import { Input } from '@/components/ui/input' +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' +import { toast } from '@/components/ui/toast' + +export default function NewChequeBookPage() { + const router = useRouter() + const [bankAccounts, setBankAccounts] = useState(null) + const [bankAccountsError, setBankAccountsError] = useState(null) + + const [branchId, setBranchId] = useState('') + const [bankAccountId, setBankAccountId] = useState('') + const [chequeBookNo, setChequeBookNo] = useState('') + const [startChequeNo, setStartChequeNo] = useState('') + const [endChequeNo, setEndChequeNo] = useState('') + const [totalLeaves, setTotalLeaves] = useState('') + const [receivedDate, setReceivedDate] = useState('') + const [description, setDescription] = useState('') + const [createdBy, setCreatedBy] = useState('') + const [errors, setErrors] = useState>({}) + const [submitting, setSubmitting] = useState(false) + + useEffect(() => { + bankAccountsApi.list(BankAccountType.Bank) + .then(setBankAccounts) + .catch(err => setBankAccountsError(getApiError(err))) + }, []) + + async function handleSubmit() { + const next: Record = {} + if (!bankAccountId) next.bankAccountId = 'Bank account is required' + if (!branchId) next.branchId = 'Branch is required' + if (!chequeBookNo.trim()) next.chequeBookNo = 'Cheque book number is required' + if (!startChequeNo.trim()) next.startChequeNo = 'Start cheque number is required' + if (!endChequeNo.trim()) next.endChequeNo = 'End cheque number is required' + const leavesNum = Number(totalLeaves) + if (!totalLeaves || Number.isNaN(leavesNum) || leavesNum <= 0) next.totalLeaves = 'Total leaves must be greater than zero' + if (!receivedDate) next.receivedDate = 'Received date is required' + setErrors(next) + if (Object.keys(next).length > 0) return + + setSubmitting(true) + try { + const created = await chequeBooksApi.create({ + branchId: Number(branchId), + bankAccountId, + chequeBookNo, + startChequeNo, + endChequeNo, + totalLeaves: Number(totalLeaves), + receivedDate, + description: description || undefined, + createdBy: createdBy || undefined, + }) + toast.add({ title: 'Cheque book created', description: `${created.chequeBookNo} — ${created.totalLeaves} leaves`, type: 'success' }) + router.push(`/payments/cheque-books/${encodeURIComponent(created.chequeBookNo)}`) + } catch (err) { + toast.add({ title: 'Could not create cheque book', description: getApiError(err), type: 'error' }) + } finally { + setSubmitting(false) + } + } + + return ( +
+
+ + + +
+

New Cheque Book

+

+ Every leaf from the start to end cheque number is generated automatically, all "Unused". +

+
+
+ + {bankAccountsError && ( +
{bankAccountsError}
+ )} + +
+
+ + Bank account + value={bankAccountId} onValueChange={(v) => setBankAccountId(v ?? '')}> + + + + + {(bankAccounts ?? []).map(a => ( + + {a.accountName}{a.bankName ? ` — ${a.bankName}` : ''} + + ))} + + + + + + + Branch + setBranchId(e.target.value)} placeholder="1" aria-invalid={!!errors.branchId} /> + + + + + Cheque book number + setChequeBookNo(e.target.value)} placeholder="CB-0001" aria-invalid={!!errors.chequeBookNo} /> + + + + + Start cheque no. + setStartChequeNo(e.target.value)} placeholder="000001" aria-invalid={!!errors.startChequeNo} /> + + + + End cheque no. + setEndChequeNo(e.target.value)} placeholder="000025" aria-invalid={!!errors.endChequeNo} /> + + + + + Total leaves + setTotalLeaves(e.target.value)} placeholder="25" aria-invalid={!!errors.totalLeaves} /> +

Must equal end − start + 1.

+ +
+ + + Received date + setReceivedDate(e.target.value)} aria-invalid={!!errors.receivedDate} /> + + + + + Description (optional) + setDescription(e.target.value)} /> + + + + Created by (optional) + setCreatedBy(e.target.value)} /> + +
+ +
+ Cancel + +
+
+
+ ) +} diff --git a/distribution_fe/app/(dashboard)/payments/cheque-books/page.tsx b/distribution_fe/app/(dashboard)/payments/cheque-books/page.tsx new file mode 100644 index 0000000..58bae3a --- /dev/null +++ b/distribution_fe/app/(dashboard)/payments/cheque-books/page.tsx @@ -0,0 +1,143 @@ +'use client' + +import { useEffect, useMemo, useState } from 'react' +import Link from 'next/link' +import { useRouter } from 'next/navigation' +import { BookText, Plus } from 'lucide-react' + +import { bankAccounts as bankAccountsApi, chequeBooks as chequeBooksApi, getApiError } from '@/lib/api/index' +import { cn } from '@/lib/utils' +import { + BankAccountType, + ChequeBookStatus, + type BankAccountResponse, + type ChequeBookResponse, +} from '@/types/payments' + +import { Badge } from '@/components/ui/badge' +import { buttonVariants } from '@/components/ui/button' +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' +import { Skeleton } from '@/components/ui/skeleton' +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table' + +type StatusFilter = ChequeBookStatus | 'All' + +const STATUS_BADGE_VARIANT: Record = { + [ChequeBookStatus.Active]: 'default', + [ChequeBookStatus.Completed]: 'secondary', + [ChequeBookStatus.Cancelled]: 'destructive', +} + +function formatDate(value: string): string { + return new Date(value).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }) +} + +export default function ChequeBooksPage() { + const router = useRouter() + const [books, setBooks] = useState(null) + const [bankAccountMap, setBankAccountMap] = useState>(new Map()) + const [error, setError] = useState(null) + const [status, setStatus] = useState('All') + + useEffect(() => { + bankAccountsApi + .list(BankAccountType.Bank) + .then(list => setBankAccountMap(new Map(list.map(a => [a.accountId, a])))) + .catch(() => setBankAccountMap(new Map())) + }, []) + + useEffect(() => { + let cancelled = false + chequeBooksApi + .list({ status: status === 'All' ? undefined : status, pageSize: 100 }) + .then(res => { if (!cancelled) setBooks(res.items) }) + .catch(err => { if (!cancelled) setError(getApiError(err)) }) + return () => { cancelled = true } + }, [status]) + + const sortedBooks = useMemo(() => books, [books]) + + return ( +
+
+
+

Cheque Books

+

Cheque books issued from the company's own supply.

+
+ + + New Cheque Book + +
+ +
+ value={status} onValueChange={(v) => setStatus(v ?? 'All')}> + + + + + All statuses + Active + Completed + Cancelled + + +
+ + {error && ( +
{error}
+ )} + + {!error && sortedBooks === null && ( +
+ {Array.from({ length: 4 }).map((_, i) => )} +
+ )} + + {!error && sortedBooks !== null && sortedBooks.length === 0 && ( +
+ +

No cheque books yet.

+
+ )} + + {!error && sortedBooks !== null && sortedBooks.length > 0 && ( + + + + Cheque book no. + Bank account + Branch + Range + Leaves + Received + Status + + + + {sortedBooks.map(b => { + const bank = bankAccountMap.get(b.bankAccountId) + return ( + router.push(`/payments/cheque-books/${encodeURIComponent(b.chequeBookNo)}`)} + > + {b.chequeBookNo} + {bank ? bank.accountName : `#${b.bankAccountId.slice(0, 8)}`} + {b.branchId || '—'} + {b.startChequeNo} – {b.endChequeNo} + {b.totalLeaves} + {formatDate(b.receivedDate)} + + {b.status} + + + ) + })} + +
+ )} +
+ ) +} diff --git a/distribution_fe/app/(dashboard)/payments/received-cheques/new/page.tsx b/distribution_fe/app/(dashboard)/payments/received-cheques/new/page.tsx new file mode 100644 index 0000000..3a3e2e2 --- /dev/null +++ b/distribution_fe/app/(dashboard)/payments/received-cheques/new/page.tsx @@ -0,0 +1,189 @@ +'use client' + +import { useState } from 'react' +import Link from 'next/link' +import { useRouter } from 'next/navigation' +import { ArrowLeft } from 'lucide-react' + +import { receivedCheques as receivedChequesApi, getApiError } from '@/lib/api/index' +import { cn } from '@/lib/utils' +import { ReceivedFromType } from '@/types/payments' + +import { Button, buttonVariants } from '@/components/ui/button' +import { Field, FieldError, FieldLabel } from '@/components/ui/field' +import { Input } from '@/components/ui/input' +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' +import { toast } from '@/components/ui/toast' + +export default function NewReceivedChequePage() { + const router = useRouter() + + const [companyId, setCompanyId] = useState('') + const [branchId, setBranchId] = useState('') + const [receivedFromType, setReceivedFromType] = useState(ReceivedFromType.Customer) + const [receivedFromId, setReceivedFromId] = useState('') + const [receivedFromName, setReceivedFromName] = useState('') + const [drawerBankName, setDrawerBankName] = useState('') + const [drawerBankBranch, setDrawerBankBranch] = useState('') + const [accountHolderName, setAccountHolderName] = useState('') + const [chequeNo, setChequeNo] = useState('') + const [chequeDate, setChequeDate] = useState('') + const [amount, setAmount] = useState('') + const [receivedDate, setReceivedDate] = useState('') + const [referenceType, setReferenceType] = useState('') + const [referenceId, setReferenceId] = useState('') + const [notes, setNotes] = useState('') + const [createdBy, setCreatedBy] = useState('') + const [errors, setErrors] = useState>({}) + const [submitting, setSubmitting] = useState(false) + + async function handleSubmit() { + const next: Record = {} + const companyNum = Number(companyId) + if (!companyId || Number.isNaN(companyNum) || companyNum <= 0) next.companyId = 'Company ID is required' + if (!receivedFromName.trim()) next.receivedFromName = 'Received from name is required' + if (!chequeNo.trim()) next.chequeNo = 'Cheque number is required' + if (!chequeDate) next.chequeDate = 'Cheque date is required' + const amountNum = Number(amount) + if (!amount || Number.isNaN(amountNum) || amountNum <= 0) next.amount = 'Amount must be greater than zero' + if (!receivedDate) next.receivedDate = 'Received date is required' + setErrors(next) + if (Object.keys(next).length > 0) return + + setSubmitting(true) + try { + const created = await receivedChequesApi.create({ + companyId: companyNum, + branchId: branchId ? Number(branchId) : undefined, + receivedFromType, + receivedFromId: receivedFromId ? Number(receivedFromId) : undefined, + receivedFromName, + drawerBankName: drawerBankName || undefined, + drawerBankBranch: drawerBankBranch || undefined, + accountHolderName: accountHolderName || undefined, + chequeNo, + chequeDate, + amount: amountNum, + receivedDate, + referenceType: referenceType || undefined, + referenceId: referenceId ? Number(referenceId) : undefined, + notes: notes || undefined, + createdBy: createdBy || undefined, + }) + toast.add({ title: 'Received cheque recorded', description: `${created.chequeNo} — ${created.receivedFromName}`, type: 'success' }) + router.push('/payments/received-cheques') + } catch (err) { + toast.add({ title: 'Could not record received cheque', description: getApiError(err), type: 'error' }) + } finally { + setSubmitting(false) + } + } + + return ( +
+
+ + + +
+

New Received Cheque

+

Record a cheque received from a customer, supplier, or other party.

+
+
+ +
+
+ + Company ID + setCompanyId(e.target.value)} placeholder="1" aria-invalid={!!errors.companyId} /> + + + + Branch (optional) + setBranchId(e.target.value)} /> + + + + Received from type + value={receivedFromType} onValueChange={(v) => setReceivedFromType(v ?? ReceivedFromType.Customer)}> + + + {Object.values(ReceivedFromType).map(t => ( + {t} + ))} + + + + + + Received from name + setReceivedFromName(e.target.value)} aria-invalid={!!errors.receivedFromName} /> + + + + Received from ID (optional) + setReceivedFromId(e.target.value)} /> + + + + Drawer bank (optional) + setDrawerBankName(e.target.value)} /> + + + Drawer branch (optional) + setDrawerBankBranch(e.target.value)} /> + + + Account holder name (optional) + setAccountHolderName(e.target.value)} /> + + + + Cheque number + setChequeNo(e.target.value)} aria-invalid={!!errors.chequeNo} /> + + + + Cheque date + setChequeDate(e.target.value)} aria-invalid={!!errors.chequeDate} /> + + + + + Amount + setAmount(e.target.value)} aria-invalid={!!errors.amount} /> + + + + Received date + setReceivedDate(e.target.value)} aria-invalid={!!errors.receivedDate} /> + + + + + Reference type (optional) + setReferenceType(e.target.value)} placeholder="Invoice" /> + + + Reference ID (optional) + setReferenceId(e.target.value)} /> + + + + Notes (optional) + setNotes(e.target.value)} /> + + + Created by (optional) + setCreatedBy(e.target.value)} /> + +
+ +
+ Cancel + +
+
+
+ ) +} diff --git a/distribution_fe/app/(dashboard)/payments/received-cheques/page.tsx b/distribution_fe/app/(dashboard)/payments/received-cheques/page.tsx new file mode 100644 index 0000000..1273518 --- /dev/null +++ b/distribution_fe/app/(dashboard)/payments/received-cheques/page.tsx @@ -0,0 +1,287 @@ +'use client' + +import { useEffect, useState } from 'react' +import Link from 'next/link' +import { Inbox, Plus } from 'lucide-react' + +import { bankAccounts as bankAccountsApi, receivedCheques as receivedChequesApi, getApiError } from '@/lib/api/index' +import { cn } from '@/lib/utils' +import { + BankAccountType, + ReceivedChequeStatus, + ReceivedChequeStatusAction, + type BankAccountResponse, + type ReceivedChequeResponse, +} from '@/types/payments' + +import { Badge } from '@/components/ui/badge' +import { Button, buttonVariants } from '@/components/ui/button' +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog' +import { Field, FieldLabel } from '@/components/ui/field' +import { Input } from '@/components/ui/input' +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' +import { Skeleton } from '@/components/ui/skeleton' +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table' +import { toast } from '@/components/ui/toast' + +type StatusFilter = ReceivedChequeStatus | 'All' + +const STATUS_BADGE_VARIANT: Record = { + [ReceivedChequeStatus.Received]: 'outline', + [ReceivedChequeStatus.Deposited]: 'default', + [ReceivedChequeStatus.Cleared]: 'secondary', + [ReceivedChequeStatus.Returned]: 'destructive', + [ReceivedChequeStatus.Cancelled]: 'destructive', +} + +function formatDate(value: string | null): string { + if (!value) return '—' + return new Date(value).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }) +} + +function formatAmount(value: number): string { + return value.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) +} + +export default function ReceivedChequesPage() { + const [cheques, setCheques] = useState(null) + const [error, setError] = useState(null) + const [status, setStatus] = useState('All') + const [selected, setSelected] = useState(null) + + function load() { + receivedChequesApi + .list({ status: status === 'All' ? undefined : status, pageSize: 100 }) + .then(res => setCheques(res.items)) + .catch(err => setError(getApiError(err))) + } + + useEffect(load, [status]) + + function handleUpdated(updated: ReceivedChequeResponse) { + setCheques(prev => prev ? prev.map(c => c.receivedChequeId === updated.receivedChequeId ? updated : c) : prev) + setSelected(updated) + } + + return ( +
+
+
+

Received Cheques

+

Cheques received from customers, suppliers, or others.

+
+ + + New Received Cheque + +
+ +
+ value={status} onValueChange={(v) => setStatus(v ?? 'All')}> + + + + + All statuses + {Object.values(ReceivedChequeStatus).map(s => ( + {s} + ))} + + +
+ + {error && ( +
{error}
+ )} + + {!error && cheques === null && ( +
+ {Array.from({ length: 4 }).map((_, i) => )} +
+ )} + + {!error && cheques !== null && cheques.length === 0 && ( +
+ +

No received cheques yet.

+
+ )} + + {!error && cheques !== null && cheques.length > 0 && ( + + + + Cheque no. + Received from + Type + Amount + Received + Status + + + + {cheques.map(c => ( + setSelected(c)}> + {c.chequeNo} + {c.receivedFromName} + {c.receivedFromType} + {formatAmount(c.amount)} + {formatDate(c.receivedDate)} + + {c.status} + + + ))} + +
+ )} + + setSelected(null)} onUpdated={handleUpdated} /> +
+ ) +} + +function ReceivedChequeDialog({ + cheque, + onClose, + onUpdated, +}: { + cheque: ReceivedChequeResponse | null + onClose: () => void + onUpdated: (c: ReceivedChequeResponse) => void +}) { + const open = cheque !== null + const [mode, setMode] = useState<'view' | 'action'>('view') + const [action, setAction] = useState(ReceivedChequeStatusAction.Deposit) + const [depositBankAccountId, setDepositBankAccountId] = useState('') + const [depositDate, setDepositDate] = useState('') + const [notes, setNotes] = useState('') + const [submitting, setSubmitting] = useState(false) + const [bankOptions, setBankOptions] = useState([]) + + useEffect(() => { + if (!cheque) return + setMode('view') + setAction(ReceivedChequeStatusAction.Deposit) + setDepositBankAccountId('') + setDepositDate('') + setNotes('') + }, [cheque]) + + useEffect(() => { + if (mode !== 'action' || action !== ReceivedChequeStatusAction.Deposit || bankOptions.length > 0) return + bankAccountsApi.list(BankAccountType.Bank).then(setBankOptions).catch(() => setBankOptions([])) + }, [mode, action, bankOptions.length]) + + if (!cheque) return null + + const availableActions: ReceivedChequeStatusAction[] = + cheque.status === ReceivedChequeStatus.Received + ? [ReceivedChequeStatusAction.Deposit, ReceivedChequeStatusAction.Cancel] + : cheque.status === ReceivedChequeStatus.Deposited + ? [ReceivedChequeStatusAction.Clear, ReceivedChequeStatusAction.Return] + : [] + + async function handleSubmit() { + if (!cheque) return + if (action === ReceivedChequeStatusAction.Deposit && (!depositBankAccountId || !depositDate)) { + toast.add({ title: 'Deposit bank account and date are required', type: 'error' }) + return + } + setSubmitting(true) + try { + const updated = await receivedChequesApi.updateStatus(cheque.receivedChequeId, { + action, + depositBankAccountId: action === ReceivedChequeStatusAction.Deposit ? depositBankAccountId : undefined, + depositDate: action === ReceivedChequeStatusAction.Deposit ? depositDate : undefined, + notes: notes || undefined, + }) + toast.add({ title: `Cheque ${action.toLowerCase()}ed`, type: 'success' }) + onUpdated(updated) + setMode('view') + } catch (err) { + toast.add({ title: 'Could not update status', description: getApiError(err), type: 'error' }) + } finally { + setSubmitting(false) + } + } + + return ( + { if (!v) onClose() }}> + + + Cheque {cheque.chequeNo} + + Status: {cheque.status} + + + + {mode === 'view' && ( +
+
+

Received from

{cheque.receivedFromName}

+

Type

{cheque.receivedFromType}

+

Cheque date

{formatDate(cheque.chequeDate)}

+

Amount

{formatAmount(cheque.amount)}

+

Drawer bank

{cheque.drawerBankName ?? '—'}

+

Deposit date

{formatDate(cheque.depositDate)}

+ {cheque.notes && ( +

Notes

{cheque.notes}

+ )} +
+ {availableActions.length > 0 && ( +
+ +
+ )} +
+ )} + + {mode === 'action' && ( +
+ + Action + value={action} onValueChange={(v) => setAction(v ?? availableActions[0])}> + + + {availableActions.map(a => ( + {a} + ))} + + + + {action === ReceivedChequeStatusAction.Deposit && ( + <> + + Deposit bank account + value={depositBankAccountId} onValueChange={(v) => setDepositBankAccountId(v ?? '')}> + + + + + {bankOptions.map(b => ( + {b.accountName} + ))} + + + + + Deposit date + setDepositDate(e.target.value)} /> + + + )} + + Notes (optional) + setNotes(e.target.value)} /> + +
+ + +
+
+ )} +
+
+ ) +} diff --git a/distribution_fe/config/nav.ts b/distribution_fe/config/nav.ts index b2285be..98dcabf 100644 --- a/distribution_fe/config/nav.ts +++ b/distribution_fe/config/nav.ts @@ -127,6 +127,15 @@ export const NAV_GROUPS: NavGroup[] = [ { title: 'Suppliers', href: '/suppliers', icon: UserGroupIcon, description: 'Supplier accounts used for raising purchase orders', permission: 'suppliers.view' }, ], }, + { + title: 'Accounts', + icon: BankIcon, + items: [ + { title: 'Bank Accounts', href: '/payments/bank-accounts', icon: BankIcon, description: 'Cash and bank accounts used for payments and deposits' }, + { title: 'Cheque Books', href: '/payments/cheque-books', icon: ClipboardListIcon, description: 'Cheque books issued from the company’s own supply' }, + { title: 'Received Cheques', href: '/payments/received-cheques', icon: DollarSquareIcon, description: 'Cheques received from customers, suppliers, or others' }, + ], + }, { title: 'Returns & Claims', icon: ClipboardListIcon, diff --git a/distribution_fe/lib/api/bank-accounts.ts b/distribution_fe/lib/api/bank-accounts.ts new file mode 100644 index 0000000..f5378ab --- /dev/null +++ b/distribution_fe/lib/api/bank-accounts.ts @@ -0,0 +1,34 @@ +import { api } from '@/lib/api' +import type { + BankAccountResponse, + BankAccountType, + CashAccountTypeDto, + CreateBankAccountRequest, + CreateCashAccountRequest, +} from '@/types/payments' + +export const bankAccounts = { + list: (accountType?: BankAccountType) => + api + .get('/bank-accounts', { + params: accountType ? { accountType } : undefined, + }) + .then(r => r.data), + + createBank: (body: CreateBankAccountRequest) => + api.post('/bank-accounts', body).then(r => r.data), + + createCash: (body: CreateCashAccountRequest) => + api.post('/cash-accounts', body).then(r => r.data), + + updateCash: (id: string, accountName: string) => + api.put(`/cash-accounts/${id}`, { accountName }).then(r => r.data), + + setCashStatus: (id: string, isActive: boolean) => + api.patch(`/cash-accounts/${id}/status`, { isActive }).then(r => r.data), + + deleteCash: (id: string) => api.delete(`/cash-accounts/${id}`), + + cashAccountTypes: () => + api.get('/cash-account-types').then(r => r.data), +} diff --git a/distribution_fe/lib/api/cheques.ts b/distribution_fe/lib/api/cheques.ts new file mode 100644 index 0000000..d7e401d --- /dev/null +++ b/distribution_fe/lib/api/cheques.ts @@ -0,0 +1,51 @@ +import { api } from '@/lib/api' +import type { + ChequeBookResponse, + ChequeBookStatus, + ChequePageResponse, + CreateChequeBookRequest, + IssueChequePageRequest, + PagedResult, + UpdateChequePageStatusRequest, +} from '@/types/payments' + +export const chequeBooks = { + list: (params?: { + bankAccountId?: string + branchId?: number + status?: ChequeBookStatus + page?: number + pageSize?: number + }) => + api + .get>('/cheque-books', { params }) + .then(r => r.data), + + get: (chequeBookNo: string, expandPages = false) => + api + .get(`/cheque-books/${encodeURIComponent(chequeBookNo)}`, { + params: expandPages ? { expand: 'pages' } : undefined, + }) + .then(r => r.data), + + create: (body: CreateChequeBookRequest) => + api.post('/cheque-books', body).then(r => r.data), +} + +export const chequePages = { + issue: (chequeNo: string, body: IssueChequePageRequest) => + api + .put( + `/cheque-pages/${encodeURIComponent(chequeNo)}/issue`, + body, + ) + .then(r => r.data), + + updateStatus: (chequeNo: string, body: UpdateChequePageStatusRequest) => + api + .put( + `/cheque-pages/${encodeURIComponent(chequeNo)}/status`, + body, + ) + .then(r => r.data), +} diff --git a/distribution_fe/lib/api/index.ts b/distribution_fe/lib/api/index.ts index 08ff4ca..3c3c7e9 100644 --- a/distribution_fe/lib/api/index.ts +++ b/distribution_fe/lib/api/index.ts @@ -12,6 +12,9 @@ export { productReports } from './reports' export { shopPos, invoices, payments } from './sales' export { saleReturns, claims, supplierClaims } from './returns-claims' export { sysConfig, ITEM_TRACKING_KEYS, GRN_TAX_KEYS, grnTaxSettings, DEFAULT_GRN_TAX_SETTINGS } from './sys-config' +export { bankAccounts } from './bank-accounts' +export { chequeBooks, chequePages } from './cheques' +export { receivedCheques } from './received-cheques' export { getPaginatedItems } from './paginated' export type { PageParams } from './master' diff --git a/distribution_fe/lib/api/received-cheques.ts b/distribution_fe/lib/api/received-cheques.ts new file mode 100644 index 0000000..8342864 --- /dev/null +++ b/distribution_fe/lib/api/received-cheques.ts @@ -0,0 +1,29 @@ +import { api } from '@/lib/api' +import type { + CreateReceivedChequeRequest, + PagedResult, + ReceivedChequeResponse, + ReceivedChequeStatus, + ReceivedFromType, + UpdateReceivedChequeStatusRequest, +} from '@/types/payments' + +export const receivedCheques = { + list: (params?: { + companyId?: number + branchId?: number + status?: ReceivedChequeStatus + receivedFromType?: ReceivedFromType + page?: number + pageSize?: number + }) => + api + .get>('/received-cheques', { params }) + .then(r => r.data), + + create: (body: CreateReceivedChequeRequest) => + api.post('/received-cheques', body).then(r => r.data), + + updateStatus: (id: string, body: UpdateReceivedChequeStatusRequest) => + api.put(`/received-cheques/${id}/status`, body).then(r => r.data), +} diff --git a/distribution_fe/types/payments.ts b/distribution_fe/types/payments.ts new file mode 100644 index 0000000..5e619c5 --- /dev/null +++ b/distribution_fe/types/payments.ts @@ -0,0 +1,223 @@ +// Mirrors Distribution backend DTOs in Features/{BankAccount,ChequeBook,ReceivedCheque}. +// Entities use Guid Ids on the backend — represented as strings here. + +export enum BankAccountType { + Cash = 'Cash', + Bank = 'Bank', +} + +export interface BankAccountResponse { + accountType: BankAccountType + accountId: string + accountName: string + bankName: string | null + cashAccountTypeName: string | null + accountNumber: string | null + currencyCode: string + createdAt: string + isActive: boolean | null + isDefault: boolean | null +} + +export interface CreateBankAccountRequest { + accountName: string + bankName?: string | null + accountNumber?: string | null + currencyCode?: string +} + +export interface CreateCashAccountRequest { + accountName: string + cashAccountTypeName: string + accountNumber?: string | null + currencyCode?: string +} + +export interface CashAccountTypeDto { + name: string +} + +// Cheque Books / Pages + +export enum ChequeBookStatus { + Active = 'Active', + Completed = 'Completed', + Cancelled = 'Cancelled', +} + +export enum ChequePageIssueStatus { + Unused = 'Unused', + Issued = 'Issued', + Cleared = 'Cleared', + Bounced = 'Bounced', + Cancelled = 'Cancelled', + Void = 'Void', +} + +export enum ChequePageStatusAction { + Clear = 'Clear', + Bounce = 'Bounce', + Cancel = 'Cancel', + Void = 'Void', +} + +export enum PayeeType { + Supplier = 'Supplier', + Customer = 'Customer', + Employee = 'Employee', + Other = 'Other', +} + +export interface ChequePageResponse { + chequeNo: string + chequeBookNo: string + issueStatus: ChequePageIssueStatus + payeeType: PayeeType | null + payeeId: number | null + payeeName: string | null + issueDate: string | null + amount: number | null + currencyCode: string | null + voucherId: number | null + referenceNo: string | null + purpose: string | null + isCrossCheque: boolean | null + isAccountPayee: boolean | null + isPostDated: boolean | null + notes: string | null + printedBy: string | null + printedAt: string | null + clearedDate: string | null + clearedByBank: boolean | null + cancelReason: string | null +} + +export interface ChequeBookResponse { + chequeBookNo: string + branchId: number + bankAccountId: string + startChequeNo: string + endChequeNo: string + totalLeaves: number + receivedDate: string + description: string | null + createdBy: string | null + status: ChequeBookStatus + pages: ChequePageResponse[] +} + +export interface PagedResult { + items: T[] + totalCount: number + page: number | null + pageSize: number | null +} + +export interface CreateChequeBookRequest { + branchId: number + bankAccountId: string + chequeBookNo: string + startChequeNo: string + endChequeNo: string + totalLeaves: number + receivedDate: string + description?: string + createdBy?: string +} + +export interface IssueChequePageRequest { + payeeType: PayeeType + payeeId?: number + payeeName: string + issueDate: string + amount: number + currencyCode?: string + voucherId?: number + referenceNo?: string + purpose?: string + isCrossCheque?: boolean + isAccountPayee?: boolean + isPostDated?: boolean + notes?: string + printedBy?: string +} + +export interface UpdateChequePageStatusRequest { + action: ChequePageStatusAction + clearedDate?: string + cancelReason?: string + performedBy?: string +} + +// Received Cheques + +export enum ReceivedChequeStatus { + Received = 'Received', + Deposited = 'Deposited', + Cleared = 'Cleared', + Returned = 'Returned', + Cancelled = 'Cancelled', +} + +export enum ReceivedChequeStatusAction { + Deposit = 'Deposit', + Clear = 'Clear', + Return = 'Return', + Cancel = 'Cancel', +} + +export enum ReceivedFromType { + Customer = 'Customer', + Supplier = 'Supplier', + Other = 'Other', +} + +export interface ReceivedChequeResponse { + receivedChequeId: string + companyId: number + branchId: number | null + receivedFromType: ReceivedFromType + receivedFromId: number | null + receivedFromName: string + drawerBankName: string | null + drawerBankBranch: string | null + accountHolderName: string | null + chequeNo: string + chequeDate: string + amount: number + receivedDate: string + referenceType: string | null + referenceId: number | null + notes: string | null + createdBy: string | null + status: ReceivedChequeStatus + depositBankAccountId: string | null + depositDate: string | null +} + +export interface CreateReceivedChequeRequest { + companyId: number + branchId?: number + receivedFromType: ReceivedFromType + receivedFromId?: number + receivedFromName: string + drawerBankName?: string + drawerBankBranch?: string + accountHolderName?: string + chequeNo: string + chequeDate: string + amount: number + receivedDate: string + referenceType?: string + referenceId?: number + notes?: string + createdBy?: string +} + +export interface UpdateReceivedChequeStatusRequest { + action: ReceivedChequeStatusAction + depositBankAccountId?: string + depositDate?: string + notes?: string + performedBy?: string +}