Files
PowderCoatingLogix/src/PowderCoating.Application/Interfaces/IAccountBalanceService.cs
T
2026-04-23 21:38:24 -04:00

34 lines
1.4 KiB
C#

namespace PowderCoating.Application.Interfaces;
/// <summary>
/// Keeps Account.CurrentBalance in sync with double-entry transactions.
/// DebitAsync / CreditAsync update the balance in the normal-balance direction
/// for each account sub-type, but do NOT call CompleteAsync — the caller must
/// persist by calling IUnitOfWork.CompleteAsync / CommitTransactionAsync.
/// RecalculateAllAsync is the exception: it saves internally and is safe to call standalone.
/// </summary>
public interface IAccountBalanceService
{
/// <summary>
/// Applies a debit to the account.
/// Debit-normal accounts (Asset / Expense / COGS): balance increases.
/// Credit-normal accounts (Liability / Equity / Revenue): balance decreases.
/// No-op when accountId is null or amount is zero.
/// </summary>
Task DebitAsync(int? accountId, decimal amount);
/// <summary>
/// Applies a credit to the account.
/// Debit-normal accounts: balance decreases.
/// Credit-normal accounts: balance increases.
/// No-op when accountId is null or amount is zero.
/// </summary>
Task CreditAsync(int? accountId, decimal amount);
/// <summary>
/// Recomputes CurrentBalance for every active account in the company by replaying all
/// transactions through LedgerService. Saves internally. Use after import or to fix drift.
/// </summary>
Task RecalculateAllAsync(int companyId);
}