Esempio n. 1
0
        public static InactiveLeaseDTO DeactivateLease(this MarketStateDbBase mkt, LeaseDTO lse,
                                                       string reason, DateTime deactivationDate)
        {
            if (lse is InactiveLeaseDTO)
            {
                throw Bad.State <LeaseDTO>("Inactive", "Active");
            }

            var inactv = new InactiveLeaseDTO(lse, reason, deactivationDate, mkt.CurrentUser);

            mkt.InactiveLeases.Insert(inactv);

            return(inactv);
        }
Esempio n. 2
0
        protected override void ExecuteAfterSave(InactiveLeaseDTO lse, bool operationIsDelete)
        {
            if (operationIsDelete)
            {
                return;
            }

            _db.ActiveLeases.Delete(lse.Id);

            if (_db.ActiveLeases.HasId(lse.Id))
            {
                throw Bad.State <LeaseDTO>("Deactivated", "Exists-As-Active");
            }

            _db.Balances.GetRepo(lse.Id)
            .RecomputeFrom(lse.DeactivatedDate);
        }
Esempio n. 3
0
        private static List <JournalVoucherDTO> CastAsAllByfs(List <dynamic> byfHeadrs, List <dynamic> byfItems, MainWindowVM2 main)
        {
            var headrs    = byfHeadrs.Select(_ => (JournalVoucherDTO)CastAsVoucherDTO(_)).ToList();
            var itemsDict = GroupItemsByHeader(byfItems, main.RntCache);

            foreach (var kvp in itemsDict)
            {
                var headr = headrs.SingleOrDefault(_ => _.Id == kvp.Key);
                if (headr == null)
                {
                    throw No.Match <JournalVoucherDTO>("Id", kvp.Key);
                }

                if (!headr.IsBalanced)
                {
                    throw Bad.State <JournalVoucherDTO>("balanced", "not balanced");
                }

                headr.Allocations = kvp.Value;
                headr.Amount      = headr.TotalCredit;
            }
            return(headrs);
        }