Search in sources :

Example 6 with MBankStatementLine

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("??");
}
Also used : AdempiereSystemError(org.compiere.util.AdempiereSystemError) X_I_BankStatement(org.compiere.model.X_I_BankStatement) MBankStatementLine(org.compiere.model.MBankStatementLine)

Example 7 with MBankStatementLine

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());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AdempiereException(org.adempiere.exceptions.AdempiereException) MPayment(org.compiere.model.MPayment) AtomicReference(java.util.concurrent.atomic.AtomicReference) MBankStatement(org.compiere.model.MBankStatement) MBankStatementLine(org.compiere.model.MBankStatementLine) Timestamp(java.sql.Timestamp) MBankAccount(org.compiere.model.MBankAccount) BigDecimal(java.math.BigDecimal)

Example 8 with MBankStatementLine

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();
}
Also used : MBankStatement(org.compiere.model.MBankStatement) MBankStatementLine(org.compiere.model.MBankStatementLine)

Aggregations

MBankStatementLine (org.compiere.model.MBankStatementLine)8 MBankStatement (org.compiere.model.MBankStatement)6 BigDecimal (java.math.BigDecimal)3 MPayment (org.compiere.model.MPayment)3 X_I_BankStatement (org.compiere.model.X_I_BankStatement)3 Timestamp (java.sql.Timestamp)2 MBankAccount (org.compiere.model.MBankAccount)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 MPeriod (org.compiere.model.MPeriod)1 AdempiereSystemError (org.compiere.util.AdempiereSystemError)1 KeyNamePair (org.compiere.util.KeyNamePair)1