Skip to content

Commit 3ae2823

Browse files
committed
Add validation for bank statement line without lines with payment
reference
1 parent 9a3533b commit 3ae2823

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

base/src/org/compiere/model/MBankStatement.java

+43-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.compiere.util.Env;
3535
import org.compiere.util.Msg;
3636
import org.compiere.util.TimeUtil;
37+
import org.compiere.util.Util;
3738

3839

3940
/**
@@ -442,7 +443,48 @@ public String completeIt()
442443
if (!isApproved())
443444
approveIt();
444445
log.info("completeIt - " + toString());
445-
446+
StringBuffer linesWithoutReference = new StringBuffer();
447+
Arrays.asList(getLines(true)).stream()
448+
.filter(statementLine -> statementLine.getC_Payment_ID() == 0)
449+
.forEach(statementLine -> {
450+
if(linesWithoutReference.length() > 0) {
451+
linesWithoutReference.append(Env.NL);
452+
}
453+
// Add
454+
StringBuffer displayValue = new StringBuffer();
455+
displayValue.append(statementLine.getLine());
456+
// Reference No
457+
if(!Util.isEmpty(statementLine.getReferenceNo())) {
458+
displayValue.append(" - @ReferenceNo@: ").append(statementLine.getReferenceNo());
459+
}
460+
// Memo
461+
if(!Util.isEmpty(statementLine.getMemo())) {
462+
displayValue.append(" - @Memo@: ").append(statementLine.getMemo());
463+
}
464+
// EFT Check No
465+
if(!Util.isEmpty(statementLine.getEftCheckNo())) {
466+
displayValue.append(" - @EftCheckNo@: ").append(statementLine.getEftCheckNo());
467+
}
468+
if(!Util.isEmpty(statementLine.getEftMemo())) {
469+
displayValue.append(" - @EftMemo@: ").append(statementLine.getEftMemo());
470+
}
471+
// Add amount
472+
if (statementLine.getTrxAmt().compareTo(Env.ZERO) != 0) {
473+
displayValue.append(" - @TrxAmt@: ").append(DisplayType.getNumberFormat(DisplayType.Amount).format(statementLine.getTrxAmt()));
474+
}
475+
if (statementLine.getChargeAmt().compareTo(Env.ZERO) != 0) {
476+
displayValue.append(" - @ChargeAmt@: ").append(DisplayType.getNumberFormat(DisplayType.Amount).format(statementLine.getChargeAmt()));
477+
}
478+
if (statementLine.getInterestAmt().compareTo(Env.ZERO) != 0) {
479+
displayValue.append(" - @InterestAmt@: ").append(DisplayType.getNumberFormat(DisplayType.Amount).format(statementLine.getInterestAmt()));
480+
}
481+
// Add info
482+
linesWithoutReference.append(displayValue);
483+
});
484+
// Validate
485+
if(linesWithoutReference.length() > 0) {
486+
throw new AdempiereException("@Error@" + Env.NL + " @C_Payment_ID@ @NotFound@ " + Env.NL + linesWithoutReference.toString());
487+
}
446488
// Set Payment reconciled
447489
MBankStatementLine[] lines = getLines(false);
448490
for (int i = 0; i < lines.length; i++)

0 commit comments

Comments
 (0)