private FundRequestDTO ToInactive(FundRequestDTO orig)
        {
            var inactv = orig.ShallowClone <FundRequestDTO>();

            inactv.Id = 0;
            return(inactv);
        }
        private static bool IsBuggy(FundRequestDTO req, out AccountAllocation bdo1Alloc)
        {
            bdo1Alloc = null;
            //if (req.IsBalanced) return false;
            if (req.Allocations == null)
            {
                return(false);
            }
            if (!req.Allocations.Any())
            {
                return(false);
            }

            //Cash in Bank - BDO 1
            var matches = req.Allocations.Where(_
                                                => _.Account.Id == 37282);

            if (!matches.Any())
            {
                return(false);
            }
            if (matches.Count() > 1)
            {
                return(false);
            }

            bdo1Alloc = matches.Single();
            return(true);
        }
 public void DisplayItems(FundRequestDTO req)
 {
     Items.Clear();
     Items.Add(AllocationVM.CashInBank(_arg.AccountName));
     req.Allocations?.ForEach(_
                              => Items.Add(new AllocationVM(_)));
     CanAddItem = false;
 }
 public void SetAs_Prepared(FundRequestDTO request,
                            DateTime chequeDate, int chequeNumber)
 {
     PreparedCheques.Insert(new ChequeVoucherDTO
     {
         Request      = request,
         ChequeDate   = chequeDate,
         ChequeNumber = chequeNumber,
     });
     InactiveRequests.Insert(ToInactive(request));
     ActiveRequests.Delete(request);
 }
Exemple #5
0
 public static void ToPreparedCheque(this PassbookDB pbk, FundRequestDTO req, int chequeNumber, DateTime chequeDate)
 {
     //if (ChequeExists(chequeNumber, pbk)) return;
     pbk.ActiveCheques.Insert(new RequestedChequeDTO
     {
         Request      = req,
         ChequeNumber = chequeNumber,
         ChequeDate   = chequeDate,
     });
     pbk.InactiveRequests.Insert(req);
     pbk.ActiveRequests.Delete(req);
 }
Exemple #6
0
        private bool IsWithinDates(FundRequestDTO req, GLRecapReport main)
        {
            var date = req.RequestDate.Date;

            if (date < main.StartDate)
            {
                return(false);
            }
            if (date > main.EndDate)
            {
                return(false);
            }
            return(true);
        }
Exemple #7
0
        private static GLRecapAllocation CreateAllocation(decimal amount, string label, GLAccountDTO acct, DateTime date)
        {
            var alloc = new AccountAllocation
            {
                Account   = acct,
                SubAmount = amount
            };
            var req = new FundRequestDTO
            {
                Purpose    = label,
                DateOffset = date.DaysSinceMin(),
            };

            return(new GLRecapAllocation(alloc, req));
        }
        private static int GetBankAcctId(FundRequestDTO hdr, MainWindowVM2 main)
        {
            var cache = main.ByfCache;

            foreach (var row in hdr.Allocations)
            {
                //if (row.IsDebit) continue;
                var glAcct    = row.Account.Id;
                var bnkAcctId = cache.BankAcctByGlAcct.GetOrDefault(glAcct);
                if (bnkAcctId != 0)
                {
                    return(bnkAcctId);
                }
            }
            //throw Bad.Data($"No valid bank acct row from voucher items [hdr:{hdr.Id}].");
            return(0);
        }
        private static ChequeVoucherDTO CastAsCheckDTO(dynamic byf, ByfCache cache)
        {
            var req = new FundRequestDTO
            {
                Id           = As.ID(byf.nid),
                Amount       = As.Decimal_(byf.checkamountactual),
                SerialNum    = As.ID_(byf.serial) ?? 0,
                DateOffset   = As.DateOffset(byf.requestdate),
                Payee        = (string)As.Text(byf.adhocpayee),
                Purpose      = As.Text(byf.description),
                Remarks      = As.Text(byf.remarks),
                ChequeStatus = GetChequeStatus(byf),
                Allocations  = new List <AccountAllocation>()
            };

            var cleared = (DateTime?)As.Date_(byf.cleareddate);

            if (cleared.HasValue)
            {
                cache.ClearedDatesById[req.Id] = cleared.Value;
            }

            if (req.Payee.IsBlank())
            {
                req.Payee = cache.PayeeById(As.ID(byf.savedpayeenid));
            }

            return(new ChequeVoucherDTO
            {
                Id = req.Id,
                Request = req,
                ChequeDate = As.Date_(byf.checkdate) ?? DateTime.MinValue,
                ChequeNumber = As.ID_(byf.checknumber) ?? 0,
                IssuedDate = As.Date_(byf.issueddate),
                IssuedTo = As.Text(byf.issuedto),
                Remarks = req.Remarks,
            });
        }
 public static void Preview(FundRequestDTO req, ITenantDBsDir dir)
 => Preview(new ChequeVoucherDTO {
     Request = req
 }, dir);
Exemple #11
0
 public static bool HasCashInBankEntry(this FundRequestDTO req)
 => req?.Allocations?.HasCashInBankEntry() ?? false;
Exemple #12
0
 public GLRecapAllocation(AccountAllocation alloc, FundRequestDTO req)
 {
     Account   = alloc.Account;
     SubAmount = alloc.SubAmount;
     Request   = req;
 }
Exemple #13
0
 private static void SetRequestOffset(FundRequestDTO req)
 => req.DateOffset = req.RequestDate.DaysSinceMin();