/** * Create Payment for BankStatement * * @param bsl bank statement Line * @return Message * @throws Exception if not successful */ private String createPayment(MBankStatementLine bsl) throws Exception { if (bsl == null || bsl.getC_Payment_ID() != 0) return "--"; log.debug(bsl.toString()); if (bsl.getC_Invoice_ID() == 0 && bsl.getC_BPartner_ID() == 0) throw new AdempiereUserError("@NotFound@ @C_Invoice_ID@ / @C_BPartner_ID@"); // MBankStatement bs = new MBankStatement(getCtx(), bsl.getC_BankStatement_ID(), get_TrxName()); // MPayment payment = createPayment( bsl.getC_Invoice_ID(), bsl.getC_BPartner_ID(), bsl.getC_Currency_ID(), bsl.getStmtAmt(), bsl.getTrxAmt(), bs.getC_BP_BankAccount_ID(), bsl.getStatementLineDate(), bsl.getDateAcct(), bsl.getDescription(), bsl.getAD_Org_ID()); if (payment == null) throw new AdempiereSystemError("Could not create Payment"); // update statement bsl.setPayment(payment); bsl.save(); // String retString = "@C_Payment_ID@ = " + payment.getDocumentNo(); if (payment.getOverUnderAmt().signum() != 0) retString += " - @OverUnderAmt@=" + payment.getOverUnderAmt(); return retString; } // createPayment
/** * Perform Match * * @param bsl bank statement line * @return Message */ private String match(MBankStatementLine bsl) { if (m_matchers == null || bsl == null || bsl.getC_Payment_ID() != 0) return "--"; log.fine("match - " + bsl); BankStatementMatchInfo info = null; for (MBankStatementMatcher element : m_matchers) { if (element.isMatcherValid()) { info = element.getMatcher().findMatch(bsl); if (info != null && info.isMatched()) { if (info.getC_Payment_ID() > 0) bsl.setC_Payment_ID(info.getC_Payment_ID()); if (info.getC_Invoice_ID() > 0) bsl.setC_Invoice_ID(info.getC_Invoice_ID()); if (info.getC_BPartner_ID() > 0) bsl.setC_BPartner_ID(info.getC_BPartner_ID()); bsl.save(); return "OK"; } } } // for all matchers return "--"; } // match