feat(billing): model invoice payment balances and settlement
Persist amounts due and paid, derive partial and full settlement, and protect balances during command updates. Add migration, focused tests and invoicing documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
ed51e62b29
commit
5d03b2e477
13 changed files with 5434 additions and 2 deletions
|
|
@ -58,6 +58,10 @@ namespace Yavsc.Models
|
|||
}
|
||||
builder.UseIdentityByDefaultColumns();
|
||||
|
||||
builder.Entity<NominativeServiceCommand>()
|
||||
.Property(command => command.AmountPaid)
|
||||
.HasDefaultValue(0m);
|
||||
|
||||
builder.Entity<ResourceUsageRecord>(entity =>
|
||||
{
|
||||
entity.HasKey(r => r.Id);
|
||||
|
|
|
|||
|
|
@ -80,9 +80,29 @@ namespace Yavsc.Models.Billing
|
|||
|
||||
public abstract System.Collections.Generic.List<IBillItem> GetBillItems();
|
||||
|
||||
/// <summary>
|
||||
/// Null until an invoice total has been established; never inferred
|
||||
/// from a provisional price or a payment gateway acknowledgement.
|
||||
/// </summary>
|
||||
public decimal? AmountDue { get; private set; }
|
||||
|
||||
public decimal AmountPaid { get; private set; }
|
||||
|
||||
[NotMapped]
|
||||
public PaymentSummary? PaymentSummary => AmountDue.HasValue
|
||||
? new PaymentSummary(AmountDue.Value, AmountPaid)
|
||||
: null;
|
||||
|
||||
public void SetPaymentAmounts(decimal amountDue, decimal amountPaid)
|
||||
{
|
||||
var summary = new PaymentSummary(amountDue, amountPaid);
|
||||
AmountDue = summary.AmountDue;
|
||||
AmountPaid = summary.AmountPaid;
|
||||
}
|
||||
|
||||
public bool GetIsAcquitted()
|
||||
{
|
||||
return Regularization?.IsOk() ?? false;
|
||||
return PaymentSummary?.IsAcquitted ?? false;
|
||||
}
|
||||
|
||||
public string GetFileBaseName(IBillingService billingService)
|
||||
|
|
|
|||
Loading…
Reference in a new issue