Пример #1
0
        private static decimal GetCashierColxnsTotal(ICollectionsDB db)
        {
            var all = db.CashierColxns.GetAll();
            var sum = all.Sum(_ => _.Amount);

            return(sum);
        }
Пример #2
0
 private BillPayment ToPayment(IntendedColxnDTO colxn, ICollectionsDB db) => new BillPayment
 {
     Amount    = colxn.Actuals.For(this.BillCode).Value,
     PRNumber  = colxn.PRNumber,
     Remarks   = colxn.Remarks,
     Collector = db.GetCollector(colxn.Lease),
 };
Пример #3
0
        private void AddSubRows(CollectorDTO collector, SectionDTO sec, ICollectionsDB db, IStallsRepo stalls)
        {
            var savedCollectr = db.GetCollector(sec)
                                ?? new CollectorDTO {
                Id = 1
            };

            if (savedCollectr.Id != collector.Id)
            {
                return;
            }
            if (!db.IntendedColxns.TryGetValue(sec.Id, out IIntendedColxnsRepo repo))
            {
                return;
            }
            if (!repo.Any())
            {
                return;
            }

            foreach (var colxn in repo.GetAll())
            {
                if (colxn.StallSnapshot == null)
                {
                    colxn.StallSnapshot = stalls.Find(colxn.Lease.Stall.Id, true);
                }

                this.Add(new CollectorPerfSubRow(colxn, sec));
            }
        }
Пример #4
0
        public static List <Action> GetActions(ICollectionsDB colxnsDB, ITenantDBsDir dir, string postedBy)
        {
            var jobs = new List <Action>();

            jobs.Add(() => colxnsDB.MarkAsPosted(postedBy));

            return(jobs);
        }
Пример #5
0
        private static decimal GetIntendedColxnsTotal(ICollectionsDB db)
        {
            var bySec = db.IntendedColxns.Values.Select(s
                                                        => s.GetAll().Sum(_ => _.Actuals.Total));

            var sum = bySec.Sum(_ => _);

            return(sum);
        }
Пример #6
0
        private static decimal GetAmbulantColxnsTotal(ICollectionsDB db)
        {
            var bySec = db.AmbulantColxns.Values.Select(s
                                                        => s.GetAll().Sum(_ => _.Amount));

            var sum = bySec.Sum(_ => _);

            return(sum);
        }
        public static void AddDepsToPassbookIfNeeded(this ICollectionsDB colxnsDB, IEnumerable <BankDepositDTO> deps, ITenantDBsDir dir)
        {
            if (colxnsDB.IsRemediated())
            {
                return;
            }
            var tweakd = TweakDepositsForPassbook(deps);

            dir.UpdateAccountPassbooks(tweakd, colxnsDB.Date, false);
            colxnsDB.MarkAsRemediated();
        }
Пример #8
0
        private IEnumerable <LeaseDTO> GetOccupieds(ICollectionsDB db)
        {
            var lses = db.IntendedColxns[Section.Id]
                       .GetAll().Select(_ => _.Lease).ToList();

            lses.AddRange(db.Uncollecteds[Section.Id]
                          .GetAll().Select(_ => _.Lease));

            lses.AddRange(db.NoOperations[Section.Id]
                          .GetAll().Select(_ => _.Lease));
            return(lses);
        }
Пример #9
0
        private UIList <OtherColxnDTO> LoadOtherColxns(ICollectionsDB db)
        {
            var all  = db.OtherColxns.GetAll();
            var list = new UIList <OtherColxnDTO>(all);

            list.SetSummary(new OtherColxnDTO
            {
                Amount = all.Sum(_ => _.Amount)
            });
            list.SummaryAmount = (double)list.SummaryRows[0].Amount;
            return(list);
        }
Пример #10
0
        public static List <Action> GetActions(ICollectionsDB colxnsDB, ITenantDBsDir dir)
        {
            var jobs    = new List <Action>();
            var balancd = colxnsDB.Date.AddDays(-1);

            EnqueueBalanceUpdates(jobs, balancd, dir);

            jobs.Add(() => dir.AddDepositsToPassbook(balancd, true));
            jobs.Add(() => colxnsDB.MarkAsOpened());
            jobs.Add(() => TerminateExpiredLeases(dir));
            return(jobs);
        }
Пример #11
0
        private UIList <BankDepositDTO> LoadBankDeposits(ICollectionsDB db)
        {
            var all  = db.BankDeposits.GetAll();
            var list = new UIList <BankDepositDTO>(all);

            list.SetSummary(new BankDepositDTO
            {
                Amount = all.Sum(_ => _.Amount)
            });
            list.SummaryAmount = (double)list.SummaryRows[0].Amount;
            return(list);
        }
Пример #12
0
        public StallsInventoryReport(ICollectionsDB colxns, MarketStateDbBase mkt)
        {
            var sections = colxns.SectionsSnapshot ?? mkt.Sections.GetAll();

            foreach (var sec in sections)
            {
                var row = new StallsInventoryRow(sec, colxns);
                if (row.TotalCount > 0)
                {
                    this.Add(row);
                }
            }

            this.SetSummary(new StallsInventoryTotal(this));
        }
Пример #13
0
        public static CollectorsPerformanceReport New(IMarketStateDB mkt, ICollectionsDB db)
        {
            var cp = new CollectorsPerformanceReport();

            var collectors = db.CollectorsSnapshot
                             ?? mkt.Collectors.GetAll();

            foreach (var collector in collectors)
            {
                cp.Add(CollectorPerformanceRow.New(collector, mkt.Stalls, db, mkt));
            }

            cp.RemoveAll(_ => !_.Any());

            return(cp);
        }
Пример #14
0
        public static ColPerfStallCoverage New(CollectorPerformanceRow colPerfRow, ICollectionsDB db)
        {
            var sc = new ColPerfStallCoverage();

            sc.CollectedsCount = colPerfRow.Count;

            foreach (var sec in colPerfRow.Sections)
            {
                if (db.Uncollecteds.TryGetValue(sec.Id, out IUncollectedsRepo uncolRepo))
                {
                    sc.UncollectedsCount += uncolRepo.GetAll().Count;
                }

                if (db.NoOperations.TryGetValue(sec.Id, out INoOperationsRepo noOpsRepo))
                {
                    sc.NoOperationsCount += noOpsRepo.GetAll().Count;
                }
            }
            return(sc);
        }
Пример #15
0
 private static decimal GetTotalDeposits(ICollectionsDB db)
 => db.BankDeposits.GetAll().Sum(_ => _.Amount);
Пример #16
0
 private IEnumerable <StallDTO> GetVacants(ICollectionsDB db)
 => db.VacantStalls[Section.Id].GetAll();
Пример #17
0
 private static bool IsRemediated(this ICollectionsDB colxnsDB)
 => colxnsDB.Meta.Has(META_KEY);
Пример #18
0
 private static void MarkAsRemediated(this ICollectionsDB colxnsDB)
 => colxnsDB.Meta.SetTrue(META_KEY);
Пример #19
0
 protected override CollectorDTO GetSectionCollector(SectionDTO sec, ICollectionsDB db)
 => CollectorDTO.Office();
Пример #20
0
 protected override void ReplaceInColxnsDB(IEnumerable <CashierColxnDTO> rntDTOs, ICollectionsDB colxnsDB)
 => colxnsDB.CashierColxns.DropAndInsert(rntDTOs, true, false);
Пример #21
0
 protected virtual CollectorDTO GetSectionCollector(SectionDTO sec, ICollectionsDB db)
 => db.GetCollector(sec);
Пример #22
0
 protected override void ReplaceInColxnsDB(IEnumerable <BankDepositDTO> rntDTOs, ICollectionsDB colxnsDB)
 => colxnsDB.BankDeposits.DropAndInsert(rntDTOs, true, false);
Пример #23
0
 protected override void ReplaceInColxnsDB(IEnumerable <BankDepositDTO> rntDTOs, ICollectionsDB colxnsDB)
 {
     colxnsDB.BankDeposits.DropAndInsert(rntDTOs, true, false);
     //_rntDir.UpdateAccountPassbooks(rntDTOs, colxnsDB.Date);
     colxnsDB.AddDepsToPassbookIfNeeded(rntDTOs, _rntDir);
 }
Пример #24
0
 public NextDayOpenerVM(MainWindowVM mainWindowVM)
 {
     _main = mainWindowVM;
     _db   = _main.ColxnsDB;
 }
Пример #25
0
        protected virtual List <LeaseColxnRow> GetLeaseColxns(SectionDTO sec, DateTime date, ICollectionsDB db, ITenantDBsDir dir)
        {
            var fromLses = db.IntendedColxns[sec.Id].GetAll()
                           .Select(_ => new LeaseColxnRow(_));

            foreach (var item in fromLses)
            {
                dir.MarketState.RefreshStall(item.Lease);
            }

            var fromAmbu = db.AmbulantColxns[sec.Id].GetAll()
                           .Select(_ => new LeaseColxnRow(Section, _));

            return(fromLses.Concat(fromAmbu).ToList());
        }
Пример #26
0
        protected override void ReplaceInColxnsDB(IEnumerable <AmbulantColxnDTO> rntDTOs, ICollectionsDB colxnsDB)
        {
            var grpBySec = rntDTOs.GroupBy(_ => GetSecId(_));

            foreach (var secGrp in grpBySec)
            {
                if (secGrp.Key == 0)
                {
                    continue;
                }
                var repo = colxnsDB.AmbulantColxns[secGrp.Key];
                repo.DropAndInsert(secGrp, true, false);
            }
        }
Пример #27
0
        protected override void ReplaceInColxnsDB(IEnumerable <IntendedColxnDTO> rntDTOs, ICollectionsDB colxnsDb)
        {
            var grpBySec = rntDTOs.GroupBy(_ => _.Lease?.Stall?.Section?.Id ?? 0);

            foreach (var secGrp in grpBySec)
            {
                if (secGrp.Key == 0)
                {
                    continue;
                }
                var repo = colxnsDb.IntendedColxns[secGrp.Key];
                repo.DropAndInsert(secGrp, true, false);
            }
        }
Пример #28
0
        protected override List <LeaseColxnRow> GetLeaseColxns(SectionDTO sec, DateTime date, ICollectionsDB db, ITenantDBsDir dir)
        {
            var colxns = db.CashierColxns.GetAll()
                         .Select(_ => ToLeaseColxnRow(_));

            foreach (var item in colxns)
            {
                dir.MarketState.RefreshStall(item.Lease);
            }

            return(colxns.ToList());
        }
Пример #29
0
 protected abstract void                 ReplaceInColxnsDB(IEnumerable <T> rntDTOs, ICollectionsDB colxnsDB);
Пример #30
0
        public static CollectorPerformanceRow New(CollectorDTO collector, IStallsRepo fallbackStallsRepo, ICollectionsDB db, IMarketStateDB mkt)
        {
            var cp       = new CollectorPerformanceRow(collector);
            var sections = db.SectionsSnapshot ?? mkt.Sections.GetAll();

            foreach (var sec in sections)
            {
                cp.AddSubRows(collector, sec, db, fallbackStallsRepo);
            }

            cp.Sections = cp.DistinctBy(_ => _.Section.Id)
                          .Select(_ => _.Section)
                          .ToList();

            cp.StallCoverage = ColPerfStallCoverage.New(cp, db);
            cp.RentBill      = ColPerfBillPerformance.New(BillCode.Rent, cp.Select(_ => _.Rent));
            cp.RightsBill    = ColPerfBillPerformance.New(BillCode.Rights, cp.Select(_ => _.Rights));

            cp.SetSummary(new CollectorPerfSubRowsTotal(cp));

            return(cp);
        }