IDEMPIERE-1104 : SysConfig for posting using bank statement line date (#1149)

* IDEMPIERE-1104 : SysConfig for posting using bank statement line date

* IDEMPIERE-1104 : SysConfig for posting using bank statement line date - compare periods using IDs

* @nmicoud IDEMPIERE-1104 : SysConfig for posting using bank statement line date

change method's name and javadoc
This commit is contained in:
Nicolas Micoud 2022-02-01 17:37:20 +01:00 committed by GitHub
parent 35220381f7
commit 81bb438237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 4 deletions

View File

@ -0,0 +1,14 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-1104
-- Jan 27, 2022, 4:33:43 PM CET
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','The date on line {0} is not in the same period as header''''s date',0,0,'Y',TO_DATE('2022-01-27 16:33:43','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2022-01-27 16:33:43','YYYY-MM-DD HH24:MI:SS'),0,200725,'BankStatementLinePeriodNotSameAsHeader','D','2d919960-34f1-4ef4-a159-f0ae40e4d3bc')
;
-- Jan 27, 2022, 4:34:08 PM CET
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200192,0,0,TO_DATE('2022-01-27 16:34:07','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2022-01-27 16:34:07','YYYY-MM-DD HH24:MI:SS'),0,0,'Y','BANK_STATEMENT_POST_WITH_DATE_FROM_LINE','N','Setting it to Y can lead to potential issues if a bank statement cover several periods (see https://idempiere.atlassian.net/browse/IDEMPIERE-480 and https://idempiere.atlassian.net/browse/IDEMPIERE-1104)','D','C','2c5f249e-2e08-4e02-a390-f7573443e0fe')
;
SELECT register_migration_script('202201271630_IDEMPIERE-1104.sql') FROM dual
;

View File

@ -0,0 +1,11 @@
-- IDEMPIERE-1104
-- Jan 27, 2022, 4:33:43 PM CET
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','The date on line {0} is not in the same period as header''''s date',0,0,'Y',TO_TIMESTAMP('2022-01-27 16:33:43','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2022-01-27 16:33:43','YYYY-MM-DD HH24:MI:SS'),0,200725,'BankStatementLinePeriodNotSameAsHeader','D','2d919960-34f1-4ef4-a159-f0ae40e4d3bc')
;
-- Jan 27, 2022, 4:34:08 PM CET
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200192,0,0,TO_TIMESTAMP('2022-01-27 16:34:07','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2022-01-27 16:34:07','YYYY-MM-DD HH24:MI:SS'),0,0,'Y','BANK_STATEMENT_POST_WITH_DATE_FROM_LINE','N','Setting it to Y can lead to potential issues if a bank statement cover several periods (see https://idempiere.atlassian.net/browse/IDEMPIERE-480 and https://idempiere.atlassian.net/browse/IDEMPIERE-1104)','D','C','2c5f249e-2e08-4e02-a390-f7573443e0fe')
;
SELECT register_migration_script('202201271630_IDEMPIERE-1104.sql') FROM dual
;

View File

@ -18,6 +18,7 @@ package org.compiere.acct;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.compiere.model.MBankStatement;
import org.compiere.model.MBankStatementLine; import org.compiere.model.MBankStatementLine;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -46,7 +47,7 @@ public class DocLine_Bank extends DocLine
m_TrxAmt = line.getTrxAmt(); m_TrxAmt = line.getTrxAmt();
// //
setDateDoc(line.getValutaDate()); setDateDoc(line.getValutaDate());
setDateAcct(doc.getDateAcct()); // adaxa-pb use statement date setDateAcct(MBankStatement.isPostWithDateFromLine(doc.getAD_Client_ID()) ? line.getDateAcct() : doc.getDateAcct());
setC_BPartner_ID(line.getC_BPartner_ID()); setC_BPartner_ID(line.getC_BPartner_ID());
} // DocLine_Bank } // DocLine_Bank

View File

@ -52,7 +52,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction
/** /**
* *
*/ */
private static final long serialVersionUID = 4286511528899179483L; private static final long serialVersionUID = -5635804381201264475L;
/** /**
* Standard Constructor * Standard Constructor
@ -313,6 +313,12 @@ public class MBankStatement extends X_C_BankStatement implements DocAction
MBankStatementLine line = lines[i]; MBankStatementLine line = lines[i];
if (!line.isActive()) if (!line.isActive())
continue; continue;
if (!line.isDateConsistentIfUsedForPosting()) {
m_processMsg = Msg.getMsg(getCtx(), "BankStatementLinePeriodNotSameAsHeader", new Object[] {line.getLine()});
return DocAction.STATUS_Invalid;
}
total = total.add(line.getStmtAmt()); total = total.add(line.getStmtAmt());
} }
setStatementDifference(total); setStatementDifference(total);
@ -644,5 +650,9 @@ public class MBankStatement extends X_C_BankStatement implements DocAction
|| DOCSTATUS_Closed.equals(ds) || DOCSTATUS_Closed.equals(ds)
|| DOCSTATUS_Reversed.equals(ds); || DOCSTATUS_Reversed.equals(ds);
} // isComplete } // isComplete
public static boolean isPostWithDateFromLine(int clientID) {
return MSysConfig.getBooleanValue(MSysConfig.BANK_STATEMENT_POST_WITH_DATE_FROM_LINE, false, Env.getAD_Client_ID(Env.getCtx()));
}
} // MBankStatement } // MBankStatement

View File

@ -44,7 +44,7 @@ import org.compiere.util.Msg;
/** /**
* *
*/ */
private static final long serialVersionUID = 3809130336412385420L; private static final long serialVersionUID = -4479911757321927051L;
/** /**
* Standard Constructor * Standard Constructor
@ -163,6 +163,15 @@ import org.compiere.util.Msg;
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_BankStatement_ID")); log.saveError("ParentComplete", Msg.translate(getCtx(), "C_BankStatement_ID"));
return false; return false;
} }
// Make sure date is on the same period as header if used for posting
if (newRecord || is_ValueChanged(COLUMNNAME_DateAcct)) {
if (!isDateConsistentIfUsedForPosting()) {
log.saveError("SaveError", Msg.getMsg(getCtx(), "BankStatementLinePeriodNotSameAsHeader", new Object[] {getLine()}));
return false;
}
}
// Calculate Charge = Statement - trx - Interest // Calculate Charge = Statement - trx - Interest
BigDecimal amt = getStmtAmt(); BigDecimal amt = getStmtAmt();
amt = amt.subtract(getTrxAmt()); amt = amt.subtract(getTrxAmt());
@ -269,5 +278,19 @@ import org.compiere.util.Msg;
} }
return true; return true;
} // updateHeader } // updateHeader
/**
* If the posting is based on the date of the line (ie SysConfig BANK_STATEMENT_POST_WITH_DATE_FROM_LINE = Y), make sure line and header dates are on the same period
*/
public boolean isDateConsistentIfUsedForPosting() {
if (MBankStatement.isPostWithDateFromLine(getAD_Client_ID())) {
MPeriod headerPeriod = MPeriod.get(getCtx(), getParent().getDateAcct(), getParent().getAD_Org_ID(), get_TrxName());
MPeriod linePeriod = MPeriod.get(getCtx(), getDateAcct(), getParent().getAD_Org_ID(), get_TrxName());
return headerPeriod != null && linePeriod != null && headerPeriod.getC_Period_ID() == linePeriod.getC_Period_ID();
}
return true;
}
} // MBankStatementLine } // MBankStatementLine

View File

@ -44,7 +44,7 @@ public class MSysConfig extends X_AD_SysConfig
/** /**
* *
*/ */
private static final long serialVersionUID = 7257949078651339908L; private static final long serialVersionUID = -3851200335563922376L;
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION"; public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS"; public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
@ -75,6 +75,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String BACKGROUND_JOB_MAX_IN_SYSTEM = "BACKGROUND_JOB_MAX_IN_SYSTEM"; public static final String BACKGROUND_JOB_MAX_IN_SYSTEM = "BACKGROUND_JOB_MAX_IN_SYSTEM";
public static final String BACKGROUND_JOB_MAX_PER_CLIENT = "BACKGROUND_JOB_MAX_PER_CLIENT"; public static final String BACKGROUND_JOB_MAX_PER_CLIENT = "BACKGROUND_JOB_MAX_PER_CLIENT";
public static final String BACKGROUND_JOB_MAX_PER_USER = "BACKGROUND_JOB_MAX_PER_USER"; public static final String BACKGROUND_JOB_MAX_PER_USER = "BACKGROUND_JOB_MAX_PER_USER";
public static final String BANK_STATEMENT_POST_WITH_DATE_FROM_LINE = "BANK_STATEMENT_POST_WITH_DATE_FROM_LINE";
public static final String BPARTNER_QUICK_ENTRY_OPTIONAL_LOCATION_TABLES = "BPARTNER_QUICK_ENTRY_OPTIONAL_LOCATION_TABLES"; public static final String BPARTNER_QUICK_ENTRY_OPTIONAL_LOCATION_TABLES = "BPARTNER_QUICK_ENTRY_OPTIONAL_LOCATION_TABLES";
public static final String CALENDAR_ALTERNATE_TIMEZONE = "CALENDAR_ALTERNATE_TIMEZONE"; public static final String CALENDAR_ALTERNATE_TIMEZONE = "CALENDAR_ALTERNATE_TIMEZONE";
public static final String CASH_AS_PAYMENT = "CASH_AS_PAYMENT"; public static final String CASH_AS_PAYMENT = "CASH_AS_PAYMENT";