private static decimal GetCashierColxnsTotal(ICollectionsDB db) { var all = db.CashierColxns.GetAll(); var sum = all.Sum(_ => _.Amount); return(sum); }
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), };
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)); } }
public static List <Action> GetActions(ICollectionsDB colxnsDB, ITenantDBsDir dir, string postedBy) { var jobs = new List <Action>(); jobs.Add(() => colxnsDB.MarkAsPosted(postedBy)); return(jobs); }
private static decimal GetIntendedColxnsTotal(ICollectionsDB db) { var bySec = db.IntendedColxns.Values.Select(s => s.GetAll().Sum(_ => _.Actuals.Total)); var sum = bySec.Sum(_ => _); return(sum); }
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(); }
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); }
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); }
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); }
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); }
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)); }
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); }
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); }
private static decimal GetTotalDeposits(ICollectionsDB db) => db.BankDeposits.GetAll().Sum(_ => _.Amount);
private IEnumerable <StallDTO> GetVacants(ICollectionsDB db) => db.VacantStalls[Section.Id].GetAll();
private static bool IsRemediated(this ICollectionsDB colxnsDB) => colxnsDB.Meta.Has(META_KEY);
private static void MarkAsRemediated(this ICollectionsDB colxnsDB) => colxnsDB.Meta.SetTrue(META_KEY);
protected override CollectorDTO GetSectionCollector(SectionDTO sec, ICollectionsDB db) => CollectorDTO.Office();
protected override void ReplaceInColxnsDB(IEnumerable <CashierColxnDTO> rntDTOs, ICollectionsDB colxnsDB) => colxnsDB.CashierColxns.DropAndInsert(rntDTOs, true, false);
protected virtual CollectorDTO GetSectionCollector(SectionDTO sec, ICollectionsDB db) => db.GetCollector(sec);
protected override void ReplaceInColxnsDB(IEnumerable <BankDepositDTO> rntDTOs, ICollectionsDB colxnsDB) => colxnsDB.BankDeposits.DropAndInsert(rntDTOs, true, false);
protected override void ReplaceInColxnsDB(IEnumerable <BankDepositDTO> rntDTOs, ICollectionsDB colxnsDB) { colxnsDB.BankDeposits.DropAndInsert(rntDTOs, true, false); //_rntDir.UpdateAccountPassbooks(rntDTOs, colxnsDB.Date); colxnsDB.AddDepsToPassbookIfNeeded(rntDTOs, _rntDir); }
public NextDayOpenerVM(MainWindowVM mainWindowVM) { _main = mainWindowVM; _db = _main.ColxnsDB; }
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()); }
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); } }
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); } }
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()); }
protected abstract void ReplaceInColxnsDB(IEnumerable <T> rntDTOs, ICollectionsDB colxnsDB);
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); }