use of org.compiere.model.MPaySelection in project adempiere by adempiere.
the class MPaySelectionTest method testQuery.
public void testQuery() throws Exception {
lines = new MPaySelection(getCtx(), 100, getTrxName());
List<MPaySelectionLine> payselection = lines.getLines(true);
assertTrue("There should be payment lines", payselection.size() > 0);
}
use of org.compiere.model.MPaySelection in project adempiere by adempiere.
the class PaySelect method generatePaySelect.
/**
* Generate PaySelection
*/
public String generatePaySelect(IMiniTable miniTable, ValueNamePair paymentRule, Timestamp payDate, BankInfo bi) {
log.info("");
// String trxName Trx.createTrxName("PaySelect");
// Trx trx = Trx.get(trxName, true); trx needs to be committed too
String trxName = null;
trx = null;
String PaymentRule = paymentRule.getValue();
// Create Header
m_ps = new MPaySelection(Env.getCtx(), 0, trxName);
// FR [ 297 ]
m_ps.setDescription(Msg.getMsg(Env.getCtx(), "VPaySelect") + " - " + paymentRule.getName() + " - " + payDate);
m_ps.setPayDate(payDate);
m_ps.setC_BankAccount_ID(bi.C_BankAccount_ID);
m_ps.setIsApproved(true);
if (!m_ps.save()) {
m_ps = null;
return Msg.translate(Env.getCtx(), "C_PaySelection_ID");
}
log.config(m_ps.toString());
// Create Lines
int rows = miniTable.getRowCount();
int line = 0;
for (int i = 0; i < rows; i++) {
IDColumn id = (IDColumn) miniTable.getValueAt(i, 0);
Object ips_id = miniTable.getValueAt(i, 11);
if (id.isSelected()) {
line += 10;
MPaySelectionLine psl = new MPaySelectionLine(m_ps, line, PaymentRule);
int C_Invoice_ID = id.getRecord_ID().intValue();
int C_InvoicePaySchedule_ID = Integer.parseInt(ips_id.toString());
BigDecimal OpenAmt = (BigDecimal) miniTable.getValueAt(i, 9);
BigDecimal PayAmt = (BigDecimal) miniTable.getValueAt(i, 10);
boolean isSOTrx = false;
//
psl.setInvoice(C_Invoice_ID, C_InvoicePaySchedule_ID, isSOTrx, OpenAmt, PayAmt, OpenAmt.subtract(PayAmt));
if (!psl.save(trxName)) {
return Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID");
}
log.fine("C_Invoice_ID=" + C_Invoice_ID + ", PayAmt=" + PayAmt);
}
}
return null;
}
use of org.compiere.model.MPaySelection in project adempiere by adempiere.
the class PSCreateFromOrder method doIt.
@Override
protected String doIt() throws Exception {
// Instance current Payment Selection
MPaySelection paySelection = new MPaySelection(getCtx(), getRecord_ID(), get_TrxName());
m_SeqNo = paySelection.getLastLineNo();
// Loop for keys
for (Integer key : getSelectionKeys()) {
// get values from result set
int C_Order_ID = key;
String PaymentRule = getSelectionAsString(key, "ORD_PaymentRule");
BigDecimal GrandTotal = getSelectionAsBigDecimal(key, "ORD_GrandTotal");
BigDecimal ConvertedAmt = getSelectionAsBigDecimal(key, "ORD_ConvertedAmt");
BigDecimal PayAmt = getSelectionAsBigDecimal(key, "ORD_PayAmt");
m_SeqNo += 10;
MPaySelectionLine line = new MPaySelectionLine(paySelection, m_SeqNo, PaymentRule);
// Add Order
line.setOrder(C_Order_ID, GrandTotal, ConvertedAmt, PayAmt, Env.ZERO);
// Save
line.saveEx();
}
// Default Ok
return "@OK@";
}
use of org.compiere.model.MPaySelection in project adempiere by adempiere.
the class PSCreateFromPaySelection method doIt.
@Override
protected String doIt() throws Exception {
// Instance current Payment Selection
MPaySelection paySelection = new MPaySelection(getCtx(), getRecord_ID(), get_TrxName());
m_SeqNo = paySelection.getLastLineNo();
// Loop for keys
for (Integer key : getSelectionKeys()) {
// get values from result set
int C_PaySelectionLine_ID = key;
String PaymentRule = getSelectionAsString(key, "PSL_PaymentRule");
BigDecimal PayAmt = getSelectionAsBigDecimal(key, "PSL_PayAmt");
BigDecimal DiscountAmt = getSelectionAsBigDecimal(key, "PSL_DiscountAmt");
m_SeqNo += 10;
MPaySelectionLine line = new MPaySelectionLine(paySelection, m_SeqNo, PaymentRule);
// Add Order
line.setPaySelectionLineParent(C_PaySelectionLine_ID, PayAmt, DiscountAmt);
// Save
line.saveEx();
}
// Default Ok
return "@OK@";
}
use of org.compiere.model.MPaySelection in project adempiere by adempiere.
the class PaySelectionCreateCheck method doIt.
// prepare
/**
* Perform process.
* @return Message (clear text)
* @throws Exception if not successful
*/
protected String doIt() throws Exception {
log.info("C_PaySelection_ID=" + p_C_PaySelection_ID + ", PaymentRule=" + p_PaymentRule);
MPaySelection paySelection = new MPaySelection(getCtx(), p_C_PaySelection_ID, get_TrxName());
if (paySelection.get_ID() == 0)
throw new IllegalArgumentException("Not found C_PaySelection_ID=" + p_C_PaySelection_ID);
if (paySelection.isProcessed())
throw new IllegalArgumentException("@Processed@");
for (MPaySelectionLine paySelectionLine : paySelection.getLines(false)) {
if (!paySelectionLine.isActive() || paySelectionLine.isProcessed())
continue;
createCheck(paySelectionLine);
}
//
paySelection.setProcessed(true);
paySelection.saveEx();
return "@C_PaySelectionCheck_ID@ - #" + paySelectionChecks.size();
}
Aggregations