/** * Get AD_Org_ID from Bank Account * * @return AD_Org_ID or 0 */ private final int getBank_Org_ID() { final I_C_BP_BankAccount bpBankAccount = getC_BP_BankAccount(); if (bpBankAccount == null) { return 0; } return bpBankAccount.getAD_Org_ID(); }
/** * 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
@Override public void updateFromInvoice(final org.compiere.model.I_C_PaySelectionLine psl) { final I_C_PaySelectionLine pslExt = InterfaceWrapperHelper.create(psl, I_C_PaySelectionLine.class); if (Services.get(IPaymentRequestBL.class).isUpdatedFromPaymentRequest(pslExt)) { return; } if (psl.getC_Invoice_ID() <= 0) { return; // nothing to do yet, but as C_PaySelectionLine.C_Invoice_ID is mandatory, we only // need to make sure this method is eventually called from a model interceptor } final IBPBankAccountDAO bpBankAccountDAO = Services.get(IBPBankAccountDAO.class); final Properties ctx = InterfaceWrapperHelper.getCtx(pslExt); final int partnerID = pslExt.getC_Invoice().getC_BPartner_ID(); pslExt.setC_BPartner_ID(partnerID); final String paymentRule = pslExt.getPaymentRule(); // task 09500 get the currency from the account of the selection header // this is safe because the columns are mandatory final int currencyID = pslExt.getC_PaySelection().getC_BP_BankAccount().getC_Currency_ID(); final List<I_C_BP_BankAccount> bankAccts = bpBankAccountDAO.retrieveBankAccountsForPartnerAndCurrency(ctx, partnerID, currencyID); if (!bankAccts.isEmpty()) { int primaryAcct = 0; int secondaryAcct = 0; for (final I_C_BP_BankAccount account : bankAccts) { final int accountID = account.getC_BP_BankAccount_ID(); if (accountID > 0) { if (account.getBPBankAcctUse().equals(X_C_BP_BankAccount.BPBANKACCTUSE_Both)) { secondaryAcct = accountID; } else if (account.getBPBankAcctUse().equals(paymentRule)) { primaryAcct = accountID; break; } } } if (primaryAcct != 0) { pslExt.setC_BP_BankAccount_ID(primaryAcct); } else if (secondaryAcct != 0) { pslExt.setC_BP_BankAccount_ID(secondaryAcct); } } // 08297: After trying to set the Reference from the payment request, fallback (if still empty) // to the Invoice's POReference final boolean trimWhitespaces = true; if (Check.isEmpty(pslExt.getReference(), trimWhitespaces)) { final I_C_Invoice invoice = pslExt.getC_Invoice(); if (invoice == null) { return; } final String invoicePOReference = invoice.getPOReference(); if (Check.isEmpty(invoicePOReference, trimWhitespaces)) { return; } pslExt.setReference(invoicePOReference); } }