public void InsertDepositedColxn(BankDepositDTO deposit, DateTime colxnDate) { var whyNot = deposit.WhyInvalidForColxnDeposit(BankAccountID); if (!whyNot.IsBlank()) { throw Bad.Insert(deposit, whyNot); } var repo = FindRepo(deposit.DepositDate); var row = deposit.ToPassbookRow(colxnDate); repo.Insert(row); }
public static PassbookRowDTO ToPassbookRow (this BankDepositDTO dep, DateTime colxnDate) => new PassbookRowDTO { DateOffset = dep.DepositDate.DaysSinceMin(), TransactionRef = dep.DocumentRef, Subject = "Cash Deposit", Description = $"{colxnDate:MMM-d} Market Collections: {dep.Description}", Amount = dep.Amount, DocRefType = dep.GetType().FullName, DocRefId = dep.Id, DocRefJson = dep.ToJson(true), };
public static string WhyInvalidForColxnDeposit(this BankDepositDTO deposit, int bankAcctID) { if (deposit.BankAccount.Id != bankAcctID) { return($"Expected Bank Acct ID to be [{bankAcctID}] but was [{deposit.BankAccount.Id}]"); } if (deposit.DepositDate == DateTime.MinValue) { return("[DepositDate] should not be blank."); } if (deposit.Amount < 0) { return("Deposit amount should be greater than zero."); } return(string.Empty); }