Пример #1
0
 /**
  * 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
  /**
   * Load Specific Document Details
   *
   * @return error message or null
   */
  @Override
  protected String loadDocumentDetails() {
    MBankStatement bs = (MBankStatement) getPO();
    setDateDoc(bs.getStatementDate());
    setDateAcct(bs.getStatementDate()); // Overwritten on Line Level
    setC_BP_BankAccount_ID(bs.getC_BP_BankAccount_ID());
    // Amounts
    setAmount(AMTTYPE_Gross, bs.getStatementDifference());

    // Set Bank Account Info (Currency)
    final I_C_BP_BankAccount ba = getC_BP_BankAccount(); // shall not be null
    setC_Currency_ID(ba.getC_Currency_ID());

    // Contained Objects
    p_lines = loadLines(bs);
    log.fine("Lines=" + p_lines.length);
    return null;
  } // loadDocumentDetails
  /**
   * Load Invoice Line.
   *
   * @param bs bank statement 4 amounts AMTTYPE_Payment AMTTYPE_Statement2 AMTTYPE_Charge
   *     AMTTYPE_Interest
   * @return DocLine Array
   */
  private DocLine[] loadLines(final MBankStatement bs) {
    ArrayList<DocLine> list = new ArrayList<DocLine>();
    MBankStatementLine[] lines = bs.getLines(false);
    for (int i = 0; i < lines.length; i++) {
      MBankStatementLine line = lines[i];
      DocLine_BankStatement docLine = new DocLine_BankStatement(line, this);
      // Set Date Acct
      if (i == 0) setDateAcct(line.getDateAcct());
      MPeriod period = MPeriod.get(getCtx(), line.getDateAcct(), line.getAD_Org_ID());
      if (period != null
          && period.isOpen(DOCTYPE_BankStatement, line.getDateAcct(), bs.getAD_Org_ID())) {
        docLine.setC_Period_ID(period.getC_Period_ID());
      }
      //
      list.add(docLine);
    }

    // Return Array
    DocLine[] dls = new DocLine[list.size()];
    list.toArray(dls);
    return dls;
  } // loadLines
Пример #4
0
 /**
  * Perform Match
  *
  * @param bs bank statement
  * @return Message
  */
 private String match(MBankStatement bs) {
   if (m_matchers == null || bs == null) return "--";
   log.fine("match - " + bs);
   int count = 0;
   MBankStatementLine[] lines = bs.getLines(false);
   for (MBankStatementLine element : lines) {
     if (element.getC_Payment_ID() == 0) {
       match(element);
       count++;
     }
   }
   return String.valueOf(count);
 } //	match