Ejemplo n.º 1
0
 public PrintPreviewWindowVM(ChequeVoucherDTO dto, ITenantDBsDir dir) //: base(dto, dir)
 {
     AppArgs     = dir;
     CurrentItem = dto;
     AllocationTotals.SetItems(GetAllocationsSummary(dto));
     ReviewerName = Default.ReviewerName;
     ApproverName = Default.ApproverName;
 }
Ejemplo n.º 2
0
        public void SetAs_Cancelled(ChequeVoucherDTO chq)
        {
            var req = FindInactiveRequest(chq);

            req.ChequeStatus = ChequeState.Cancelled;
            InactiveRequests.Update(req);
            PreparedCheques.Delete(chq);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public void SetAs_Unprepared(ChequeVoucherDTO chq)
        {
            PreparedCheques.Delete(chq);
            var req = FindInactiveRequest(chq);

            InactiveRequests.Delete(req);
            req.Id = 0;
            ActiveRequests.Insert(req);
        }
Ejemplo n.º 5
0
        //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);
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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),
        };
Ejemplo n.º 9
0
        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());
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        public static void Preview(ChequeVoucherDTO dto, ITenantDBsDir dir)
        {
            var vm = new PrintPreviewWindowVM(dto, dir);

            PrintPreviewer2.Preview(vm).On <PrintLayout1>();
        }
Ejemplo n.º 12
0
 private IEnumerable <AccountAllocation> GetAllocationsSummary(ChequeVoucherDTO dto)
 => new List <AccountAllocation>
 {
     new AllocationsTotal(dto.Request.Allocations)
 };
Ejemplo n.º 13
0
 public void SetAs_Issued(ChequeVoucherDTO dto, DateTime issuedDate, string issuedTo)
 {
     dto.IssuedDate = issuedDate;
     dto.IssuedTo   = issuedTo;
     PreparedCheques.Update(dto);
 }
Ejemplo n.º 14
0
 public void SetAs_TakenBack(ChequeVoucherDTO cheque)
 {
     cheque.IssuedDate = null;
     cheque.IssuedTo   = string.Empty;
     PreparedCheques.Update(cheque);
 }