Exemple #1
0
 /// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="statement">Bank Statement that the line is part of</param>
 public MBankStatementLine(MBankStatement statement)
     : this(statement.GetCtx(), 0, statement.Get_TrxName())
 {
     SetClientOrg(statement);
     SetC_BankStatement_ID(statement.GetC_BankStatement_ID());
     SetStatementLineDate(statement.GetStatementDate());
 }
Exemple #2
0
        //private bool UpdateBSAndLine()
        public bool UpdateBSAndLine(bool DeletingLinesFromHeader = false)
        {
            // Update Bank Statement
            //bool DeletingLinesFromHeader_ = DeletingLinesFromHeader;
            UpdateHeader(DeletingLinesFromHeader);

            // Update BankAccount and BankAccountLine
            MBankStatement parent      = GetParent();
            MBankAccount   bankAccount = new MBankAccount(GetCtx(), parent.GetC_BankAccount_ID(), Get_TrxName());

            // bankAccount.SetUnMatchedBalance(Decimal.Add(Decimal.Subtract(bankAccount.GetUnMatchedBalance(), old_ebAmt), new_ebAmt)); //Commented Arpit..To updated only if document gets completed..asked by Ashish
            if (!bankAccount.Save(Get_TrxName()))
            {
                log.Warning("Cannot update unmatched balance.");
                return(false);
            }

            DataTable dtBankAccountLine;
            int       C_BANKACCOUNTLINE_ID = 0;

            string sql = "SELECT C_BANKACCOUNTLINE_ID FROM C_BANKACCOUNTLINE WHERE C_BANKACCOUNT_ID="
                         + bankAccount.GetC_BankAccount_ID() + " AND STATEMENTDATE="
                         + DB.TO_DATE(GetStatementLineDate()) + " AND AD_ORG_ID=" + GetAD_Org_ID();

            dtBankAccountLine = DB.ExecuteDataset(sql, null, Get_TrxName()).Tables[0];

            if (dtBankAccountLine.Rows.Count > 0)
            {
                C_BANKACCOUNTLINE_ID = Util.GetValueOfInt(dtBankAccountLine.Rows[0][0]);
            }

            MBankAccountLine bankAccountLine = new MBankAccountLine(GetCtx(), C_BANKACCOUNTLINE_ID, Get_TrxName());

            if (C_BANKACCOUNTLINE_ID == 0)
            {
                bankAccountLine.SetC_BankAccount_ID(bankAccount.GetC_BankAccount_ID());
                //Arpit To set same orgnization as Bank Statement on Account Line
                //bankAccountLine.SetAD_Org_ID(GetCtx().GetAD_Org_ID());
                //bankAccountLine.SetAD_Client_ID(GetCtx().GetAD_Client_ID());
                bankAccountLine.SetAD_Org_ID(parent.GetAD_Org_ID());
                bankAccountLine.SetAD_Client_ID(parent.GetAD_Client_ID());
                bankAccountLine.SetEndingBalance(
                    Decimal.Add(Decimal.Add(Decimal.Subtract(bankAccountLine.GetEndingBalance(), old_ebAmt), new_ebAmt), bankAccount.GetCurrentBalance()));
            }
            else
            {
                bankAccountLine.SetEndingBalance(Decimal.Add(Decimal.Subtract(bankAccountLine.GetEndingBalance(), old_ebAmt), new_ebAmt));
            }
            bankAccountLine.SetStatementDate(GetStatementLineDate());
            bankAccountLine.SetStatementDifference(Decimal.Add(Decimal.Subtract(bankAccountLine.GetStatementDifference(), old_sdAmt), new_sdAmt));
            //bankAccountLine.SetEndingBalance(Decimal.Add(Decimal.Subtract(bankAccountLine.GetEndingBalance(), old_ebAmt), new_ebAmt)); //Arpit commented because Ending Balance Already updated in above Lines

            if (!bankAccountLine.Save(Get_TrxName()))
            {
                log.Warning("Cannot create/update bank account line.");
                return(false);
            }

            return(true);
        }
Exemple #3
0
 /**
  *  Get BankAccount (parent)
  *	@return BankAccount
  */
 public MBankStatement GetParent()
 {
     if (_parent == null)
     {
         _parent = new MBankStatement(GetCtx(), GetC_BankStatement_ID(), Get_TrxName());
     }
     return(_parent);
 }
Exemple #4
0
        private bool UpdateBSAndLine()
        {
            // Update Bank Statement
            UpdateHeader();

            // Update BankAccount and BankAccountLine
            MBankStatement parent      = GetParent();
            MBankAccount   bankAccount = new MBankAccount(GetCtx(), parent.GetC_BankAccount_ID(), Get_TrxName());

            bankAccount.SetUnMatchedBalance(Decimal.Add(Decimal.Subtract(bankAccount.GetUnMatchedBalance(), old_ebAmt), new_ebAmt));

            if (!bankAccount.Save())
            {
                log.Warning("Cannot update unmatched balance.");
                return(false);
            }

            DataTable dtBankAccountLine;
            int       C_BANKACCOUNTLINE_ID = 0;

            string sql = "SELECT C_BANKACCOUNTLINE_ID FROM C_BANKACCOUNTLINE WHERE C_BANKACCOUNT_ID="
                         + bankAccount.GetC_BankAccount_ID() + " AND STATEMENTDATE="
                         + DB.TO_DATE(GetStatementLineDate()) + " AND AD_ORG_ID=" + GetAD_Org_ID();

            dtBankAccountLine = DB.ExecuteDataset(sql, null, null).Tables[0];

            if (dtBankAccountLine.Rows.Count > 0)
            {
                C_BANKACCOUNTLINE_ID = Util.GetValueOfInt(dtBankAccountLine.Rows[0][0]);
            }

            MBankAccountLine bankAccountLine = new MBankAccountLine(GetCtx(), C_BANKACCOUNTLINE_ID, Get_TrxName());

            if (C_BANKACCOUNTLINE_ID == 0)
            {
                bankAccountLine.SetC_BankAccount_ID(bankAccount.GetC_BankAccount_ID());
                bankAccountLine.SetAD_Org_ID(GetCtx().GetAD_Org_ID());
                bankAccountLine.SetAD_Client_ID(GetCtx().GetAD_Client_ID());
                bankAccountLine.SetEndingBalance(
                    Decimal.Add(Decimal.Add(Decimal.Subtract(bankAccountLine.GetEndingBalance(), old_ebAmt), new_ebAmt), bankAccount.GetCurrentBalance()));
            }
            else
            {
                bankAccountLine.SetEndingBalance(Decimal.Add(Decimal.Subtract(bankAccountLine.GetEndingBalance(), old_ebAmt), new_ebAmt));
            }
            bankAccountLine.SetStatementDate(GetStatementLineDate());
            bankAccountLine.SetStatementDifference(Decimal.Add(Decimal.Subtract(bankAccountLine.GetStatementDifference(), old_sdAmt), new_sdAmt));
            bankAccountLine.SetEndingBalance(Decimal.Add(Decimal.Subtract(bankAccountLine.GetEndingBalance(), old_ebAmt), new_ebAmt));

            if (!bankAccountLine.Save())
            {
                log.Warning("Cannot create/update bank account line.");
                return(false);
            }

            return(true);
        }
Exemple #5
0
 /// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="statement">Bank Statement that the line is part of</param>
 /// <param name="lineNo">position of the line within the statement</param>
 public MBankStatementLine(MBankStatement statement, int lineNo)
     : this(statement)
 {
     SetLine(lineNo);
 }