Esempio n. 1
0
                public static void Create(Models.CreditDebit creditDebit)
                {
                    if (creditDebit.TransactionType
                        == Models.Transaction.TransactionTypes.DEPOSIT ||
                        creditDebit.TransactionType
                        == Models.Transaction.TransactionTypes.SYSTEM_DEPOSIT ||
                        creditDebit.TransactionType
                        == Models.Transaction.TransactionTypes.SEND_RECEIVE_RECEIVE ||
                        creditDebit.TransactionType
                        == Models.Transaction.TransactionTypes.LOAN_PAYMENT ||
                        creditDebit.TransactionType
                        == Models.Transaction.TransactionTypes.ACCOUNT_CREATION_FEE ||
                        creditDebit.TransactionType
                        == Models.Transaction.TransactionTypes.STANDING_CHARGE)
                    {
                        //increment new Balance by Creditamount
                        creditDebit.NewBalance = creditDebit.Credit + creditDebit.Account.Balance;
                    }
                    else if (creditDebit.TransactionType
                             == Models.Transaction.TransactionTypes.WITHDRAW ||
                             creditDebit.TransactionType
                             == Models.Transaction.TransactionTypes.SEND_RECEIVE_SEND)
                    {
                        creditDebit.NewBalance = creditDebit.Account.Balance - creditDebit.Debit;
                    }

                    String sql =
                        "INSERT INTO `cred_deb` " +
                        "(`TransactionId`,`AccountNumber`,`Credit`,`Debit`,`NewBalance`,`description_id`) " +
                        "VALUES " +
                        "(" + creditDebit.Transaction.TransactionId + "," + creditDebit.Account.Number + "," + creditDebit.Credit + "," + creditDebit.Debit + "," + creditDebit.NewBalance + ",'" + creditDebit.TransactionDescription.Id + "');" +
                        "UPDATE accounts SET balance = '" + creditDebit.NewBalance + "' WHERE Number = " + creditDebit.Account.Number + ";";

                    database.execute(sql);
                }
Esempio n. 2
0
                public static void CreateForLoans(Models.CreditDebit creditDebit)
                {
                    String sql =
                        "INSERT INTO `cred_deb` " +
                        "(`TransactionId`,`AccountNumber`,`Credit`,`Debit`,`NewBalance`,`description_id`) " +
                        "VALUES " +
                        "(" + creditDebit.Transaction.TransactionId + "," + creditDebit.Account.Number + "," + creditDebit.Credit + "," + creditDebit.Debit + "," + creditDebit.NewBalance + ",'" + creditDebit.TransactionDescription.Id + "');" +
                        ";";

                    database.execute(sql);
                }
Esempio n. 3
0
                    public static Models.CreditDebit FormatCreditDebit(MySqlDataReader dataReader)
                    {
                        Models.CreditDebit credDeb = null;
                        String             tId = "-1", tdId = "-1", number = "-1";

                        while (dataReader.Read())
                        {
                            credDeb = new Models.CreditDebit
                            {
                                Id         = dataReader["Id"].ToString(),
                                Credit     = dataReader.GetDouble("Credit"),
                                Debit      = dataReader.GetDouble("Debit"),
                                NewBalance = dataReader.GetDouble("NewBalance"),
                                DateStamp  = dataReader.GetDateTime("date_stamp")
                            };
                        }
                        dataReader.Close();
                        credDeb.Transaction            = API.Controllers.Transaction.FindByID(tId);
                        credDeb.TransactionDescription = API.Controllers.TransactionDescription.FindByID(tdId);
                        credDeb.Account = API.Controllers.Accounts.FetchByAccountNumber(number);
                        return(credDeb);
                    }