Search in sources :

Example 1 with MPaymentBatch

use of org.compiere.model.MPaymentBatch in project adempiere by adempiere.

the class GenerateWithdrawal method doIt.

@Override
protected String doIt() throws Exception {
    MPaymentBatch paymentBatchFrom = new MPaymentBatch(getCtx(), 0, get_TrxName());
    paymentBatchFrom.setName(getDescription());
    paymentBatchFrom.setProcessingDate(getTransactionDate());
    paymentBatchFrom.saveEx();
    MPaymentBatch paymentBatchTo = new MPaymentBatch(getCtx(), 0, get_TrxName());
    paymentBatchTo.setName(getDescription());
    paymentBatchTo.setProcessingDate(getTransactionDate());
    paymentBatchTo.saveEx();
    List<MRefList> refLists = (List<MRefList>) getInstancesForSelection(get_TrxName());
    refLists.stream().forEach(refList -> {
        BigDecimal amount = getSelectionAsBigDecimal(refList.get_ID(), "TT_Amount");
        String referenceNo = getSelectionAsString(refList.get_ID(), "TT_ReferenceNo");
        if (amount.signum() > 0) {
            createPayment(getBankAccountId(), getPOSTerminalId(), getBusinessPartnerId(), getDocumentNo(), paymentBatchFrom.getDocumentNo(), referenceNo, getDocumentTypeId(), getChargeId(), refList.getValue(), getCurrencyId(), amount, getTransactionDate(), getAccountDate(), false, paymentBatchFrom.get_ID());
            createPayment(getTransferCashtrxtoId(), getPOSTerminalId(), getBusinessPartnerId(), getDocumentNo(), referenceNo, paymentBatchTo.getDocumentNo(), getCounterDocumentTypeId(), getChargeId(), refList.getValue(), getCurrencyId(), amount, getTransactionDate(), getAccountDate(), true, paymentBatchTo.get_ID());
        }
    });
    return "@Ok@";
}
Also used : MRefList(org.compiere.model.MRefList) MPaymentBatch(org.compiere.model.MPaymentBatch) List(java.util.List) MRefList(org.compiere.model.MRefList) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)1 List (java.util.List)1 MPaymentBatch (org.compiere.model.MPaymentBatch)1 MRefList (org.compiere.model.MRefList)1