Merge pull request 'Dev' (#72) from dev into production
Reviewed-on: #72
This commit was merged in pull request #72.
This commit is contained in:
@@ -69,6 +69,8 @@ public class AppDBContext(DbContextOptions<AppDBContext> options) : DbContext(op
|
||||
public DbSet<ChequeBook> ChequeBooks { get; set; }
|
||||
public DbSet<ChequePage> ChequePages { get; set; }
|
||||
public DbSet<ReceivedCheque> ReceivedCheques { get; set; }
|
||||
public DbSet<SupplierPayment> SupplierPayments { get; set; }
|
||||
public DbSet<SupplierPaymentGRN> SupplierPaymentGRNs { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -665,6 +667,46 @@ public class AppDBContext(DbContextOptions<AppDBContext> options) : DbContext(op
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired(false);
|
||||
|
||||
// --- SupplierPayment ---
|
||||
|
||||
modelBuilder.Entity<SupplierPayment>()
|
||||
.HasOne(p => p.Supplier)
|
||||
.WithMany()
|
||||
.HasForeignKey(p => p.FK_SupplierId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
modelBuilder.Entity<SupplierPayment>()
|
||||
.HasOne(p => p.BankAccount)
|
||||
.WithMany()
|
||||
.HasForeignKey(p => p.FK_BankAccountId)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired(false);
|
||||
|
||||
modelBuilder.Entity<SupplierPayment>()
|
||||
.HasOne(p => p.ChequePage)
|
||||
.WithMany()
|
||||
.HasForeignKey(p => p.FK_ChequePageId)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired(false);
|
||||
|
||||
modelBuilder.Entity<SupplierPayment>()
|
||||
.Property(p => p.Amount).HasPrecision(18, 2);
|
||||
|
||||
modelBuilder.Entity<SupplierPaymentGRN>()
|
||||
.HasOne(a => a.SupplierPayment)
|
||||
.WithMany(p => p.Allocations)
|
||||
.HasForeignKey(a => a.FK_SupplierPaymentId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<SupplierPaymentGRN>()
|
||||
.HasOne(a => a.GoodsReceipt)
|
||||
.WithMany()
|
||||
.HasForeignKey(a => a.FK_GoodsReceiptId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
modelBuilder.Entity<SupplierPaymentGRN>()
|
||||
.HasIndex(a => a.FK_GoodsReceiptId);
|
||||
|
||||
Seed.RoleAndPermissionSeed.Apply(modelBuilder);
|
||||
Seed.MasterDataSeed.Apply(modelBuilder);
|
||||
Seed.OperationsDataSeed.Apply(modelBuilder);
|
||||
|
||||
@@ -3,6 +3,7 @@ using Distribution.Models;
|
||||
namespace Distribution.Features.ChequeBook;
|
||||
|
||||
public record ChequePageResponse(
|
||||
Guid Id,
|
||||
string ChequeNo,
|
||||
string ChequeBookNo,
|
||||
ChequePageIssueStatus IssueStatus,
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ChequeBookService(
|
||||
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,
|
||||
new(p.Id, 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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Distribution.Models;
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Features.Payment;
|
||||
|
||||
@@ -6,8 +6,14 @@ public record CreatePaymentRequest(
|
||||
decimal Amount,
|
||||
PaymentMethod Method,
|
||||
EntryMode EntryMode = EntryMode.RealTime,
|
||||
// Cash: required. Cheque: optional (used as the deposit account hint if provided).
|
||||
Guid? BankAccountId = null,
|
||||
// Cheque: required.
|
||||
string? ChequeNumber = null,
|
||||
DateTime? ChequeDate = null,
|
||||
// Cheque: optional metadata forwarded to the auto-created ReceivedCheque.
|
||||
string? DrawerBankName = null,
|
||||
string? AccountHolderName = null,
|
||||
Guid? CollectedByUserId = null);
|
||||
|
||||
public record PaymentResponse(
|
||||
@@ -16,6 +22,8 @@ public record PaymentResponse(
|
||||
decimal Amount,
|
||||
PaymentMethod Method,
|
||||
EntryMode EntryMode,
|
||||
Guid? BankAccountId,
|
||||
Guid? ReceivedChequeId,
|
||||
string? ChequeNumber,
|
||||
DateTime? ChequeDate,
|
||||
DateTime CollectedAt,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Distribution.Features.Invoice;
|
||||
using Distribution.Features.BankAccount;
|
||||
using Distribution.Features.Invoice;
|
||||
using Distribution.Features.ReceivedCheque;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Distribution.Infra.UoW;
|
||||
using Distribution.Models;
|
||||
@@ -8,11 +10,15 @@ namespace Distribution.Features.Payment;
|
||||
public class PaymentService(
|
||||
IPaymentRepository repo,
|
||||
IInvoiceRepository invoiceRepo,
|
||||
IBankAccountRepository bankAccountRepo,
|
||||
IReceivedChequeRepository receivedChequeRepo,
|
||||
IUnitOfWork uow,
|
||||
ICurrentUserService currentUser)
|
||||
{
|
||||
private static PaymentResponse ToResponse(Models.Payment p) =>
|
||||
new(p.Id, p.FK_InvoiceId, p.Amount, p.Method, p.EntryMode, p.ChequeNumber, p.ChequeDate,
|
||||
new(p.Id, p.FK_InvoiceId, p.Amount, p.Method, p.EntryMode,
|
||||
p.FK_BankAccountId, p.FK_ReceivedChequeId,
|
||||
p.ChequeNumber, p.ChequeDate,
|
||||
p.CollectedAt, p.CollectedBy, p.RecordedBy, p.CreatedAt);
|
||||
|
||||
public async Task<List<PaymentResponse>?> GetByInvoiceIdAsync(Guid invoiceId)
|
||||
@@ -31,10 +37,26 @@ public class PaymentService(
|
||||
if (invoice.Status == InvoiceStatus.Finalized)
|
||||
throw new InvalidOperationException("Cannot record a payment against a finalized invoice");
|
||||
|
||||
if (request.Amount <= 0)
|
||||
throw new InvalidOperationException("Amount must be greater than zero");
|
||||
|
||||
if (request.Method == PaymentMethod.Cheque &&
|
||||
(string.IsNullOrWhiteSpace(request.ChequeNumber) || request.ChequeDate is null))
|
||||
throw new InvalidOperationException("ChequeNumber and ChequeDate are required when Method is Cheque");
|
||||
|
||||
if (request.Method == PaymentMethod.Cash && request.BankAccountId is null)
|
||||
throw new InvalidOperationException("BankAccountId is required when Method is Cash");
|
||||
|
||||
Models.BankAccount? bankAccount = null;
|
||||
if (request.BankAccountId is not null)
|
||||
{
|
||||
bankAccount = await bankAccountRepo.GetByIdAsync(request.BankAccountId.Value);
|
||||
if (bankAccount is null)
|
||||
throw new InvalidOperationException("BankAccountId does not reference a valid account");
|
||||
if (bankAccount.IsActive is false)
|
||||
throw new InvalidOperationException("The selected account is inactive");
|
||||
}
|
||||
|
||||
var recorderId = currentUser.UserId ?? request.CollectedByUserId
|
||||
?? throw new InvalidOperationException("CollectedByUserId is required while auth is unavailable");
|
||||
var collectedBy = request.CollectedByUserId ?? recorderId;
|
||||
@@ -50,6 +72,7 @@ public class PaymentService(
|
||||
EntryMode = request.EntryMode,
|
||||
ChequeNumber = request.Method == PaymentMethod.Cheque ? request.ChequeNumber : null,
|
||||
ChequeDate = request.Method == PaymentMethod.Cheque ? request.ChequeDate : null,
|
||||
FK_BankAccountId = request.BankAccountId,
|
||||
CollectedAt = DateTime.Now,
|
||||
CollectedBy = collectedBy,
|
||||
RecordedBy = recordedBy
|
||||
@@ -58,6 +81,30 @@ public class PaymentService(
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
// Auto-create a ReceivedCheque for the physical cheque. Status starts at Received;
|
||||
// bookkeeping of the deposit/clear transitions happens through the Received Cheques screen.
|
||||
if (request.Method == PaymentMethod.Cheque)
|
||||
{
|
||||
var cheque = new Models.ReceivedCheque
|
||||
{
|
||||
CompanyId = null,
|
||||
BranchId = null,
|
||||
ReceivedFromType = ReceivedFromType.Customer,
|
||||
ReceivedFromId = null,
|
||||
ReceivedFromName = $"Invoice {invoice.Id}",
|
||||
DrawerBankName = request.DrawerBankName,
|
||||
AccountHolderName = request.AccountHolderName,
|
||||
ChequeNo = request.ChequeNumber!,
|
||||
ChequeDate = request.ChequeDate!.Value,
|
||||
Amount = request.Amount,
|
||||
ReceivedDate = DateTime.Now,
|
||||
ReferenceType = "Invoice",
|
||||
Status = ReceivedChequeStatus.Received
|
||||
};
|
||||
await receivedChequeRepo.AddAsync(cheque);
|
||||
payment.FK_ReceivedChequeId = cheque.Id;
|
||||
}
|
||||
|
||||
await repo.AddAsync(payment);
|
||||
|
||||
var allPayments = await repo.GetByInvoiceIdAsync(invoiceId);
|
||||
@@ -70,6 +117,11 @@ public class PaymentService(
|
||||
: PaymentStatus.Paid;
|
||||
|
||||
invoiceRepo.Update(invoice);
|
||||
|
||||
// TODO ledger: when accounting is wired in, post a journal entry here —
|
||||
// Debit Cash/Bank (BankAccount) OR Cheques-in-hand (for Cheque payments)
|
||||
// Credit Accounts Receivable (invoice.Store)
|
||||
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch { await uow.RollbackAsync(ct); throw; }
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Distribution.Features.ReceivedCheque;
|
||||
|
||||
public record ReceivedChequeResponse(
|
||||
Guid ReceivedChequeId,
|
||||
int CompanyId,
|
||||
int? CompanyId,
|
||||
int? BranchId,
|
||||
ReceivedFromType ReceivedFromType,
|
||||
int? ReceivedFromId,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Features.SupplierPayment;
|
||||
|
||||
public interface ISupplierPaymentRepository
|
||||
{
|
||||
Task<Models.SupplierPayment?> GetByIdAsync(Guid id);
|
||||
Task<List<Models.SupplierPayment>> ListBySupplierAsync(Guid supplierId, int page, int pageSize);
|
||||
Task<int> CountBySupplierAsync(Guid supplierId);
|
||||
Task AddAsync(Models.SupplierPayment payment);
|
||||
|
||||
/// <summary>Sum of currently-allocated amounts to a GRN, across all active SupplierPayments.</summary>
|
||||
Task<decimal> GetAllocatedTotalForGrnAsync(Guid goodsReceiptId);
|
||||
|
||||
/// <summary>Load a GRN with its items so the total can be computed.</summary>
|
||||
Task<Models.GoodsReceipt?> GetGrnWithItemsAsync(Guid goodsReceiptId);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.SupplierPayment;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/suppliers/{supplierId:guid}/payments")]
|
||||
public class SupplierPaymentController(SupplierPaymentService service) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> List(Guid supplierId, [FromQuery] int page = 1, [FromQuery] int pageSize = 20)
|
||||
{
|
||||
var result = await service.ListBySupplierAsync(supplierId, page, pageSize);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(Guid supplierId, CreateSupplierPaymentRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await service.CreateAsync(supplierId, request, ct);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Features.SupplierPayment;
|
||||
|
||||
public record SupplierPaymentAllocationRequest(
|
||||
Guid GoodsReceiptId,
|
||||
decimal AllocatedAmount);
|
||||
|
||||
public record CreateSupplierPaymentRequest(
|
||||
decimal Amount,
|
||||
PaymentMethod Method,
|
||||
// One or more GRNs this payment covers. Sum of AllocatedAmount must equal Amount.
|
||||
List<SupplierPaymentAllocationRequest> Allocations,
|
||||
// Cash: required.
|
||||
Guid? BankAccountId = null,
|
||||
// Cheque: required — an Unused page from an Active cheque book.
|
||||
Guid? ChequePageId = null,
|
||||
string? Notes = null,
|
||||
Guid? PaidByUserId = null);
|
||||
|
||||
public record SupplierPaymentAllocationResponse(
|
||||
Guid GoodsReceiptId,
|
||||
decimal AllocatedAmount);
|
||||
|
||||
public record SupplierPaymentResponse(
|
||||
Guid Id,
|
||||
Guid SupplierId,
|
||||
decimal Amount,
|
||||
PaymentMethod Method,
|
||||
Guid? BankAccountId,
|
||||
Guid? ChequePageId,
|
||||
string? ChequeNo,
|
||||
DateTime PaidAt,
|
||||
Guid? PaidByUserId,
|
||||
string? Notes,
|
||||
List<SupplierPaymentAllocationResponse> Allocations,
|
||||
DateTime CreatedAt);
|
||||
|
||||
public record PagedSupplierPaymentsResponse(
|
||||
List<SupplierPaymentResponse> Items,
|
||||
int Page,
|
||||
int PageSize,
|
||||
int Total);
|
||||
@@ -0,0 +1,43 @@
|
||||
using Distribution.Data;
|
||||
using Distribution.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Features.SupplierPayment;
|
||||
|
||||
public class SupplierPaymentRepository(AppDBContext context) : ISupplierPaymentRepository
|
||||
{
|
||||
public async Task<Models.SupplierPayment?> GetByIdAsync(Guid id) =>
|
||||
await context.SupplierPayments
|
||||
.Include(p => p.ChequePage)
|
||||
.Include(p => p.Allocations)
|
||||
.FirstOrDefaultAsync(p => p.Id == id);
|
||||
|
||||
public async Task<List<Models.SupplierPayment>> ListBySupplierAsync(Guid supplierId, int page, int pageSize) =>
|
||||
await context.SupplierPayments
|
||||
.Include(p => p.ChequePage)
|
||||
.Include(p => p.Allocations)
|
||||
.Where(p => p.FK_SupplierId == supplierId && p.IsActive)
|
||||
.OrderByDescending(p => p.PaidAt)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<int> CountBySupplierAsync(Guid supplierId) =>
|
||||
await context.SupplierPayments
|
||||
.CountAsync(p => p.FK_SupplierId == supplierId && p.IsActive);
|
||||
|
||||
public async Task AddAsync(Models.SupplierPayment payment) =>
|
||||
await context.SupplierPayments.AddAsync(payment);
|
||||
|
||||
public async Task<decimal> GetAllocatedTotalForGrnAsync(Guid goodsReceiptId) =>
|
||||
await context.SupplierPaymentGRNs
|
||||
.Where(a => a.FK_GoodsReceiptId == goodsReceiptId
|
||||
&& a.IsActive
|
||||
&& a.SupplierPayment!.IsActive)
|
||||
.SumAsync(a => (decimal?)a.AllocatedAmount) ?? 0m;
|
||||
|
||||
public async Task<Models.GoodsReceipt?> GetGrnWithItemsAsync(Guid goodsReceiptId) =>
|
||||
await context.GoodsReceipts
|
||||
.Include(g => g.Items)
|
||||
.FirstOrDefaultAsync(g => g.Id == goodsReceiptId && g.IsActive);
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
using Distribution.Data;
|
||||
using Distribution.Features.BankAccount;
|
||||
using Distribution.Features.ChequeBook;
|
||||
using Distribution.Features.Grn;
|
||||
using Distribution.Features.Supplier;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Distribution.Infra.UoW;
|
||||
using Distribution.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Features.SupplierPayment;
|
||||
|
||||
public class SupplierPaymentService(
|
||||
AppDBContext context,
|
||||
ISupplierPaymentRepository repo,
|
||||
ISupplierRepository supplierRepo,
|
||||
IBankAccountRepository bankAccountRepo,
|
||||
IChequeBookRepository chequeBookRepo,
|
||||
IUnitOfWork uow,
|
||||
ICurrentUserService currentUser)
|
||||
{
|
||||
private static SupplierPaymentResponse ToResponse(Models.SupplierPayment p) =>
|
||||
new(p.Id, p.FK_SupplierId, p.Amount, p.Method,
|
||||
p.FK_BankAccountId, p.FK_ChequePageId, p.ChequePage?.ChequeNo,
|
||||
p.PaidAt, p.PaidByUserId, p.Notes,
|
||||
p.Allocations
|
||||
.Where(a => a.IsActive)
|
||||
.Select(a => new SupplierPaymentAllocationResponse(a.FK_GoodsReceiptId, a.AllocatedAmount))
|
||||
.ToList(),
|
||||
p.CreatedAt);
|
||||
|
||||
/// <summary>GRN total = sum per line of (gross - discount + NBT + VAT). Rejected qty never costs.</summary>
|
||||
private static decimal GrnTotal(Models.GoodsReceipt grn) =>
|
||||
grn.Items.Where(i => i.IsActive).Sum(i =>
|
||||
GrnPricing.Line(i.AcceptedQuantity, i.UnitCost, i.DiscountPercent, i.NbtPercent, i.VatPercent).Total);
|
||||
|
||||
public async Task<PagedSupplierPaymentsResponse?> ListBySupplierAsync(Guid supplierId, int page, int pageSize)
|
||||
{
|
||||
var supplier = await supplierRepo.GetByIdAsync(supplierId);
|
||||
if (supplier is null) return null;
|
||||
|
||||
if (page < 1) page = 1;
|
||||
if (pageSize < 1) pageSize = 20;
|
||||
if (pageSize > 200) pageSize = 200;
|
||||
|
||||
var payments = await repo.ListBySupplierAsync(supplierId, page, pageSize);
|
||||
var total = await repo.CountBySupplierAsync(supplierId);
|
||||
return new PagedSupplierPaymentsResponse(payments.Select(ToResponse).ToList(), page, pageSize, total);
|
||||
}
|
||||
|
||||
public async Task<SupplierPaymentResponse?> CreateAsync(Guid supplierId, CreateSupplierPaymentRequest request, CancellationToken ct = default)
|
||||
{
|
||||
var supplier = await supplierRepo.GetByIdAsync(supplierId);
|
||||
if (supplier is null) return null;
|
||||
|
||||
if (request.Amount <= 0)
|
||||
throw new InvalidOperationException("Amount must be greater than zero");
|
||||
if (request.Method == PaymentMethod.Credit)
|
||||
throw new InvalidOperationException("Credit is not a valid outgoing payment method");
|
||||
|
||||
if (request.Allocations is null || request.Allocations.Count == 0)
|
||||
throw new InvalidOperationException("At least one GRN allocation is required");
|
||||
|
||||
var duplicateGrn = request.Allocations.GroupBy(a => a.GoodsReceiptId).FirstOrDefault(g => g.Count() > 1);
|
||||
if (duplicateGrn is not null)
|
||||
throw new InvalidOperationException($"GRN {duplicateGrn.Key} is allocated more than once");
|
||||
|
||||
if (request.Allocations.Any(a => a.AllocatedAmount <= 0))
|
||||
throw new InvalidOperationException("Each allocation amount must be greater than zero");
|
||||
|
||||
var allocationSum = request.Allocations.Sum(a => a.AllocatedAmount);
|
||||
if (allocationSum != request.Amount)
|
||||
throw new InvalidOperationException($"Allocations sum ({allocationSum}) must equal Amount ({request.Amount})");
|
||||
|
||||
// Validate each GRN exists, belongs to this supplier, and the new allocation does not push cumulative paid over the GRN total.
|
||||
foreach (var alloc in request.Allocations)
|
||||
{
|
||||
var grn = await repo.GetGrnWithItemsAsync(alloc.GoodsReceiptId)
|
||||
?? throw new InvalidOperationException($"GRN {alloc.GoodsReceiptId} not found");
|
||||
|
||||
var grnSupplierId = grn.FK_SupplierId
|
||||
?? grn.PurchaseOrder?.FK_SupplierId;
|
||||
if (grnSupplierId is null)
|
||||
{
|
||||
// PO-based GRN without the PO loaded — re-query to confirm supplier match.
|
||||
var po = await context.PurchaseOrders.FindAsync([grn.FK_PurchaseOrderId], ct);
|
||||
grnSupplierId = po?.FK_SupplierId;
|
||||
}
|
||||
if (grnSupplierId != supplierId)
|
||||
throw new InvalidOperationException($"GRN {alloc.GoodsReceiptId} does not belong to the specified supplier");
|
||||
|
||||
var grnTotal = GrnTotal(grn);
|
||||
var alreadyAllocated = await repo.GetAllocatedTotalForGrnAsync(grn.Id);
|
||||
if (alreadyAllocated + alloc.AllocatedAmount > grnTotal)
|
||||
throw new InvalidOperationException(
|
||||
$"Allocation to GRN {grn.Id} ({alloc.AllocatedAmount}) exceeds outstanding balance " +
|
||||
$"(GRN total {grnTotal}, already paid {alreadyAllocated})");
|
||||
}
|
||||
|
||||
var payerId = currentUser.UserId ?? request.PaidByUserId;
|
||||
|
||||
var payment = new Models.SupplierPayment
|
||||
{
|
||||
FK_SupplierId = supplierId,
|
||||
Amount = request.Amount,
|
||||
Method = request.Method,
|
||||
PaidAt = DateTime.Now,
|
||||
PaidByUserId = payerId,
|
||||
Notes = request.Notes,
|
||||
Allocations = request.Allocations.Select(a => new Models.SupplierPaymentGRN
|
||||
{
|
||||
FK_GoodsReceiptId = a.GoodsReceiptId,
|
||||
AllocatedAmount = a.AllocatedAmount
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
if (request.Method == PaymentMethod.Cash)
|
||||
{
|
||||
if (request.BankAccountId is null)
|
||||
throw new InvalidOperationException("BankAccountId is required when Method is Cash");
|
||||
|
||||
var account = await bankAccountRepo.GetByIdAsync(request.BankAccountId.Value);
|
||||
if (account is null)
|
||||
throw new InvalidOperationException("BankAccountId does not reference a valid account");
|
||||
if (account.IsActive is false)
|
||||
throw new InvalidOperationException("The selected account is inactive");
|
||||
|
||||
payment.FK_BankAccountId = account.Id;
|
||||
}
|
||||
else // Cheque
|
||||
{
|
||||
if (request.ChequePageId is null)
|
||||
throw new InvalidOperationException("ChequePageId is required when Method is Cheque");
|
||||
|
||||
var page = await context.ChequePages
|
||||
.Include(p => p.ChequeBook)
|
||||
.FirstOrDefaultAsync(p => p.Id == request.ChequePageId.Value, ct);
|
||||
|
||||
if (page is null)
|
||||
throw new InvalidOperationException("ChequePageId does not reference a valid cheque page");
|
||||
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");
|
||||
|
||||
page.IssueStatus = ChequePageIssueStatus.Issued;
|
||||
page.PayeeType = PayeeType.Supplier;
|
||||
page.PayeeName = supplier.Name;
|
||||
page.IssueDate = DateTime.Now;
|
||||
page.Amount = request.Amount;
|
||||
page.CurrencyCode = "LKR";
|
||||
page.PrintedAt = DateTime.Now;
|
||||
|
||||
chequeBookRepo.UpdatePage(page);
|
||||
payment.FK_ChequePageId = page.Id;
|
||||
payment.ChequePage = page;
|
||||
}
|
||||
|
||||
await repo.AddAsync(payment);
|
||||
|
||||
// TODO ledger: when accounting is wired in, post a journal entry here —
|
||||
// Debit Accounts Payable (supplier)
|
||||
// Credit Cash/Bank (BankAccount) OR Cheques-outstanding (for Cheque payments)
|
||||
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch { await uow.RollbackAsync(ct); throw; }
|
||||
|
||||
return ToResponse(payment);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,928 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Distribution.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddSupplierPayments : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "CompanyId",
|
||||
table: "ReceivedCheques",
|
||||
type: "int",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "FK_BankAccountId",
|
||||
table: "Payments",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "FK_ReceivedChequeId",
|
||||
table: "Payments",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SupplierPayments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
FK_SupplierId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Amount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
|
||||
Method = table.Column<int>(type: "int", nullable: false),
|
||||
FK_BankAccountId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
FK_ChequePageId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
PaidAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
PaidByUserId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
Notes = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SupplierPayments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SupplierPayments_BankAccounts_FK_BankAccountId",
|
||||
column: x => x.FK_BankAccountId,
|
||||
principalTable: "BankAccounts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_SupplierPayments_ChequePages_FK_ChequePageId",
|
||||
column: x => x.FK_ChequePageId,
|
||||
principalTable: "ChequePages",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_SupplierPayments_Suppliers_FK_SupplierId",
|
||||
column: x => x.FK_SupplierId,
|
||||
principalTable: "Suppliers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SupplierPaymentGRNs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
FK_SupplierPaymentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
FK_GoodsReceiptId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
AllocatedAmount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SupplierPaymentGRNs", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SupplierPaymentGRNs_GoodsReceipts_FK_GoodsReceiptId",
|
||||
column: x => x.FK_GoodsReceiptId,
|
||||
principalTable: "GoodsReceipts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_SupplierPaymentGRNs_SupplierPayments_FK_SupplierPaymentId",
|
||||
column: x => x.FK_SupplierPaymentId,
|
||||
principalTable: "SupplierPayments",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Payments",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("47000000-0000-0000-0000-000000000001"),
|
||||
columns: new[] { "FK_BankAccountId", "FK_ReceivedChequeId" },
|
||||
values: new object[] { null, null });
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Payments",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("47000000-0000-0000-0000-000000000002"),
|
||||
columns: new[] { "FK_BankAccountId", "FK_ReceivedChequeId" },
|
||||
values: new object[] { null, null });
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Payments",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("47000000-0000-0000-0000-000000000003"),
|
||||
columns: new[] { "FK_BankAccountId", "FK_ReceivedChequeId" },
|
||||
values: new object[] { null, null });
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Payments",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("47000000-0000-0000-0000-000000000004"),
|
||||
columns: new[] { "FK_BankAccountId", "FK_ReceivedChequeId" },
|
||||
values: new object[] { null, null });
|
||||
|
||||
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("30f658ac-2c92-4cd8-ad47-10b0def2699c"));
|
||||
|
||||
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("42ab2c52-eaf8-4a17-b67a-ccd66569e56a"));
|
||||
|
||||
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("8afec825-27b3-4153-ad06-f8bcdbf93da8"));
|
||||
|
||||
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("4b427620-e99d-4068-a416-c3788d5bd9b5"));
|
||||
|
||||
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("361f44ef-1cd1-48a9-be4d-4c068aacef1e"));
|
||||
|
||||
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("11fc03ae-92ee-4336-ae57-29aac731ad51"));
|
||||
|
||||
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("0b1f2b73-ef60-4634-864f-22a6c0cd1373"));
|
||||
|
||||
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("2380abf3-2bcd-4a9f-b447-5f1685df2fc8"));
|
||||
|
||||
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("240e4d6a-8306-40ba-aaec-8e05cd0347db"));
|
||||
|
||||
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("cfde0aa6-e859-4f9c-8291-b0d886fcd4c9"));
|
||||
|
||||
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("dae772c8-26ec-4b5c-8d7a-f3196510bf2c"));
|
||||
|
||||
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("3512c0a4-a5ae-4002-a779-7d3cc600ab61"));
|
||||
|
||||
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("f9e2a348-159e-47a2-b7be-a60f0254873f"));
|
||||
|
||||
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("c8b4c181-5b08-45d2-818b-74bceeab78a8"));
|
||||
|
||||
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("8fb4ff4c-c5bd-4afd-a08e-02861d63cb7b"));
|
||||
|
||||
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("edb3b711-d623-439d-811e-afaef8d0680d"));
|
||||
|
||||
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("f33e4c62-d69f-4a91-8b62-acbd5351ea2a"));
|
||||
|
||||
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("c7c9d16c-e343-43e9-9e27-f38f903a5d00"));
|
||||
|
||||
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("f5f4760a-8a45-46ca-8093-743c95b0313f"));
|
||||
|
||||
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("c5434801-146a-4fd9-9c29-a1145e7f7f00"));
|
||||
|
||||
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("6c085135-78a5-4e65-a380-ee090b07e2bb"));
|
||||
|
||||
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("bbde2785-a3df-4f81-bad1-0bc5afe5de57"));
|
||||
|
||||
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("4421a0fb-bdd4-45a9-8dc0-d9b70f775e97"));
|
||||
|
||||
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("dba9dcb4-3b94-4ddc-89f3-552cfc109478"));
|
||||
|
||||
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("d8f74160-c150-4d9c-aba6-e45e628c684e"));
|
||||
|
||||
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("495fb68b-9f01-4538-9561-fefce0d39558"));
|
||||
|
||||
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("3bdece9b-a798-4223-a23c-9c9dd10d042d"));
|
||||
|
||||
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("6fa616eb-99fe-46b9-8305-908765d037fd"));
|
||||
|
||||
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("7a07148a-1327-4e97-befc-b2045eacad21"));
|
||||
|
||||
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("852e86d7-aa57-4a77-81c0-054f3fb4d7f7"));
|
||||
|
||||
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("3b767929-c973-41fb-a340-4ee5feb65619"));
|
||||
|
||||
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("63619bbd-0352-41bd-9e1c-a3f7908fb5d2"));
|
||||
|
||||
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("f6b4c8bf-a9b3-4179-9f57-a8584678c0d1"));
|
||||
|
||||
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("bb47b8ca-f7cf-40fe-8945-fc532a439b53"));
|
||||
|
||||
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("52126271-ae3b-4b58-a9d2-50e2dd894087"));
|
||||
|
||||
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("981e3358-85bb-47fe-a1f5-3a3a02cf47b1"));
|
||||
|
||||
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("749408da-fcee-458d-9144-8d8dee928ba0"));
|
||||
|
||||
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("c157857c-fb0e-41fd-a414-c0f57a44b120"));
|
||||
|
||||
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("3217cdbc-76c9-4505-b9f3-23de91a6212b"));
|
||||
|
||||
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("63526c52-18ba-40e0-9889-3bd3b7fc8161"));
|
||||
|
||||
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("260cf2fa-1ca6-4cd5-92ae-8c479a80e2f0"));
|
||||
|
||||
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("130ab09c-8a36-4705-8235-9d00f75dd684"));
|
||||
|
||||
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("41794774-e919-4f4e-a42a-5ae408d3407f"));
|
||||
|
||||
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("2ff23d04-d1f6-4aa3-a48e-1c82bb9ad12a"));
|
||||
|
||||
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("d36c81c0-8e9b-41ea-8e09-464a327a16d2"));
|
||||
|
||||
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("6c51dfc1-63e0-46a6-b2bb-27c21c708b51"));
|
||||
|
||||
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("076333d5-b1f3-4b89-86fd-5a61a4451c88"));
|
||||
|
||||
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("7e834f3e-1424-4aaa-816e-d62da6df672b"));
|
||||
|
||||
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("699fa06b-a7ff-4dbd-98a7-a29c2c361665"));
|
||||
|
||||
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("00df5735-54c6-4cdf-8e2c-a64cd90ede15"));
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Payments_FK_BankAccountId",
|
||||
table: "Payments",
|
||||
column: "FK_BankAccountId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Payments_FK_ReceivedChequeId",
|
||||
table: "Payments",
|
||||
column: "FK_ReceivedChequeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SupplierPaymentGRNs_FK_GoodsReceiptId",
|
||||
table: "SupplierPaymentGRNs",
|
||||
column: "FK_GoodsReceiptId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SupplierPaymentGRNs_FK_SupplierPaymentId",
|
||||
table: "SupplierPaymentGRNs",
|
||||
column: "FK_SupplierPaymentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SupplierPayments_FK_BankAccountId",
|
||||
table: "SupplierPayments",
|
||||
column: "FK_BankAccountId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SupplierPayments_FK_ChequePageId",
|
||||
table: "SupplierPayments",
|
||||
column: "FK_ChequePageId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SupplierPayments_FK_SupplierId",
|
||||
table: "SupplierPayments",
|
||||
column: "FK_SupplierId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Payments_BankAccounts_FK_BankAccountId",
|
||||
table: "Payments",
|
||||
column: "FK_BankAccountId",
|
||||
principalTable: "BankAccounts",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Payments_ReceivedCheques_FK_ReceivedChequeId",
|
||||
table: "Payments",
|
||||
column: "FK_ReceivedChequeId",
|
||||
principalTable: "ReceivedCheques",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Payments_BankAccounts_FK_BankAccountId",
|
||||
table: "Payments");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Payments_ReceivedCheques_FK_ReceivedChequeId",
|
||||
table: "Payments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SupplierPaymentGRNs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SupplierPayments");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Payments_FK_BankAccountId",
|
||||
table: "Payments");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Payments_FK_ReceivedChequeId",
|
||||
table: "Payments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FK_BankAccountId",
|
||||
table: "Payments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FK_ReceivedChequeId",
|
||||
table: "Payments");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "CompanyId",
|
||||
table: "ReceivedCheques",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int",
|
||||
oldNullable: true);
|
||||
|
||||
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("ec13fdfa-d848-4004-b749-4b455ba0a77e"));
|
||||
|
||||
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("66f41359-cf33-4bd9-a936-816f03b23da7"));
|
||||
|
||||
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("369efbe7-f200-4b2e-bc15-858b6d2ca882"));
|
||||
|
||||
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("adc14999-08af-4b4c-937d-3ecd7c35b709"));
|
||||
|
||||
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("f1bf4ccb-45c6-4915-b941-6b507eb1e44f"));
|
||||
|
||||
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("1cbd132a-ea3d-46b2-8150-c5a077b6b36a"));
|
||||
|
||||
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("362118bd-1d4c-4576-95f6-7da899bf7368"));
|
||||
|
||||
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("15e94675-d2ae-4f5a-8198-6297a26d7a2c"));
|
||||
|
||||
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("4af2ab93-d3ba-4bda-b440-167f672cc166"));
|
||||
|
||||
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("bc5ba5f8-f20a-432a-985b-95b9500ce693"));
|
||||
|
||||
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("4f43f82b-8e6a-4729-9ded-c78c7dde24a7"));
|
||||
|
||||
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("7ac3df8c-f5c3-4d57-b537-5d5ca4ec1e11"));
|
||||
|
||||
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("44ec8d0f-f540-4786-9d9a-9194fa091286"));
|
||||
|
||||
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("143c4280-21be-4852-adc5-7cd17ab595fd"));
|
||||
|
||||
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("d00b144e-bf2d-4a04-9c85-0c14544edf48"));
|
||||
|
||||
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("9a72b7e4-1197-4032-8ec6-ebb3442a267f"));
|
||||
|
||||
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("5ec2af6e-d1db-4811-9c37-94a260e6ef9b"));
|
||||
|
||||
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("a71aceba-5199-4824-8b4e-998b108c082c"));
|
||||
|
||||
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("4bd840bf-da52-46fd-b065-40253f915c7c"));
|
||||
|
||||
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("8b4d8558-dba9-45bb-b263-f066580a55e9"));
|
||||
|
||||
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("0ee1a2e0-e4d2-4af3-9cca-ffad05bc1e20"));
|
||||
|
||||
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("700be5ec-0c11-497b-808a-80e7a854d2b4"));
|
||||
|
||||
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("b9978e5a-14b1-462a-9b7b-c9c32c4decb9"));
|
||||
|
||||
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("1e7cc9d4-f65e-434b-90e5-f78b4fda39b8"));
|
||||
|
||||
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("bfb3f80b-32c3-43b0-b216-f05e55f09360"));
|
||||
|
||||
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("fcfe2242-93ad-4c6d-8eec-3ec1f1270d0a"));
|
||||
|
||||
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("8e6eeb90-966f-4417-a1ae-148cdaa64904"));
|
||||
|
||||
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("6df60aea-63f3-465e-96fb-9a7304ead3c2"));
|
||||
|
||||
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("c0e21519-a095-4c7f-af42-e26efdcdd31e"));
|
||||
|
||||
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("496bbf8d-d84d-4c21-b190-bf95a06b4113"));
|
||||
|
||||
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("36f55476-d749-459b-92d9-839919499460"));
|
||||
|
||||
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("d90301fa-8990-49cf-8fa0-228ea7e684bc"));
|
||||
|
||||
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("8da4cd2a-1fd2-4417-bb6d-9e91174193f5"));
|
||||
|
||||
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("cc9bed46-a230-4611-88b4-d568abca857e"));
|
||||
|
||||
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("4d791413-ac44-4165-87b8-c28dbfa49230"));
|
||||
|
||||
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("2bb28028-8b12-4937-9dc6-68e35b100007"));
|
||||
|
||||
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("fdc8d3d9-a32d-4322-8144-93ff677beea3"));
|
||||
|
||||
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("b1ea0901-08e8-4dea-8ac3-15b522a2f274"));
|
||||
|
||||
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("116ac7bf-741e-4d4f-a313-2e7946a50044"));
|
||||
|
||||
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("7fd97ca6-a14b-4e42-8474-5471c0ef79a9"));
|
||||
|
||||
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("e58f35b2-8308-4fbb-b3ca-db9d037347cd"));
|
||||
|
||||
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("dc6b2750-083b-4653-a986-7af7aaec8136"));
|
||||
|
||||
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("6629888a-eb6b-433f-bbfe-ee5d947fb5b2"));
|
||||
|
||||
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("94b97271-7593-4cec-9290-802e9a26f0d8"));
|
||||
|
||||
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("0dc88aca-4e86-4712-988f-8db6a466531d"));
|
||||
|
||||
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("c8839187-4358-4218-bf3d-5ea4ed758661"));
|
||||
|
||||
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("5c731906-8d81-4f85-abad-230050af0bd0"));
|
||||
|
||||
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("d6e3db40-ca38-4caf-88d8-ce87475b4d87"));
|
||||
|
||||
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("398f1c4d-5d7d-4af4-9aa7-a88d7abf9a33"));
|
||||
|
||||
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("0f6c66e6-833c-4b52-ba2c-09da8dbead6f"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1305,9 +1305,15 @@ namespace Distribution.Migrations
|
||||
b.Property<int>("EntryMode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("FK_BankAccountId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("FK_InvoiceId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("FK_ReceivedChequeId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
@@ -1319,8 +1325,12 @@ namespace Distribution.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FK_BankAccountId");
|
||||
|
||||
b.HasIndex("FK_InvoiceId");
|
||||
|
||||
b.HasIndex("FK_ReceivedChequeId");
|
||||
|
||||
b.ToTable("Payments");
|
||||
|
||||
b.HasData(
|
||||
@@ -2144,7 +2154,7 @@ namespace Distribution.Migrations
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.Property<int>("CompanyId")
|
||||
b.Property<int?>("CompanyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
@@ -2518,7 +2528,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("ec13fdfa-d848-4004-b749-4b455ba0a77e"),
|
||||
Id = new Guid("30f658ac-2c92-4cd8-ad47-10b0def2699c"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2526,7 +2536,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("66f41359-cf33-4bd9-a936-816f03b23da7"),
|
||||
Id = new Guid("42ab2c52-eaf8-4a17-b67a-ccd66569e56a"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2534,7 +2544,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("369efbe7-f200-4b2e-bc15-858b6d2ca882"),
|
||||
Id = new Guid("8afec825-27b3-4153-ad06-f8bcdbf93da8"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2542,7 +2552,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("adc14999-08af-4b4c-937d-3ecd7c35b709"),
|
||||
Id = new Guid("4b427620-e99d-4068-a416-c3788d5bd9b5"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2550,7 +2560,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("f1bf4ccb-45c6-4915-b941-6b507eb1e44f"),
|
||||
Id = new Guid("361f44ef-1cd1-48a9-be4d-4c068aacef1e"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2558,7 +2568,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("1cbd132a-ea3d-46b2-8150-c5a077b6b36a"),
|
||||
Id = new Guid("11fc03ae-92ee-4336-ae57-29aac731ad51"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2566,7 +2576,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("362118bd-1d4c-4576-95f6-7da899bf7368"),
|
||||
Id = new Guid("0b1f2b73-ef60-4634-864f-22a6c0cd1373"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2574,7 +2584,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("15e94675-d2ae-4f5a-8198-6297a26d7a2c"),
|
||||
Id = new Guid("2380abf3-2bcd-4a9f-b447-5f1685df2fc8"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2582,7 +2592,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("4af2ab93-d3ba-4bda-b440-167f672cc166"),
|
||||
Id = new Guid("240e4d6a-8306-40ba-aaec-8e05cd0347db"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2590,7 +2600,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("bc5ba5f8-f20a-432a-985b-95b9500ce693"),
|
||||
Id = new Guid("cfde0aa6-e859-4f9c-8291-b0d886fcd4c9"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2598,7 +2608,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("4f43f82b-8e6a-4729-9ded-c78c7dde24a7"),
|
||||
Id = new Guid("dae772c8-26ec-4b5c-8d7a-f3196510bf2c"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2606,7 +2616,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("7ac3df8c-f5c3-4d57-b537-5d5ca4ec1e11"),
|
||||
Id = new Guid("3512c0a4-a5ae-4002-a779-7d3cc600ab61"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2614,7 +2624,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("44ec8d0f-f540-4786-9d9a-9194fa091286"),
|
||||
Id = new Guid("f9e2a348-159e-47a2-b7be-a60f0254873f"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2622,7 +2632,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("143c4280-21be-4852-adc5-7cd17ab595fd"),
|
||||
Id = new Guid("c8b4c181-5b08-45d2-818b-74bceeab78a8"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2630,7 +2640,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("d00b144e-bf2d-4a04-9c85-0c14544edf48"),
|
||||
Id = new Guid("8fb4ff4c-c5bd-4afd-a08e-02861d63cb7b"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2638,7 +2648,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("9a72b7e4-1197-4032-8ec6-ebb3442a267f"),
|
||||
Id = new Guid("edb3b711-d623-439d-811e-afaef8d0680d"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2646,7 +2656,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("5ec2af6e-d1db-4811-9c37-94a260e6ef9b"),
|
||||
Id = new Guid("f33e4c62-d69f-4a91-8b62-acbd5351ea2a"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2654,7 +2664,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("a71aceba-5199-4824-8b4e-998b108c082c"),
|
||||
Id = new Guid("c7c9d16c-e343-43e9-9e27-f38f903a5d00"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2662,7 +2672,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("4bd840bf-da52-46fd-b065-40253f915c7c"),
|
||||
Id = new Guid("f5f4760a-8a45-46ca-8093-743c95b0313f"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2670,7 +2680,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("8b4d8558-dba9-45bb-b263-f066580a55e9"),
|
||||
Id = new Guid("c5434801-146a-4fd9-9c29-a1145e7f7f00"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2678,7 +2688,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("0ee1a2e0-e4d2-4af3-9cca-ffad05bc1e20"),
|
||||
Id = new Guid("6c085135-78a5-4e65-a380-ee090b07e2bb"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2686,7 +2696,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("700be5ec-0c11-497b-808a-80e7a854d2b4"),
|
||||
Id = new Guid("bbde2785-a3df-4f81-bad1-0bc5afe5de57"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2694,7 +2704,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("b9978e5a-14b1-462a-9b7b-c9c32c4decb9"),
|
||||
Id = new Guid("4421a0fb-bdd4-45a9-8dc0-d9b70f775e97"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2702,7 +2712,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("1e7cc9d4-f65e-434b-90e5-f78b4fda39b8"),
|
||||
Id = new Guid("dba9dcb4-3b94-4ddc-89f3-552cfc109478"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2710,7 +2720,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("bfb3f80b-32c3-43b0-b216-f05e55f09360"),
|
||||
Id = new Guid("d8f74160-c150-4d9c-aba6-e45e628c684e"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2718,7 +2728,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("fcfe2242-93ad-4c6d-8eec-3ec1f1270d0a"),
|
||||
Id = new Guid("495fb68b-9f01-4538-9561-fefce0d39558"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2726,7 +2736,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("8e6eeb90-966f-4417-a1ae-148cdaa64904"),
|
||||
Id = new Guid("3bdece9b-a798-4223-a23c-9c9dd10d042d"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2734,7 +2744,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("6df60aea-63f3-465e-96fb-9a7304ead3c2"),
|
||||
Id = new Guid("6fa616eb-99fe-46b9-8305-908765d037fd"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2742,7 +2752,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("c0e21519-a095-4c7f-af42-e26efdcdd31e"),
|
||||
Id = new Guid("7a07148a-1327-4e97-befc-b2045eacad21"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2750,7 +2760,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("496bbf8d-d84d-4c21-b190-bf95a06b4113"),
|
||||
Id = new Guid("852e86d7-aa57-4a77-81c0-054f3fb4d7f7"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2758,7 +2768,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("36f55476-d749-459b-92d9-839919499460"),
|
||||
Id = new Guid("3b767929-c973-41fb-a340-4ee5feb65619"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2766,7 +2776,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("d90301fa-8990-49cf-8fa0-228ea7e684bc"),
|
||||
Id = new Guid("63619bbd-0352-41bd-9e1c-a3f7908fb5d2"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2774,7 +2784,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("8da4cd2a-1fd2-4417-bb6d-9e91174193f5"),
|
||||
Id = new Guid("f6b4c8bf-a9b3-4179-9f57-a8584678c0d1"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2782,7 +2792,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("cc9bed46-a230-4611-88b4-d568abca857e"),
|
||||
Id = new Guid("bb47b8ca-f7cf-40fe-8945-fc532a439b53"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2790,7 +2800,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("4d791413-ac44-4165-87b8-c28dbfa49230"),
|
||||
Id = new Guid("52126271-ae3b-4b58-a9d2-50e2dd894087"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2798,7 +2808,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("2bb28028-8b12-4937-9dc6-68e35b100007"),
|
||||
Id = new Guid("981e3358-85bb-47fe-a1f5-3a3a02cf47b1"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2806,7 +2816,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("fdc8d3d9-a32d-4322-8144-93ff677beea3"),
|
||||
Id = new Guid("749408da-fcee-458d-9144-8d8dee928ba0"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2814,7 +2824,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("b1ea0901-08e8-4dea-8ac3-15b522a2f274"),
|
||||
Id = new Guid("c157857c-fb0e-41fd-a414-c0f57a44b120"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2822,7 +2832,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("116ac7bf-741e-4d4f-a313-2e7946a50044"),
|
||||
Id = new Guid("3217cdbc-76c9-4505-b9f3-23de91a6212b"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2830,7 +2840,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("7fd97ca6-a14b-4e42-8474-5471c0ef79a9"),
|
||||
Id = new Guid("63526c52-18ba-40e0-9889-3bd3b7fc8161"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2838,7 +2848,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("e58f35b2-8308-4fbb-b3ca-db9d037347cd"),
|
||||
Id = new Guid("260cf2fa-1ca6-4cd5-92ae-8c479a80e2f0"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2846,7 +2856,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("dc6b2750-083b-4653-a986-7af7aaec8136"),
|
||||
Id = new Guid("130ab09c-8a36-4705-8235-9d00f75dd684"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2854,7 +2864,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("6629888a-eb6b-433f-bbfe-ee5d947fb5b2"),
|
||||
Id = new Guid("41794774-e919-4f4e-a42a-5ae408d3407f"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2862,7 +2872,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("94b97271-7593-4cec-9290-802e9a26f0d8"),
|
||||
Id = new Guid("2ff23d04-d1f6-4aa3-a48e-1c82bb9ad12a"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2870,7 +2880,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("0dc88aca-4e86-4712-988f-8db6a466531d"),
|
||||
Id = new Guid("d36c81c0-8e9b-41ea-8e09-464a327a16d2"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2878,7 +2888,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("c8839187-4358-4218-bf3d-5ea4ed758661"),
|
||||
Id = new Guid("6c51dfc1-63e0-46a6-b2bb-27c21c708b51"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2886,7 +2896,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("5c731906-8d81-4f85-abad-230050af0bd0"),
|
||||
Id = new Guid("076333d5-b1f3-4b89-86fd-5a61a4451c88"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2894,7 +2904,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("d6e3db40-ca38-4caf-88d8-ce87475b4d87"),
|
||||
Id = new Guid("7e834f3e-1424-4aaa-816e-d62da6df672b"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2902,7 +2912,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("398f1c4d-5d7d-4af4-9aa7-a88d7abf9a33"),
|
||||
Id = new Guid("699fa06b-a7ff-4dbd-98a7-a29c2c361665"),
|
||||
IsActive = true
|
||||
},
|
||||
new
|
||||
@@ -2910,7 +2920,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("0f6c66e6-833c-4b52-ba2c-09da8dbead6f"),
|
||||
Id = new Guid("00df5735-54c6-4cdf-8e2c-a64cd90ede15"),
|
||||
IsActive = true
|
||||
});
|
||||
});
|
||||
@@ -4092,6 +4102,85 @@ namespace Distribution.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.SupplierPayment", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<decimal>("Amount")
|
||||
.HasPrecision(18, 2)
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid?>("FK_BankAccountId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("FK_ChequePageId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("FK_SupplierId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("Method")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Notes")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("PaidAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid?>("PaidByUserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FK_BankAccountId");
|
||||
|
||||
b.HasIndex("FK_ChequePageId");
|
||||
|
||||
b.HasIndex("FK_SupplierId");
|
||||
|
||||
b.ToTable("SupplierPayments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.SupplierPaymentGRN", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<decimal>("AllocatedAmount")
|
||||
.HasPrecision(18, 2)
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid>("FK_GoodsReceiptId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("FK_SupplierPaymentId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FK_GoodsReceiptId");
|
||||
|
||||
b.HasIndex("FK_SupplierPaymentId");
|
||||
|
||||
b.ToTable("SupplierPaymentGRNs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.SysConfig", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
@@ -4880,13 +4969,25 @@ namespace Distribution.Migrations
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.Payment", b =>
|
||||
{
|
||||
b.HasOne("Distribution.Models.BankAccount", "BankAccount")
|
||||
.WithMany()
|
||||
.HasForeignKey("FK_BankAccountId");
|
||||
|
||||
b.HasOne("Distribution.Models.Invoice", "Invoice")
|
||||
.WithMany("Payments")
|
||||
.HasForeignKey("FK_InvoiceId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Distribution.Models.ReceivedCheque", "ReceivedCheque")
|
||||
.WithMany()
|
||||
.HasForeignKey("FK_ReceivedChequeId");
|
||||
|
||||
b.Navigation("BankAccount");
|
||||
|
||||
b.Navigation("Invoice");
|
||||
|
||||
b.Navigation("ReceivedCheque");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.PriceList", b =>
|
||||
@@ -5361,6 +5462,50 @@ namespace Distribution.Migrations
|
||||
b.Navigation("SupplierClaim");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.SupplierPayment", b =>
|
||||
{
|
||||
b.HasOne("Distribution.Models.BankAccount", "BankAccount")
|
||||
.WithMany()
|
||||
.HasForeignKey("FK_BankAccountId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("Distribution.Models.ChequePage", "ChequePage")
|
||||
.WithMany()
|
||||
.HasForeignKey("FK_ChequePageId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("Distribution.Models.Supplier", "Supplier")
|
||||
.WithMany()
|
||||
.HasForeignKey("FK_SupplierId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("BankAccount");
|
||||
|
||||
b.Navigation("ChequePage");
|
||||
|
||||
b.Navigation("Supplier");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.SupplierPaymentGRN", b =>
|
||||
{
|
||||
b.HasOne("Distribution.Models.GoodsReceipt", "GoodsReceipt")
|
||||
.WithMany()
|
||||
.HasForeignKey("FK_GoodsReceiptId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Distribution.Models.SupplierPayment", "SupplierPayment")
|
||||
.WithMany("Allocations")
|
||||
.HasForeignKey("FK_SupplierPaymentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("GoodsReceipt");
|
||||
|
||||
b.Navigation("SupplierPayment");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.UomConversion", b =>
|
||||
{
|
||||
b.HasOne("Distribution.Models.Uom", "FromUom")
|
||||
@@ -5550,6 +5695,11 @@ namespace Distribution.Migrations
|
||||
{
|
||||
b.Navigation("Items");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.SupplierPayment", b =>
|
||||
{
|
||||
b.Navigation("Allocations");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,16 @@ namespace Distribution.Models
|
||||
public DateTime CollectedAt { get; set; }
|
||||
public Guid CollectedBy { get; set; }
|
||||
public Guid? RecordedBy { get; set; }
|
||||
|
||||
// Cash/Bank account that received the funds. Required when Method = Cash;
|
||||
// for Cheque, the FK_ReceivedCheque below carries the deposit account once deposited.
|
||||
public Guid? FK_BankAccountId { get; set; }
|
||||
[ForeignKey("FK_BankAccountId")]
|
||||
public BankAccount? BankAccount { get; set; }
|
||||
|
||||
// Cheque record auto-created when Method = Cheque. Null for Cash/Credit payments.
|
||||
public Guid? FK_ReceivedChequeId { get; set; }
|
||||
[ForeignKey("FK_ReceivedChequeId")]
|
||||
public ReceivedCheque? ReceivedCheque { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Distribution.Models
|
||||
{
|
||||
public class ReceivedCheque : Template
|
||||
{
|
||||
public int CompanyId { get; set; }
|
||||
public int? CompanyId { get; set; }
|
||||
public int? BranchId { get; set; }
|
||||
|
||||
public ReceivedFromType ReceivedFromType { get; set; }
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Distribution.Models
|
||||
{
|
||||
public class SupplierPayment : Template
|
||||
{
|
||||
public Guid FK_SupplierId { get; set; }
|
||||
[ForeignKey("FK_SupplierId")]
|
||||
public Supplier? Supplier { get; set; }
|
||||
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
// Only Cash or Cheque are valid for outgoing payments. Credit is rejected at the service layer.
|
||||
public PaymentMethod Method { get; set; }
|
||||
|
||||
// Cash: required. Null for Cheque.
|
||||
public Guid? FK_BankAccountId { get; set; }
|
||||
[ForeignKey("FK_BankAccountId")]
|
||||
public BankAccount? BankAccount { get; set; }
|
||||
|
||||
// Cheque: required — the ChequePage this payment issued. Null for Cash.
|
||||
public Guid? FK_ChequePageId { get; set; }
|
||||
[ForeignKey("FK_ChequePageId")]
|
||||
public ChequePage? ChequePage { get; set; }
|
||||
|
||||
public DateTime PaidAt { get; set; }
|
||||
public Guid? PaidByUserId { get; set; }
|
||||
public string? Notes { get; set; }
|
||||
|
||||
public ICollection<SupplierPaymentGRN> Allocations { get; set; } = [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Models
|
||||
{
|
||||
public class SupplierPaymentGRN : Template
|
||||
{
|
||||
public Guid FK_SupplierPaymentId { get; set; }
|
||||
[ForeignKey("FK_SupplierPaymentId")]
|
||||
public SupplierPayment? SupplierPayment { get; set; }
|
||||
|
||||
public Guid FK_GoodsReceiptId { get; set; }
|
||||
[ForeignKey("FK_GoodsReceiptId")]
|
||||
public GoodsReceipt? GoodsReceipt { get; set; }
|
||||
|
||||
[Precision(18, 2)]
|
||||
public decimal AllocatedAmount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ using Distribution.Features.Route;
|
||||
using Distribution.Features.Scheme;
|
||||
using Distribution.Features.Store;
|
||||
using Distribution.Features.Supplier;
|
||||
using Distribution.Features.SupplierPayment;
|
||||
using Distribution.Features.Sync;
|
||||
using Distribution.Features.Uom;
|
||||
using Distribution.Features.User;
|
||||
@@ -98,6 +99,7 @@ builder.Services.AddScoped<IPaymentRepository, PaymentRepository>();
|
||||
builder.Services.AddScoped<IBankAccountRepository, BankAccountRepository>();
|
||||
builder.Services.AddScoped<IChequeBookRepository, ChequeBookRepository>();
|
||||
builder.Services.AddScoped<IReceivedChequeRepository, ReceivedChequeRepository>();
|
||||
builder.Services.AddScoped<ISupplierPaymentRepository, SupplierPaymentRepository>();
|
||||
|
||||
builder.Services.AddScoped<RegionService>();
|
||||
builder.Services.AddScoped<RouteService>();
|
||||
@@ -136,6 +138,7 @@ builder.Services.AddScoped<PaymentService>();
|
||||
builder.Services.AddScoped<BankAccountService>();
|
||||
builder.Services.AddScoped<ChequeBookService>();
|
||||
builder.Services.AddScoped<ReceivedChequeService>();
|
||||
builder.Services.AddScoped<SupplierPaymentService>();
|
||||
builder.Services.AddScoped<SysConfigService>();
|
||||
|
||||
builder.Services.AddMemoryCache();
|
||||
|
||||
+353
@@ -0,0 +1,353 @@
|
||||
'use client'
|
||||
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
|
||||
import {
|
||||
bankAccounts as bankAccountsApi,
|
||||
chequeBooks as chequeBooksApi,
|
||||
getApiError,
|
||||
grn as grnApi,
|
||||
suppliers as suppliersApi,
|
||||
supplierPayments as supplierPaymentsApi,
|
||||
} from '@/lib/api/index'
|
||||
import type { GrnResponse, SupplierResponse } from '@/types/api'
|
||||
import {
|
||||
BankAccountType,
|
||||
ChequePageIssueStatus,
|
||||
type BankAccountResponse,
|
||||
type ChequeBookResponse,
|
||||
type ChequePageResponse,
|
||||
type CreateSupplierPaymentRequest,
|
||||
type SupplierPaymentAllocation,
|
||||
type SupplierPaymentResponse,
|
||||
} from '@/types/payments'
|
||||
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, 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 { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
||||
import { toast } from '@/components/ui/toast'
|
||||
|
||||
function formatDate(value: string) {
|
||||
return new Date(value).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' })
|
||||
}
|
||||
|
||||
function formatMoney(value: number) {
|
||||
return value.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
}
|
||||
|
||||
export function SupplierPaymentsClient({ supplierId }: { supplierId: string }) {
|
||||
const [supplier, setSupplier] = useState<SupplierResponse | null>(null)
|
||||
const [payments, setPayments] = useState<SupplierPaymentResponse[]>([])
|
||||
const [total, setTotal] = useState(0)
|
||||
const [page, setPage] = useState(1)
|
||||
const [pageSize] = useState(20)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [createOpen, setCreateOpen] = useState(false)
|
||||
|
||||
const loadPayments = useCallback(async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
const result = await supplierPaymentsApi.list(supplierId, { page, pageSize })
|
||||
setPayments(result.items)
|
||||
setTotal(result.total)
|
||||
} catch (err) {
|
||||
toast.add({ title: 'Failed to load payments', description: getApiError(err), type: 'error' })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [supplierId, page, pageSize])
|
||||
|
||||
useEffect(() => {
|
||||
suppliersApi.get(supplierId).then(setSupplier).catch(() => {})
|
||||
}, [supplierId])
|
||||
|
||||
useEffect(() => { loadPayments() }, [loadPayments])
|
||||
|
||||
const pageCount = Math.max(1, Math.ceil(total / pageSize))
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold text-foreground">Supplier Payments</h1>
|
||||
<p className="text-sm text-muted-foreground mt-0.5">
|
||||
{supplier ? supplier.name : 'Supplier'} — outgoing payments against received GRNs
|
||||
</p>
|
||||
</div>
|
||||
<Button onClick={() => setCreateOpen(true)}>Record Payment</Button>
|
||||
</div>
|
||||
|
||||
<div className="rounded-md border mt-4">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Paid At</TableHead>
|
||||
<TableHead>Method</TableHead>
|
||||
<TableHead className="text-right">Amount</TableHead>
|
||||
<TableHead>Cheque / Account</TableHead>
|
||||
<TableHead className="text-right">GRNs</TableHead>
|
||||
<TableHead>Notes</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{loading ? (
|
||||
<TableRow><TableCell colSpan={6}>Loading…</TableCell></TableRow>
|
||||
) : payments.length === 0 ? (
|
||||
<TableRow><TableCell colSpan={6}>No payments yet.</TableCell></TableRow>
|
||||
) : (
|
||||
payments.map(p => (
|
||||
<TableRow key={p.id}>
|
||||
<TableCell>{formatDate(p.paidAt)}</TableCell>
|
||||
<TableCell><Badge variant="secondary">{p.method}</Badge></TableCell>
|
||||
<TableCell className="text-right font-mono">{formatMoney(p.amount)}</TableCell>
|
||||
<TableCell className="text-xs">
|
||||
{p.method === 'Cheque' ? (p.chequeNo ?? '—') : (p.bankAccountId ?? '—')}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">{p.allocations.length}</TableCell>
|
||||
<TableCell className="text-sm text-muted-foreground">{p.notes ?? '—'}</TableCell>
|
||||
</TableRow>
|
||||
))
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between mt-3 text-sm">
|
||||
<span className="text-muted-foreground">{total} payment(s)</span>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" size="sm" disabled={page <= 1} onClick={() => setPage(p => p - 1)}>Prev</Button>
|
||||
<span className="px-2 py-1">{page} / {pageCount}</span>
|
||||
<Button variant="outline" size="sm" disabled={page >= pageCount} onClick={() => setPage(p => p + 1)}>Next</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{createOpen && (
|
||||
<CreatePaymentDialog
|
||||
supplierId={supplierId}
|
||||
onClose={() => setCreateOpen(false)}
|
||||
onCreated={() => { setCreateOpen(false); loadPayments() }}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
interface AllocationDraft {
|
||||
goodsReceiptId: string
|
||||
allocatedAmount: string
|
||||
}
|
||||
|
||||
function CreatePaymentDialog({
|
||||
supplierId,
|
||||
onClose,
|
||||
onCreated,
|
||||
}: {
|
||||
supplierId: string
|
||||
onClose: () => void
|
||||
onCreated: () => void
|
||||
}) {
|
||||
const [method, setMethod] = useState<'Cash' | 'Cheque'>('Cash')
|
||||
const [amount, setAmount] = useState('')
|
||||
const [notes, setNotes] = useState('')
|
||||
const [bankAccountId, setBankAccountId] = useState<string>('')
|
||||
const [chequePageId, setChequePageId] = useState<string>('')
|
||||
const [allocations, setAllocations] = useState<AllocationDraft[]>([{ goodsReceiptId: '', allocatedAmount: '' }])
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
|
||||
const [grns, setGrns] = useState<GrnResponse[]>([])
|
||||
const [accounts, setAccounts] = useState<BankAccountResponse[]>([])
|
||||
const [unusedPages, setUnusedPages] = useState<ChequePageResponse[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
grnApi.list({ page: 1, pageSize: 100 })
|
||||
.then(r => setGrns(r.items.filter(g => g.supplierId === supplierId)))
|
||||
.catch(err => toast.add({ title: 'Failed to load GRNs', description: getApiError(err), type: 'error' }))
|
||||
|
||||
bankAccountsApi.list()
|
||||
.then(list => setAccounts(list.filter(a => a.isActive !== false)))
|
||||
.catch(() => {})
|
||||
}, [supplierId])
|
||||
|
||||
useEffect(() => {
|
||||
if (method !== 'Cheque') return
|
||||
chequeBooksApi.list({ status: 'Active' as never, page: 1, pageSize: 50 })
|
||||
.then(async res => {
|
||||
const expanded = await Promise.all(res.items.map((b: ChequeBookResponse) => chequeBooksApi.get(b.chequeBookNo, true)))
|
||||
const pages: ChequePageResponse[] = []
|
||||
expanded.forEach(book => {
|
||||
book.pages
|
||||
.filter(p => p.issueStatus === ChequePageIssueStatus.Unused)
|
||||
.forEach(p => pages.push(p))
|
||||
})
|
||||
setUnusedPages(pages)
|
||||
})
|
||||
.catch(err => toast.add({ title: 'Failed to load cheque pages', description: getApiError(err), type: 'error' }))
|
||||
}, [method])
|
||||
|
||||
const allocationTotal = useMemo(
|
||||
() => allocations.reduce((sum, a) => sum + (parseFloat(a.allocatedAmount) || 0), 0),
|
||||
[allocations],
|
||||
)
|
||||
|
||||
const amountNum = parseFloat(amount) || 0
|
||||
const mismatch = Math.abs(allocationTotal - amountNum) > 0.001
|
||||
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault()
|
||||
if (amountNum <= 0) { toast.add({ title: 'Amount must be greater than zero', type: 'error' }); return }
|
||||
if (mismatch) { toast.add({ title: `Allocation total (${formatMoney(allocationTotal)}) must equal amount (${formatMoney(amountNum)})`, type: 'error' }); return }
|
||||
|
||||
const cleanAllocations: SupplierPaymentAllocation[] = allocations
|
||||
.filter(a => a.goodsReceiptId && a.allocatedAmount)
|
||||
.map(a => ({ goodsReceiptId: a.goodsReceiptId, allocatedAmount: parseFloat(a.allocatedAmount) }))
|
||||
|
||||
if (cleanAllocations.length === 0) { toast.add({ title: 'Add at least one GRN allocation', type: 'error' }); return }
|
||||
|
||||
const body: CreateSupplierPaymentRequest = {
|
||||
amount: amountNum,
|
||||
method,
|
||||
allocations: cleanAllocations,
|
||||
notes: notes || undefined,
|
||||
bankAccountId: method === 'Cash' ? bankAccountId || undefined : undefined,
|
||||
chequePageId: method === 'Cheque' ? chequePageId || undefined : undefined,
|
||||
}
|
||||
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await supplierPaymentsApi.create(supplierId, body)
|
||||
toast.add({ title: 'Payment recorded', type: 'success' })
|
||||
onCreated()
|
||||
} catch (err) {
|
||||
toast.add({ title: 'Failed to record payment', description: getApiError(err), type: 'error' })
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open onOpenChange={v => { if (!v) onClose() }}>
|
||||
<DialogContent className="max-w-2xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Record Supplier Payment</DialogTitle>
|
||||
<DialogDescription>
|
||||
Allocate the payment across one or more GRNs. Allocation total must equal the paid amount.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Field>
|
||||
<FieldLabel>Amount</FieldLabel>
|
||||
<Input type="number" step="0.01" value={amount} onChange={e => setAmount(e.target.value)} required />
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>Method</FieldLabel>
|
||||
<Select value={method} onValueChange={v => setMethod((v ?? 'Cash') as 'Cash' | 'Cheque')}>
|
||||
<SelectTrigger><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="Cash">Cash</SelectItem>
|
||||
<SelectItem value="Cheque">Cheque</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
{method === 'Cash' && (
|
||||
<Field>
|
||||
<FieldLabel>Bank / Cash Account</FieldLabel>
|
||||
<Select value={bankAccountId} onValueChange={v => setBankAccountId(v ?? '')}>
|
||||
<SelectTrigger><SelectValue placeholder="Choose account" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
{accounts.map(a => (
|
||||
<SelectItem key={a.accountId} value={a.accountId}>
|
||||
{a.accountName}
|
||||
{a.accountType === BankAccountType.Bank && a.bankName ? ` (${a.bankName})` : ''}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
)}
|
||||
|
||||
{method === 'Cheque' && (
|
||||
<Field>
|
||||
<FieldLabel>Cheque Page</FieldLabel>
|
||||
<Select value={chequePageId} onValueChange={v => setChequePageId(v ?? '')}>
|
||||
<SelectTrigger><SelectValue placeholder="Pick an unused cheque page" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
{unusedPages.map(p => (
|
||||
<SelectItem key={p.id} value={p.id}>
|
||||
{p.chequeBookNo} / {p.chequeNo}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<FieldLabel>GRN Allocations</FieldLabel>
|
||||
<Button
|
||||
type="button" size="sm" variant="outline"
|
||||
onClick={() => setAllocations(a => [...a, { goodsReceiptId: '', allocatedAmount: '' }])}
|
||||
>
|
||||
Add GRN
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
{allocations.map((a, i) => (
|
||||
<div key={i} className="grid grid-cols-[1fr,180px,80px] gap-2 items-start">
|
||||
<Select
|
||||
value={a.goodsReceiptId}
|
||||
onValueChange={v => setAllocations(prev => prev.map((x, idx) => idx === i ? { ...x, goodsReceiptId: v ?? '' } : x))}
|
||||
>
|
||||
<SelectTrigger><SelectValue placeholder="Pick a GRN" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
{grns.map(g => (
|
||||
<SelectItem key={g.id} value={g.id}>
|
||||
GRN {g.id.slice(0, 8)} — {formatDate(g.receivedAt)} — total {formatMoney(g.totalAmount)}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Input
|
||||
type="number" step="0.01" placeholder="Amount"
|
||||
value={a.allocatedAmount}
|
||||
onChange={e => setAllocations(prev => prev.map((x, idx) => idx === i ? { ...x, allocatedAmount: e.target.value } : x))}
|
||||
/>
|
||||
<Button
|
||||
type="button" variant="ghost" size="sm"
|
||||
disabled={allocations.length === 1}
|
||||
onClick={() => setAllocations(prev => prev.filter((_, idx) => idx !== i))}
|
||||
>
|
||||
Remove
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className={`text-sm mt-2 ${mismatch ? 'text-destructive' : 'text-muted-foreground'}`}>
|
||||
Allocation total: {formatMoney(allocationTotal)} {mismatch && amount ? `(mismatch with amount ${formatMoney(amountNum)})` : ''}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Field>
|
||||
<FieldLabel>Notes</FieldLabel>
|
||||
<Input value={notes} onChange={e => setNotes(e.target.value)} placeholder="Optional" />
|
||||
</Field>
|
||||
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" onClick={onClose}>Cancel</Button>
|
||||
<Button type="submit" disabled={submitting}>{submitting ? 'Saving…' : 'Record Payment'}</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { SupplierPaymentsClient } from './_components/supplier-payments-client'
|
||||
|
||||
export default async function SupplierPaymentsPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ id: string }>
|
||||
}) {
|
||||
const { id } = await params
|
||||
return <SupplierPaymentsClient supplierId={id} />
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect, useCallback, useMemo } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { HugeiconsIcon } from '@hugeicons/react'
|
||||
import { Add01Icon } from '@hugeicons/core-free-icons'
|
||||
|
||||
@@ -16,6 +17,7 @@ import { SupplierSheet } from './supplier-sheet'
|
||||
import { SupplierViewSheet } from './supplier-view-sheet'
|
||||
|
||||
export function SuppliersClient() {
|
||||
const router = useRouter()
|
||||
const [data, setData] = useState<SupplierResponse[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [pageSize, setPageSize] = useState(20)
|
||||
@@ -125,6 +127,11 @@ export function SuppliersClient() {
|
||||
label: 'Edit supplier',
|
||||
onClick: openEdit,
|
||||
},
|
||||
{
|
||||
action: 'view',
|
||||
label: 'Payments',
|
||||
onClick: (s: SupplierResponse) => router.push(`/suppliers/${s.id}/payments`),
|
||||
},
|
||||
{
|
||||
action: 'cancel',
|
||||
label: 'Delete supplier',
|
||||
|
||||
@@ -15,6 +15,7 @@ export { sysConfig, ITEM_TRACKING_KEYS, GRN_TAX_KEYS, grnTaxSettings, DEFAULT_GR
|
||||
export { bankAccounts } from './bank-accounts'
|
||||
export { chequeBooks, chequePages } from './cheques'
|
||||
export { receivedCheques } from './received-cheques'
|
||||
export { supplierPayments } from './supplier-payments'
|
||||
export { getPaginatedItems } from './paginated'
|
||||
|
||||
export type { PageParams } from './master'
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { api } from '@/lib/api'
|
||||
import type {
|
||||
CreateSupplierPaymentRequest,
|
||||
PagedSupplierPaymentsResponse,
|
||||
SupplierPaymentResponse,
|
||||
} from '@/types/payments'
|
||||
|
||||
export const supplierPayments = {
|
||||
list: (supplierId: string, params?: { page?: number; pageSize?: number }) =>
|
||||
api
|
||||
.get<PagedSupplierPaymentsResponse>(`/suppliers/${supplierId}/payments`, { params })
|
||||
.then(r => r.data),
|
||||
|
||||
create: (supplierId: string, body: CreateSupplierPaymentRequest) =>
|
||||
api
|
||||
.post<SupplierPaymentResponse>(`/suppliers/${supplierId}/payments`, body)
|
||||
.then(r => r.data),
|
||||
}
|
||||
@@ -69,6 +69,7 @@ export enum PayeeType {
|
||||
}
|
||||
|
||||
export interface ChequePageResponse {
|
||||
id: string
|
||||
chequeNo: string
|
||||
chequeBookNo: string
|
||||
issueStatus: ChequePageIssueStatus
|
||||
@@ -221,3 +222,42 @@ export interface UpdateReceivedChequeStatusRequest {
|
||||
notes?: string
|
||||
performedBy?: string
|
||||
}
|
||||
|
||||
// Supplier Payments
|
||||
|
||||
export interface SupplierPaymentAllocation {
|
||||
goodsReceiptId: string
|
||||
allocatedAmount: number
|
||||
}
|
||||
|
||||
export interface SupplierPaymentResponse {
|
||||
id: string
|
||||
supplierId: string
|
||||
amount: number
|
||||
method: 'Cash' | 'Cheque'
|
||||
bankAccountId: string | null
|
||||
chequePageId: string | null
|
||||
chequeNo: string | null
|
||||
paidAt: string
|
||||
paidByUserId: string | null
|
||||
notes: string | null
|
||||
allocations: SupplierPaymentAllocation[]
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export interface PagedSupplierPaymentsResponse {
|
||||
items: SupplierPaymentResponse[]
|
||||
page: number
|
||||
pageSize: number
|
||||
total: number
|
||||
}
|
||||
|
||||
export interface CreateSupplierPaymentRequest {
|
||||
amount: number
|
||||
method: 'Cash' | 'Cheque'
|
||||
allocations: SupplierPaymentAllocation[]
|
||||
bankAccountId?: string
|
||||
chequePageId?: string
|
||||
notes?: string
|
||||
paidByUserId?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user