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 "??";
}
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;
}
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();
}
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;
}
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;
}
Aggregations