Пример #1
0
        protected void UpdateCycle(DateTime date)
        {
            ReaderWriterLockSlim _slimLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

            _slimLock.TryEnterWriteLock(1000);

            try
            {
                DateTime _dateChecked = this.MonetaryCycles.Last().Period.StartDateTime.Date;

                while (_dateChecked < date.Date)
                {
                    IMonetaryCycle _cycleOut = this._GetCycle(_dateChecked);
                    this._UpdateAccruedInterest(ref _cycleOut);
                    _dateChecked = _dateChecked.AddDays(1);
                }

                this._GetCycle(date);
            }


            catch { throw; }
            finally { if (_slimLock.IsWriteLockHeld)
                      {
                          _slimLock.ExitWriteLock();
                      }
            }
        }
Пример #2
0
        private void _UpdateAccruedInterest(ref IMonetaryCycle _cycle)
        {
            double?_rateIn = GetRate(_cycle.Period.StartDateTime.Date, _cycle.AvailableBalance);

            _cycle.InterestRate = _rateIn.Value;
            if (_rateIn.HasValue)
            {
                _cycle.AccruedInterest = this.GetCycleInterest(_cycle.AvailableBalance, _rateIn.Value);
            }
            _cycle.ClosingBalance = _cycle.AccruedInterest + _cycle.AvailableBalance;
        }
Пример #3
0
        private IMonetaryCycle _GetCycle(DateTime date)
        {
            IMonetaryCycle _cycle = this._FindCycle(date);

            if (_cycle == null)
            {
                _cycle = this._CreateCycle(date);
            }

            return(_cycle);
        }
Пример #4
0
        public override void Transactions_OnAdd(object sender, EventArgs e)
        {
            ITransaction   _transaction = (ITransaction)sender;
            IMonetaryCycle _cycle       = this._FindCycle(_transaction.Date);

            if (_cycle == null)
            {
                UpdateCycle(_transaction.Date);
                _cycle = this._FindCycle(_transaction.Date);
            }

            _cycle.InTransactions.Add(_transaction);
            _cycle.AvailableBalance += _transaction.Value;
        }
Пример #5
0
 private decimal AccruedInterest(IMonetaryCycle cycle)
 {
 }