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>
21 lines
702 B
C#
21 lines
702 B
C#
namespace Yavsc.Billing;
|
|
|
|
public sealed class PaymentSummary
|
|
{
|
|
public PaymentSummary(decimal amountDue, decimal amountPaid)
|
|
{
|
|
ArgumentOutOfRangeException.ThrowIfNegative(amountDue);
|
|
ArgumentOutOfRangeException.ThrowIfNegative(amountPaid);
|
|
|
|
AmountDue = amountDue;
|
|
AmountPaid = amountPaid;
|
|
}
|
|
|
|
public decimal AmountDue { get; }
|
|
public decimal AmountPaid { get; }
|
|
public decimal AmountRemaining => Math.Max(0m, AmountDue - AmountPaid);
|
|
public bool IsAcquitted => AmountPaid >= AmountDue;
|
|
public PaymentStatus Status => IsAcquitted
|
|
? PaymentStatus.Paid
|
|
: AmountPaid > 0m ? PaymentStatus.PartiallyPaid : PaymentStatus.Unpaid;
|
|
}
|