private decimal CalculatePeriodLedgerAccountBalanceChange(LedgerAccount ledgerAccount, int year, int month) { var periodLedgerTransactionLines = _repository.Get <LedgerTransactionLine>(line => line.LedgerAccountId.Equals(ledgerAccount.Id) && line.LedgerTransaction.PostingDate.Year.Equals(year) && line.LedgerTransaction.PostingDate.Month.Equals(month)); return(LedgerAccountBalanceExtensions.CalculateLedgerTransactionLinesTotal(periodLedgerTransactionLines)); }
public void Can_calculate_ledger_transaction_lines_total() { var transactionLines = new List <LedgerTransactionLine> { new LedgerTransactionLine { LedgerTransactionId = 1, LedgerAccount = new LedgerAccount { Type = LedgerAccountType.Asset }, Amount = 2000, IsDebit = true }, new LedgerTransactionLine { LedgerTransactionId = 1, LedgerAccount = new LedgerAccount { Type = LedgerAccountType.Asset }, Amount = 2000, IsDebit = false }, new LedgerTransactionLine { LedgerTransactionId = 1, LedgerAccount = new LedgerAccount { Type = LedgerAccountType.Liability }, Amount = 2000, IsDebit = true }, new LedgerTransactionLine { LedgerTransactionId = 1, LedgerAccount = new LedgerAccount { Type = LedgerAccountType.Equity }, Amount = 2000, IsDebit = false }, }; var total = LedgerAccountBalanceExtensions.CalculateLedgerTransactionLinesTotal(transactionLines); Assert.Equal(0, total); }