Пример #1
0
        internal void Calculate()
        {
            Assertion.Assert(this.Unprotected,
                             "This balance set is protected. It can not be recalculated.");

            var command = new TrialBalanceCommand {
                AccountsChartUID    = this.AccountsChart.UID,
                TrialBalanceType    = TrialBalanceType.GeneracionDeSaldos,
                InitialPeriod       = { FromDate = this.BalancesDate, ToDate = this.BalancesDate },
                ShowCascadeBalances = true
            };

            var balanceEngine = new TrialBalanceEngine(command);

            TrialBalance trialBalance = balanceEngine.BuildTrialBalance();

            StoredBalanceDataService.DeleteBalances(this);

            var entries = trialBalance.Entries.FindAll(x => ((TrialBalanceEntry)x).CurrentBalance != 0)
                          .Select(x => (TrialBalanceEntry)x);

            foreach (var entry in entries)
            {
                var storedBalance = new StoredBalance(this, entry);

                storedBalance.Save();
            }

            this.CalculationTime = DateTime.Now;

            this.Calculated = true;
            this.Save();

            this.ResetBalances();
        }
Пример #2
0
 private FixedList <StoredBalance> LoadBalances()
 {
     return(StoredBalanceDataService.GetBalances(this));
 }
 protected override void OnSave()
 {
     StoredBalanceDataService.WriteStoredBalance(this);
 }