コード例 #1
0
        public static IR2Command GetRenewInactiveLeaseCmd(FilteredListVMBase listVM,
                                                          string label = "Renew Contract for this Lease")
        {
            return(LeaseCRUD1VM.NewCmd(listVM, label,
                                       listVM.AppArgs.CanAddLease(false), (lse, crud) =>
            {
                var args = crud.AppArgs;
                var inactv = lse as InactiveLeaseDTO;
                if (inactv == null)
                {
                    throw Bad.Data("Expected non-null ‹InactiveLeaseDTO›");
                }

                if (args.MarketState.IsOccupied(inactv.Stall))
                {
                    Alert.Show($"Stall [{inactv.Stall}] is currently occupied.");
                    return;
                }

                crud.TenantTemplate = inactv.Tenant.ShallowClone();
                crud.DraftBirthDate = inactv.Tenant.BirthDate;
                crud.SetPickedStall(inactv.Stall);
                crud.SetPickedStart(inactv.DeactivatedDate.AddDays(1).Date);
                crud.SetRenewedFrom(inactv);
                crud.SetProductToSell(inactv.ProductToSell);
                crud.NewRecordSaved += (s, newLse) => inactv.ForwardBalancesTo(newLse, args);
                crud.EncodeNewDraftCmd.ExecuteIfItCan();
            }));
        }
コード例 #2
0
ファイル: AdHocJobCmdsVM.cs プロジェクト: peterson1/RentLog
        private void RunAdHoc(int taskNumber)
        {
            Action adhocJob; string desc;

            switch (taskNumber)
            {
            case 1: adhocJob =
                CheckVoucherAdHocs.FixBDO1ImportBug(_dir, out desc);
                break;

            case 2: adhocJob =
                BankTxnsFix.RemoveDuplicates(13052, _dir, out desc);
                break;

            default: throw Bad.Data($"Task #: [{taskNumber}]");
            }

            Alert.Confirm($"Run Ad Hoc job “{desc}”?", async() =>
            {
                _main.StartBeingBusy("Running Ad Hoc task ...");

                await Task.Run(() => adhocJob.Invoke());

                _main.StopBeingBusy();
                _main.ClickRefresh();
            });
        }
コード例 #3
0
 private static void EditLease <T>(T lse, ISimpleRepo <T> repo) where T : LeaseDTO
 {
     lse.Rent.PenaltyRule = RentPenalty.ZeroBackrent;
     if (!repo.Update(lse))
     {
         throw Bad.Data("Update(lse) did NOT return true.");
     }
 }
コード例 #4
0
        private static void EditStallTemplate(MarketStateDbBase mkt, int secId)
        {
            var repo = mkt.Sections;
            var sec  = repo.Find(secId, true);

            sec.StallTemplate.DefaultRent
            .PenaltyRule = RentPenalty.ZeroBackrent;

            if (!repo.Update(sec))
            {
                throw Bad.Data("Update(sec) did NOT return true.");
            }
        }
コード例 #5
0
 protected List <dynamic> PickOneWithDate(DateTime date, IEnumerable <string> filePaths)
 {
     foreach (var file in filePaths)
     {
         var      lines   = File.ReadAllText(file);
         var      list    = JsonConvert.DeserializeObject <List <dynamic> >(lines);
         DateTime dateObj = list[0].Date;
         if ((DateTime)list[0].Date == date)
         {
             return(list);
         }
     }
     throw Bad.Data($"No cached json file dated [{date}].");
 }
コード例 #6
0
        private void GenerateFrom(ITenantDBsDir dir)
        {
            BranchName = dir.MarketState.BranchName;

            FillMainList(dir);
            FillLookups(dir);
            FillSectionTotals(dir);
            FillOtherTotals(dir);

            if (TotalCollections != TotalDeposits)
            {
                throw Bad.Data($"Total collections ({TotalCollections:N2}) does not match total deposits ({TotalDeposits:N2}).");
            }
        }
コード例 #7
0
        public LeaseDTO GetOccupant(StallDTO stall)
        {
            var matches = ActiveLeases.GetAll()
                          .Where(_ => _.Stall.Id == stall.Id);

            if (!matches.Any())
            {
                return(null);
            }
            if (matches.Count() > 1)
            {
                throw Bad.Data($"1 occupant for [{stall}] but found [{matches.Count()}]");
            }
            return(matches.Single());
        }
コード例 #8
0
        private void RunAdHoc(int taskNumber)
        {
            Action adhocJob; string desc; bool canRun;

            switch (taskNumber)
            {
            case 1: adhocJob =
                ForActiveLeases.RebuildSoA(_dir, out desc, out canRun);
                break;

            case 2: adhocJob =
                SectionNight.SetNoBackRent(_dir, out desc, out canRun);
                break;

            case 3: adhocJob =
                StallsJob.SetStallDefaults(_dir, out desc, out canRun);
                break;

            case 4: adhocJob =
                ForActiveLeases.Reprocess3DaysBack(_dir, out desc, out canRun);
                break;

            case 5: adhocJob =
                RateIncrease.ApplyTo("BALAGTAS", _dir, out desc, out canRun);
                break;

            default: throw Bad.Data($"Task #: [{taskNumber}]");
            }


            if (!canRun)
            {
                var creds = _dir.Credentials;
                Alert.ShowModal("Not Authorized to Execute",
                                $"“{creds.HumanName}” ({creds.Roles}) {L.f} is not allowed to {L.f} “{desc}”.");
                return;
            }

            Alert.Confirm($"Run Ad Hoc job “{desc}”?", async() =>
            {
                _main.StartBeingBusy("Running Ad Hoc task ...");

                await Task.Run(() => adhocJob.Invoke());

                _main.StopBeingBusy();
                _main.ClickRefresh();
            });
        }
コード例 #9
0
        private void GenerateFrom(ITenantDBsDir dir)
        {
            if (Date > dir.Collections.LastPostedDate())
            {
                throw Bad.Arg("Daily Colxns Date", $"{Date:d MMM yyyy}");
            }

            FillSectionCollections(dir);
            FillOtherCollections(dir);
            DepositsSum = GetTotalDeposits(dir);

            if (CollectionsSum != DepositsSum)
            {
                throw Bad.Data($"Collections sum ({CollectionsSum:N2}) for [{Date:d-MMM-yyyy}] does not match deposits sum ({DepositsSum:N2}).");
            }

            this.SetSummary(SectionColxnsRow.GetSummary(this));
        }
コード例 #10
0
        private GLAcctType GetAcctType(int acctTypeTid)
        {
            switch (acctTypeTid)
            {
            case 33: return(GLAcctType.Asset);

            case 34: return(GLAcctType.Liability);

            case 35: return(GLAcctType.Equity);

            case 36: return(GLAcctType.Income);

            case 37: return(GLAcctType.Expense);

            default:
                throw Bad.Data($"Invalid GL Acct type tid: [{acctTypeTid}]");
            }
        }
コード例 #11
0
        private static bool IsUpdateConfirmed(out DailyBillDTO dtoForUpdate, SoaViewerVM vm)
        {
            var day1 = vm?.Rows?.LastOrDefault();

            if (day1 == null)
            {
                throw Bad.Data("Day 1 row");
            }

            dtoForUpdate = day1.DTO;
            var origVal = day1.Rights.OpeningBalance;
            var suggVal = GetSuggestedVal(day1.Rights, vm);
            var dte     = $"{day1.Date:d-MMM-yyyy}";
            var msg     = $"[{dte}] Starting Rights  (orig.val: {origVal:N2})";
            var ok      = PopUpInput.TryGetDecimal(msg, out decimal newVal, suggVal);

            if (!ok)
            {
                return(false);
            }

            EditBillRow(dtoForUpdate, newVal, vm);
            return(true);
        }
コード例 #12
0
 private decimal GetAmount(dynamic byf, out BillCode billCode)
 {
     if (TryGetValue(byf.rent, billCode = BillCode.Rent, out decimal val))
     {
         return(val);
     }
     if (TryGetValue(byf.surcharge, billCode = BillCode.Rent, out val))
     {
         return(val);
     }
     if (TryGetValue(byf.rights, billCode = BillCode.Rights, out val))
     {
         return(val);
     }
     if (TryGetValue(byf.electric, billCode = BillCode.Electric, out val))
     {
         return(val);
     }
     if (TryGetValue(byf.water, billCode = BillCode.Water, out val))
     {
         return(val);
     }
     throw Bad.Data("Balance Adj. has no valid amount");
 }