diff --git a/Marco.Pms.Services/Service/PurchaseInvoiceService.cs b/Marco.Pms.Services/Service/PurchaseInvoiceService.cs index 6e138b0..f973b75 100644 --- a/Marco.Pms.Services/Service/PurchaseInvoiceService.cs +++ b/Marco.Pms.Services/Service/PurchaseInvoiceService.cs @@ -1535,8 +1535,8 @@ namespace Marco.Pms.Services.Service var alreadyPaidAmount = existingPayments.Sum(pi => pi.Amount); var proposedTotalPaidAmount = alreadyPaidAmount + model.Amount; - - if (proposedTotalPaidAmount > purchaseInvoice.TotalAmount) + bool proformaCheck = purchaseInvoice.ProformaInvoiceAmount.HasValue ? proposedTotalPaidAmount > purchaseInvoice.ProformaInvoiceAmount : true; + if (proposedTotalPaidAmount > purchaseInvoice.TotalAmount && proformaCheck) { _logger.LogWarning("Attempt to add payment exceeding invoice total. InvoiceId: {InvoiceId}, TenantId: {TenantId}, InvoiceTotal: {InvoiceTotal}, AlreadyPaid: {AlreadyPaid}, NewAmount: {NewAmount}, ProposedTotal: {ProposedTotal}", model.InvoiceId, tenantId, purchaseInvoice.TotalAmount, alreadyPaidAmount, model.Amount, proposedTotalPaidAmount);