Search in sources :

Example 1 with MBankStatement

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

the class BankStatementMatcher 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();
    if (m_matchers == null || m_matchers.length == 0)
        throw new IllegalStateException("No Matchers found");
    //
    log.info("doIt - Table_ID=" + Table_ID + ", Record_ID=" + Record_ID + ", Matchers=" + m_matchers.length);
    if (Table_ID == X_I_BankStatement.Table_ID)
        return match(new X_I_BankStatement(getCtx(), Record_ID, get_TrxName()));
    else if (Table_ID == MBankStatement.Table_ID)
        return match(new MBankStatement(getCtx(), Record_ID, get_TrxName()));
    else if (Table_ID == MBankStatementLine.Table_ID)
        return match(new MBankStatementLine(getCtx(), Record_ID, get_TrxName()));
    return "??";
}
Also used : X_I_BankStatement(org.compiere.model.X_I_BankStatement) MBankStatement(org.compiere.model.MBankStatement) MBankStatementLine(org.compiere.model.MBankStatementLine)

Example 2 with MBankStatement

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

the class CreateFromStatement method save.

/**
	 *  Save Statement - Insert Data
	 *  @return true if saved
	 */
public boolean save(IMiniTable miniTable, String trxName) {
    //  fixed values
    MBankStatement bs = new MBankStatement(Env.getCtx(), m_Record_ID, trxName);
    log.config(bs.toString());
    //  Lines
    for (int i = 0; i < miniTable.getRowCount(); i++) {
        if (((Boolean) miniTable.getValueAt(i, 0)).booleanValue()) {
            //  1-DateTrx
            Timestamp trxDate = (Timestamp) miniTable.getValueAt(i, 1);
            //  2-C_Payment_ID
            KeyNamePair pp = (KeyNamePair) miniTable.getValueAt(i, 2);
            int C_Payment_ID = pp.getKey();
            //  3-Currency
            pp = (KeyNamePair) miniTable.getValueAt(i, 3);
            int C_Currency_ID = pp.getKey();
            //  5- Conv Amt
            BigDecimal TrxAmt = (BigDecimal) miniTable.getValueAt(i, 5);
            log.fine("Line Date=" + trxDate + ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
            //	
            MBankStatementLine bsl = new MBankStatementLine(bs);
            // BF3439695 - Create from for Statement Line picks wrong date
            bsl.setDateAcct(bs.getStatementDate());
            bsl.setStatementLineDate(bs.getStatementDate());
            bsl.setValutaDate(trxDate);
            bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, trxName));
            bsl.setTrxAmt(TrxAmt);
            bsl.setStmtAmt(TrxAmt);
            bsl.setC_Currency_ID(m_BankAccount.getC_Currency_ID());
            if (!bsl.save())
                log.log(Level.SEVERE, "Line not created #" + i);
        }
    //   if selected
    }
    //  for all rows
    return true;
}
Also used : MPayment(org.compiere.model.MPayment) MBankStatement(org.compiere.model.MBankStatement) KeyNamePair(org.compiere.util.KeyNamePair) MBankStatementLine(org.compiere.model.MBankStatementLine) Timestamp(java.sql.Timestamp) BigDecimal(java.math.BigDecimal)

Example 3 with MBankStatement

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

the class CreateFromStatement method validTable.

/**
	 * Valid Table and Record Identifier
	 * @param p_AD_Table_ID
	 * @param p_Record_ID
	 */
protected void validTable(int p_AD_Table_ID, int p_Record_ID) {
    //	Valid Table
    if (p_AD_Table_ID != I_C_BankStatement.Table_ID) {
        throw new AdempiereException("@AD_Table_ID@ @C_BankStatement_ID@ @NotFound@");
    }
    //	Valid Record Identifier
    if (p_Record_ID <= 0) {
        throw new AdempiereException("@SaveErrorRowNotFound@");
    }
    //	Default
    m_Record_ID = p_Record_ID;
    //	Instance Bank Statement
    m_BankStatement = new MBankStatement(Env.getCtx(), m_Record_ID, null);
    m_BankAccount = m_BankStatement.getBankAccount();
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) MBankStatement(org.compiere.model.MBankStatement)

Example 4 with MBankStatement

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

the class CloseStatementPOS method getBankStatements.

private LinkedHashMap<Integer, MBankStatement> getBankStatements() {
    if (baskStatements != null && baskStatements.size() > 0)
        return baskStatements;
    baskStatements = new LinkedHashMap<Integer, MBankStatement>();
    List<MPayment> payments = (List<MPayment>) getInstancesForSelection(get_TrxName());
    payments.stream().forEach(payment -> {
        Integer bankStatementLineId = getSelectionAsInt(payment.get_ID(), "BSL_C_BankStatementLine_ID");
        if (bankStatementLineId != null && bankStatementLineId > 0) {
            MBankStatementLine bankStatementLine = new MBankStatementLine(getCtx(), bankStatementLineId, get_TrxName());
            MBankStatement bankStatement = bankStatementLine.getParent();
            if (!baskStatements.containsKey(bankStatement.get_ID()))
                baskStatements.put(bankStatement.get_ID(), bankStatement);
        }
    });
    return baskStatements;
}
Also used : MPayment(org.compiere.model.MPayment) List(java.util.List) MBankStatement(org.compiere.model.MBankStatement) MBankStatementLine(org.compiere.model.MBankStatementLine)

Example 5 with MBankStatement

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

the class Doc_BankStatement method loadDocumentDetails.

/**
	 *  Load Specific Document Details
	 *  @return error message or null
	 */
protected String loadDocumentDetails() {
    MBankStatement bs = (MBankStatement) getPO();
    setDateDoc(bs.getStatementDate());
    //	Overwritten on Line Level
    setDateAcct(bs.getStatementDate());
    m_C_BankAccount_ID = bs.getC_BankAccount_ID();
    //	Amounts
    setAmount(AMTTYPE_Gross, bs.getStatementDifference());
    //  Set Bank Account Info (Currency)
    MBankAccount ba = MBankAccount.get(getCtx(), m_C_BankAccount_ID);
    setC_Currency_ID(ba.getC_Currency_ID());
    //	Contained Objects
    p_lines = loadLines(bs);
    log.fine("Lines=" + p_lines.length);
    return null;
}
Also used : MBankStatement(org.compiere.model.MBankStatement) MBankAccount(org.compiere.model.MBankAccount)

Aggregations

MBankStatement (org.compiere.model.MBankStatement)13 MBankStatementLine (org.compiere.model.MBankStatementLine)9 MPayment (org.compiere.model.MPayment)7 BigDecimal (java.math.BigDecimal)6 MBankAccount (org.compiere.model.MBankAccount)5 Timestamp (java.sql.Timestamp)3 KeyNamePair (org.compiere.util.KeyNamePair)3 AdempiereException (org.adempiere.exceptions.AdempiereException)2 X_I_BankStatement (org.compiere.model.X_I_BankStatement)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 AdempiereSystemError (org.compiere.util.AdempiereSystemError)1 AdempiereUserError (org.compiere.util.AdempiereUserError)1