use of org.compiere.model.MBankStatementLine in project adempiere by adempiere.
the class BankStatementPayment method doIt.
// prepare
/**
* Perform process.
* @return Message
* @throws Exception if not successful
*/
protected String doIt() throws Exception {
int Table_ID = getTable_ID();
int Record_ID = getRecord_ID();
log.info("Table_ID=" + Table_ID + ", Record_ID=" + Record_ID);
if (Table_ID == X_I_BankStatement.Table_ID)
return createPayment(new X_I_BankStatement(getCtx(), Record_ID, get_TrxName()));
else if (Table_ID == MBankStatementLine.Table_ID)
return createPayment(new MBankStatementLine(getCtx(), Record_ID, get_TrxName()));
throw new AdempiereSystemError("??");
}
use of org.compiere.model.MBankStatementLine in project adempiere by adempiere.
the class StatementCreateFrom method doIt.
@Override
protected String doIt() throws Exception {
// fixed values
if (getRecord_ID() <= 0)
throw new AdempiereException("@C_BankStatement_ID@ @NotFound@");
MBankStatement bankStatement = new MBankStatement(Env.getCtx(), getRecord_ID(), get_TrxName());
// Get Bank Account
MBankAccount bankAccount = bankStatement.getBankAccount();
// Created
AtomicInteger created = new AtomicInteger(0);
// Total Amount
AtomicReference<BigDecimal> totalAmt = new AtomicReference<>(BigDecimal.ZERO);
log.config(bankStatement.toString());
// Lines
getSelectionKeys().stream().forEach(key -> {
Timestamp dateTransaction = getSelectionAsTimestamp(key, "P_DateTrx");
int paymentId = getSelectionAsInt(key, "P_C_Payment_ID");
int currencyId = getSelectionAsInt(key, "P_C_Currency_ID");
BigDecimal transactionAmount = getSelectionAsBigDecimal(key, "P_ConvertedAmount");
log.fine("Line Date=" + dateTransaction + ", Payment=" + paymentId + ", Currency=" + currencyId + ", Amt=" + transactionAmount);
MBankStatementLine bankStatementLine = new MBankStatementLine(bankStatement);
bankStatementLine.setDateAcct(bankStatement.getStatementDate());
bankStatementLine.setStatementLineDate(bankStatement.getStatementDate());
bankStatementLine.setValutaDate(dateTransaction);
MPayment payment = new MPayment(Env.getCtx(), paymentId, get_TrxName());
bankStatementLine.setPayment(payment);
bankStatementLine.setTrxAmt(transactionAmount);
bankStatementLine.setStmtAmt(transactionAmount);
bankStatementLine.setC_Currency_ID(bankAccount.getC_Currency_ID());
bankStatementLine.saveEx();
created.updateAndGet(createNo -> createNo + 1);
totalAmt.updateAndGet(amt -> amt.add(payment.isReceipt() ? payment.getPayAmt() : payment.getPayAmt().negate()));
});
// Return Created
return "@Created@ = " + created.get() + " - @PayAmt@ = " + DisplayType.getNumberFormat(DisplayType.Amount).format(totalAmt.get());
}
use of org.compiere.model.MBankStatementLine in project adempiere by adempiere.
the class CloseStatementPOS method generateLostOrProfit.
private void generateLostOrProfit() {
MBankStatement bankStatement = (MBankStatement) getBankStatements().entrySet().iterator().next();
MBankStatementLine bankStatementLine = new MBankStatementLine(bankStatement);
bankStatementLine.setDateAcct(getTransactionDate());
bankStatementLine.setStatementLineDate(getTransactionDateTo());
bankStatementLine.setStmtAmt(getDifference());
bankStatementLine.setC_Charge_ID(getChargeId());
bankStatementLine.setChargeAmt(getDifference());
bankStatementLine.saveEx();
}
Aggregations