feat: add supplier payment and allocation models, API, and frontend components
- Created `SupplierPayment` and `SupplierPaymentGRN` models for managing supplier payments and their allocations. - Implemented API endpoints for listing and creating supplier payments. - Developed frontend components for displaying and recording supplier payments, including a dialog for payment creation. - Integrated GRN allocations into the payment creation process, ensuring total allocations match the payment amount. - Added pagination and loading states for the payments list.
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user