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
|
|
@ -20,6 +20,8 @@ namespace Yavsc.Billing
|
|||
|
||||
DateTime? ValidationDate { get; }
|
||||
|
||||
PaymentSummary? PaymentSummary { get; }
|
||||
|
||||
bool GetIsAcquitted ();
|
||||
|
||||
string GetFileBaseName (IBillingService service);
|
||||
|
|
|
|||
8
src/Yavsc.Abstract/Billing/PaymentStatus.cs
Normal file
8
src/Yavsc.Abstract/Billing/PaymentStatus.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
namespace Yavsc.Billing;
|
||||
|
||||
public enum PaymentStatus
|
||||
{
|
||||
Unpaid,
|
||||
PartiallyPaid,
|
||||
Paid
|
||||
}
|
||||
21
src/Yavsc.Abstract/Billing/PaymentSummary.cs
Normal file
21
src/Yavsc.Abstract/Billing/PaymentSummary.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
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;
|
||||
}
|
||||
Loading…
Reference in a new issue