Ejemplo n.º 1
0
            }             // UpdateTotal

            public void Update(SafeReader sr, AccountingLoanBalanceRawUpdate upd = null)
            {
                upd = upd ?? sr.Fill <AccountingLoanBalanceRawUpdate>();

                if (upd.TransactionDate.HasValue && !Transactions.Contains(upd.TransactionID))
                {
                    Transactions.Add(upd.TransactionID);

                    bool bNonCash = (upd.LoanTranMethod ?? string.Empty).ToLower().StartsWith("non-cash");

                    if (bNonCash)
                    {
                        NonCashPaid += upd.TotalRepaid;
                    }
                    else
                    {
                        CashPaid += upd.TotalRepaid;
                    }

                    EarnedFees      += upd.RolloverRepaid;
                    RepaidPrincipal += upd.RepaidPrincipal;
                    RepaidInterest  += upd.RepaidInterest;
                    FeesRepaid      += upd.FeesRepaid;

                    if (upd.TransactionDate.Value < WriteOffDate)
                    {
                        if (bNonCash)
                        {
                            WriteOffNonCashPaid += upd.TotalRepaid;
                        }
                        else
                        {
                            WriteOffCashPaid += upd.TotalRepaid;
                        }

                        WriteOffEarnedFees += upd.RolloverRepaid;
                    }             // if
                }                 // if

                if (upd.LoanChargeDate.HasValue && !LoanCharges.Contains(upd.FeesEarnedID))
                {
                    LoanCharges.Add(upd.FeesEarnedID);
                    EarnedFees += upd.FeesEarned;

                    if (upd.LoanChargeDate < WriteOffDate)
                    {
                        WriteOffEarnedFees += upd.FeesEarned;
                    }
                }         // if
            }             // Update
        public Dictionary <string, object> ExecuteInTransaction(ICommandTransaction client,
                                                                Dictionary <string, object> Input,
                                                                string name = "")
        {
            if (IsTransactionFailed)
            {
                throw new InconsistantStateException("Transactional Manager in error state, create a new instance to use it");
            }


            if (String.IsNullOrEmpty(client.Name) && string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Transactional Client name not passed");
            }
            if (!string.IsNullOrEmpty(name))
            {
                client.Name = name;
            }

            #region Adding client to Dictionary
            if (!Transactions.Contains(client))
            {
                Transactions.Add(client);
                TransactionInputs.Add(client, Input);
            }
            #endregion

            try
            {
                _logger.LogInformation("Executing client '{0}' in transaction", client.Name);
                var output = client.Execute(Input);
                return(output);
            }
            catch (Exception ex)
            {
                _logger.LogError("Exception occur while executing  client '{0}' in transaction", client.Name);
                _logger.LogError(ex.ToString());
                ExecuteRollBack(client);
                throw new TransactionExecutionException("Transaction failed and rollback executed successfully");
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This handler handles the event when the <see cref="ITransactionRepository.SaveTransactionCompleted"/>
 /// event is raised by <see cref="_transactionRepository"/>.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TransactionRepositorySaveTransactionCompleted(object sender, RepositoryTaskFinishedEventArgs e)
 {
     ThreadSafeInvoke(() =>
     {
         _messagingService.CloseProgressMessage();
         if (e.HasError)
         {
             _messagingService.ShowMessage(UIText.ERROR_OCCURED_MSG);
         }
         if (!Transactions.Contains(SelectedTransaction))
         {
             Transactions.Add(SelectedTransaction);
             if (null != SelectedTransaction)                     //Redundant but safe check
             {
                 SelectedTransaction.Refresh();
             }
             TotalIncome      = Transactions.Where(t => t.FlowType == TransactionFlowType.Income).Sum(t => t.Entity.Amount);
             TotalExpenditure = Transactions.Where(t => t.FlowType == TransactionFlowType.Expenditure).Sum(t => t.Entity.Amount);
             //  GraphItems = GetGraphData(Transactions.Select(t => t.Entity).ToList());
         }
     });
 }
Ejemplo n.º 4
0
 public bool Exists(ModelBase obj)
 {
     if (obj is Account)
     {
         return(Accounts.Contains(obj));
     }
     else if (obj is Transaction)
     {
         return(Transactions.Contains(obj));
     }
     else if (obj is TransactionDetail)
     {
         return(TransactionDetails.Contains(obj));
     }
     else if (obj is Receipt)
     {
         return(Receipts.Contains(obj));
     }
     else if (obj is ScheduledTransaction)
     {
         return(ScheduledTransactions.Contains(obj));
     }
     else if (obj is ScheduledTransactionDetail)
     {
         return(ScheduledTransactionDetails.Contains(obj));
     }
     else if (obj is Category)
     {
         return(Categories.Contains(obj));
     }
     else if (obj is Product)
     {
         return(Products.Contains(obj));
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
 public bool ContainsTransaction(UInt256 hash)
 {
     return(Transactions.Contains(hash));
 }