Skip to content

Commit

Permalink
IDEMPIERE-5329: Adding support to tag Payment into batch to bank stat…
Browse files Browse the repository at this point in the history
…ement line and added document workflow support for payment into batch. (idempiere#2457)

* IDEMPIERE-5329: Adding support to tag Payment into batch to bank statement line and added document workflow support for payment into batch.

* IDEMPIERE-5329: Fixing Unit tests

* IDEMPIERE-5329: Fixing as per code review comments

* IDEMPIERE-5329: Fixing as per code review comments

* IDEMPIERE-5329: Fixing as per code review comments

* IDEMPIERE-5329: Applying patch from Carlos

* IDEMPIERE-5329: Correcting comments

* IDEMPIERE-5329:  Added validation so that if Deposit batch is on bank statement line then it do not reactivated or voided. Fixed dynamic validation on Deposit batch field to not show closed and reconcilled old deposit batch.
Added Create line per payment flag on create from deposit batch form
  • Loading branch information
dpansheriya authored Dec 20, 2024
1 parent e0e9893 commit e050878
Show file tree
Hide file tree
Showing 28 changed files with 1,769 additions and 322 deletions.
314 changes: 314 additions & 0 deletions migration/iD12/oracle/202404301200_IDEMPERIE-5329.sql

Large diffs are not rendered by default.

309 changes: 309 additions & 0 deletions migration/iD12/postgresql/202404301200_IDEMPERIE-5329.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,37 @@ public String payment (Properties ctx, int WindowNo, GridTab mTab, GridField mFi
amount (ctx, WindowNo, mTab, mField, value);
return "";
} // payment

/**
* BankStmt - Payment Into Batch.
* Update Transaction Amount and statement Amount when payment into batch is selected
* @param ctx context
* @param WindowNo window no
* @param mTab tab
* @param mField field
* @param value value
* @return null or error message
*/
public String paymentIntoBatch (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
Integer C_DepositBatch_ID = (Integer) value;
if (C_DepositBatch_ID == null || C_DepositBatch_ID.intValue() == 0)
return "";
//
BigDecimal stmt = (BigDecimal) mTab.getValue("StmtAmt");
if (stmt == null)
stmt = Env.ZERO;

BigDecimal depositAmt = DB.getSQLValueBDEx(null, "SELECT DepositAmt FROM C_DepositBatch WHERE C_DepositBatch_ID=?",
C_DepositBatch_ID.intValue());
mTab.setValue("TrxAmt", depositAmt);
if (stmt.compareTo(Env.ZERO) == 0)
mTab.setValue("StmtAmt", depositAmt);

// Recalculate Amounts
amount(ctx, WindowNo, mTab, mField, value);
return "";
} // payment into batch


} // CalloutBankStatement
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/******************************************************************************
* Copyright (C) 2016 Logilite Technologies LLP *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.compiere.model;

import java.util.Properties;

public class CalloutDepositBatch extends CalloutEngine
{

/**
* Bank Account Changed.
* Update Currency
* @param ctx context
* @param WindowNo window no
* @param mTab tab
* @param mField field
* @param value value
* @return null or error message
*/
public String bankAccount (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
if (value == null)
return "";
int C_BankAccount_ID = ((Integer)value).intValue();
MBankAccount ba = MBankAccount.get(ctx, C_BankAccount_ID);
mTab.setValue(MCurrency.COLUMNNAME_C_Currency_ID, ba.getC_Currency_ID());
return "";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ private String match (MBankStatementLine bsl)
bsl.setC_Invoice_ID(info.getC_Invoice_ID());
if (info.getC_BPartner_ID() > 0)
bsl.setC_BPartner_ID(info.getC_BPartner_ID());
if (info.getC_DepositBatch_ID() > 0)
bsl.setC_DepositBatch_ID(info.getC_DepositBatch_ID());
bsl.saveEx();
return "OK";
}
Expand Down

This file was deleted.

68 changes: 68 additions & 0 deletions org.adempiere.base/src/org/compiere/acct/DocLine_DepositBatch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.compiere.acct;

import org.compiere.model.MBankStatement;
import org.compiere.model.MPayment;
import org.compiere.util.DB;

/**
* Deposit Batch Line
* @author Deepak Pansheriya
*
*/
public class DocLine_DepositBatch extends DocLine {

public DocLine_DepositBatch(MPayment line, Doc_BankStatement doc, Boolean isReversal) {
super(line, doc);

MPayment payment = new MPayment(line.getCtx(), line.getC_Payment_ID(), line.get_TrxName());

m_C_Payment_ID = line.getC_Payment_ID();
m_IsReversal = isReversal;

//
setDateDoc(payment.getDateTrx());
setDateAcct(MBankStatement.isPostWithDateFromLine(doc.getAD_Client_ID()) ? line.getDateAcct() : doc.getDateAcct());
setC_BPartner_ID(payment.getC_BPartner_ID());
}

/** Reversal Flag */
private boolean m_IsReversal = false;
/** Payment */
private int m_C_Payment_ID = 0;

/**
* Get Payment
*
* @return C_Paymnet_ID
*/
public int getC_Payment_ID() {
return m_C_Payment_ID;
} // getC_Payment_ID

/**
* Get AD_Org_ID
*
* @param payment
* if true get Org from payment
* @return org
*/
public int getAD_Org_ID(boolean payment) {
if (payment && getC_Payment_ID() != 0) {
String sql = "SELECT AD_Org_ID FROM C_Payment WHERE C_Payment_ID=?";
int id = DB.getSQLValue(null, sql, getC_Payment_ID());
if (id > 0)
return id;
}
return super.getAD_Org_ID();
} // getAD_Org_ID

/**
* Is Reversal
*
* @return true if reversal
*/
public boolean isReversal() {
return m_IsReversal;
} // isReversal

} // DocLine_DepositBatch
61 changes: 43 additions & 18 deletions org.adempiere.base/src/org/compiere/acct/Doc_BankStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.compiere.model.MBankAccount;
import org.compiere.model.MBankStatement;
import org.compiere.model.MBankStatementLine;
import org.compiere.model.MDepositBatchLine;
import org.compiere.model.MPayment;
import org.compiere.util.Env;

/**
Expand Down Expand Up @@ -187,9 +189,7 @@ public ArrayList<Fact> createFacts (MAcctSchema as)
if (amt_stmt_minus_trx.compareTo(Env.ZERO) != 0) {

// BankAsset DR CR (Statement minus Payment)
fl = fact.createLine(line,
getAccount(Doc.ACCTTYPE_BankAsset, as),
line.getC_Currency_ID(), amt_stmt_minus_trx);
fl = fact.createLine(line, acct_bank_asset, line.getC_Currency_ID(), amt_stmt_minus_trx);
if (fl != null && AD_Org_ID != 0)
fl.setAD_Org_ID(AD_Org_ID);
if (fl != null && C_BPartner_ID != 0)
Expand All @@ -202,26 +202,51 @@ public ArrayList<Fact> createFacts (MAcctSchema as)
// Normal Adempiere behavior -- unchanged if using clearing accounts

// BankAsset DR CR (Statement)
fl = fact.createLine(line,
getAccount(Doc.ACCTTYPE_BankAsset, as),
line.getC_Currency_ID(), line.getStmtAmt());
fl = fact.createLine(line, acct_bank_asset, line.getC_Currency_ID(), line.getStmtAmt());
if (fl != null && AD_Org_ID != 0)
fl.setAD_Org_ID(AD_Org_ID);
if (fl != null && C_BPartner_ID != 0)
fl.setC_BPartner_ID(C_BPartner_ID);

// BankInTransit DR CR (Payment)
fl = fact.createLine(line,
getAccount(Doc.ACCTTYPE_BankInTransit, as),
line.getC_Currency_ID(), line.getTrxAmt().negate());
if (fl != null)
{
if (C_BPartner_ID != 0)
fl.setC_BPartner_ID(C_BPartner_ID);
if (AD_Org_ID != 0)
fl.setAD_Org_ID(AD_Org_ID);
else
fl.setAD_Org_ID(line.getAD_Org_ID(true)); // from payment
// BankInTransit DR CR (Payment)
MBankStatementLine statementLine = (MBankStatementLine) line.getPO();

if (statementLine.getC_DepositBatch_ID() != 0) {

// All Deposit Line
MDepositBatchLine[] depositBatchLines = statementLine.getC_DepositBatch().getLines();

for (MDepositBatchLine depositLine : depositBatchLines) {

MPayment payment = depositLine.getC_Payment();
DocLine_DepositBatch docDepositLine = new DocLine_DepositBatch(payment, this,
statementLine.isReversal());

fl = fact.createLine(docDepositLine, getAccount(Doc.ACCTTYPE_BankInTransit, as),
payment.getC_Currency_ID(),
payment.isReceipt() ? payment.getPayAmt().negate() : payment.getPayAmt());
// line id
fl.setLine_ID(statementLine.get_ID());
if (fl != null) {
if (C_BPartner_ID != 0)
fl.setC_BPartner_ID(C_BPartner_ID);
if (AD_Org_ID != 0)
fl.setAD_Org_ID(AD_Org_ID);
else
fl.setAD_Org_ID(docDepositLine.getAD_Org_ID(true)); // from payment
}
}
} else {
fl = fact.createLine(line, getAccount(Doc.ACCTTYPE_BankInTransit, as), line.getC_Currency_ID(), line.getTrxAmt().negate());

if (fl != null) {
if (C_BPartner_ID != 0)
fl.setC_BPartner_ID(C_BPartner_ID);
if (AD_Org_ID != 0)
fl.setAD_Org_ID(AD_Org_ID);
else
fl.setAD_Org_ID(line.getAD_Org_ID(true)); // from payment
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ public BankStatementMatchInfo()
private int m_C_BPartner_ID = 0;
private int m_C_Payment_ID = 0;
private int m_C_Invoice_ID = 0;
private int m_C_DepositBatch_ID = 0;

/**
* Do we have a match?
* @return true if something could be matched
*/
public boolean isMatched()
{
return m_C_BPartner_ID > 0 || m_C_Payment_ID > 0 || m_C_Invoice_ID > 0;
return m_C_BPartner_ID > 0 || m_C_Payment_ID > 0 || m_C_Invoice_ID > 0 || m_C_DepositBatch_ID > 0;
} // isValid

/**
Expand Down Expand Up @@ -98,4 +99,22 @@ public void setC_Invoice_ID (int C_Invoice_ID)
m_C_Invoice_ID = C_Invoice_ID;
}

/**
* Get matched Deposit Batch
* @return Deposit Batch
*/
public int getC_DepositBatch_ID()
{
return m_C_DepositBatch_ID;
}

/**
* Set matched Deposit Batch
* @param C_DepositBatch_ID
*/
public void setC_DepositBatch_ID (int C_DepositBatch_ID)
{
m_C_DepositBatch_ID = C_DepositBatch_ID;
}

} // BankStatementMatchInfo
Loading

0 comments on commit e050878

Please sign in to comment.