public PrintPreviewWindowVM(ChequeVoucherDTO dto, ITenantDBsDir dir) //: base(dto, dir) { AppArgs = dir; CurrentItem = dto; AllocationTotals.SetItems(GetAllocationsSummary(dto)); ReviewerName = Default.ReviewerName; ApproverName = Default.ApproverName; }
public void SetAs_Cancelled(ChequeVoucherDTO chq) { var req = FindInactiveRequest(chq); req.ChequeStatus = ChequeState.Cancelled; InactiveRequests.Update(req); PreparedCheques.Delete(chq); }
public void SetAs_Cleared(ChequeVoucherDTO chq, DateTime date) { var passbk = PassbookRows.GetRepo(chq.Request.BankAccountId); passbk.InsertClearedCheque(chq, date); passbk.RecomputeBalancesFrom(date); PreparedCheques.Delete(chq); }
public void SetAs_Unprepared(ChequeVoucherDTO chq) { PreparedCheques.Delete(chq); var req = FindInactiveRequest(chq); InactiveRequests.Delete(req); req.Id = 0; ActiveRequests.Insert(req); }
//private PassbookRowDTO FindPassbookRow(out IPassbookRowsRepo repo) //{ // var bankId = DTO.Request.BankAccountId; // repo = AppArgs.Passbooks.GetRepo(bankId); // var rows = repo.RowsFor(ClearedDate.Value); // if (rows == null) return null; // if (!rows.Any()) return null; // var match = rows.SingleOrDefault(_ => _.DocRefId == DTO.Id); // if (match == null) throw No.Match<ChequeVoucherDTO>("Id", DTO.Id); // return match; //} public static ChequeVoucherViewerVM Show(ChequeVoucherDTO dto, ITenantDBsDir dir, bool launchWindow = true) { var vm = new ChequeVoucherViewerVM(dto, dir); if (launchWindow) { vm.Show <ChequeVoucherViewerWindow>(); } return(vm); }
public ChequeVoucherViewerVM(ChequeVoucherDTO chequeVoucherDTO, ITenantDBsDir tenantDBsDir) : base(tenantDBsDir) { DTO = chequeVoucherDTO; //ClearedDate = clearedDate; EditClearedDateCmd = R2Command.Relay(EditClearedDate, _ => CanEditClearedDate(), "Edit Cleared Date"); if (!DTO.Request.HasCashInBankEntry()) { DTO.Request.Allocations.AddCashInBankEntry(AppArgs.CurrentBankAcct, DTO.Request.Amount.Value); } }
public void InsertClearedCheque(ChequeVoucherDTO cheque, DateTime clearedDate) { var whyNot = cheque.WhyInvalidForSetAsCleared(BankAccountID); if (!whyNot.IsBlank()) { throw Bad.Insert(cheque, whyNot); } var repo = FindRepo(clearedDate); var row = cheque.ToPassbookRow(clearedDate); repo.Insert(row); }
public static PassbookRowDTO ToPassbookRow (this ChequeVoucherDTO chq, DateTime clearedDate) => new PassbookRowDTO { DateOffset = clearedDate.DaysSinceMin(), TransactionRef = $"{chq.ChequeNumber}", Subject = $"Cheque for {chq.Request.Payee}", Description = chq.Request.Purpose, Amount = chq.Request.Amount.Value * -1M, DocRefType = chq.GetType().FullName, DocRefId = chq.Id, DocRefJson = chq.ToJson(true), };
private FundRequestDTO FindInactiveRequest(ChequeVoucherDTO chq) { var matches = InactiveRequests.Find(_ => _.SerialNum == chq.Request.SerialNum); if (!matches.Any()) { //throw No.Match<FundRequestDTO>("SerialNum", chq.Request.SerialNum); InactiveRequests.Insert(chq.Request); return(FindInactiveRequest(chq)); } if (matches.Count() > 1) { throw DuplicateRecordsException.For(matches, "SerialNum", chq.Request.SerialNum); } return(matches.Single()); }
public static string WhyInvalidForSetAsCleared(this ChequeVoucherDTO chequeVoucher, int bankAcctID) { var req = chequeVoucher.Request; if (req == null) { return("Request object should not be NULL."); } if (req.BankAccountId != bankAcctID) { return($"Expected Bank Acct ID to be [{bankAcctID}] but was [{req.BankAccountId}]"); } if (!req.Amount.HasValue) { return("Requested amount should not be blank."); } return(string.Empty); }
public static void Preview(ChequeVoucherDTO dto, ITenantDBsDir dir) { var vm = new PrintPreviewWindowVM(dto, dir); PrintPreviewer2.Preview(vm).On <PrintLayout1>(); }
private IEnumerable <AccountAllocation> GetAllocationsSummary(ChequeVoucherDTO dto) => new List <AccountAllocation> { new AllocationsTotal(dto.Request.Allocations) };
public void SetAs_Issued(ChequeVoucherDTO dto, DateTime issuedDate, string issuedTo) { dto.IssuedDate = issuedDate; dto.IssuedTo = issuedTo; PreparedCheques.Update(dto); }
public void SetAs_TakenBack(ChequeVoucherDTO cheque) { cheque.IssuedDate = null; cheque.IssuedTo = string.Empty; PreparedCheques.Update(cheque); }