use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VInvoiceGenFromShipment method executeQuery.
public void executeQuery() {
KeyNamePair docTypeKNPair = (KeyNamePair) cmbDocType.getSelectedItem();
executeQuery(docTypeKNPair, panel.getMiniTable());
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VInvoiceGenFromShipment method dynInit.
/**
* Fill Picks.
* Column_ID from C_Order
* @throws Exception if Lookups cannot be initialized
*/
public void dynInit() throws Exception {
MLookup orgL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 2163, DisplayType.TableDir);
fOrg = new VLookup("AD_Org_ID", false, false, true, orgL);
// lOrg.setText(Msg.translate(Env.getCtx(), "AD_Org_ID"));
fOrg.addVetoableChangeListener(this);
MLookup docActionL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 3494, /* C_Invoice.DocStatus */
DisplayType.List, Env.getLanguage(Env.getCtx()), "DocAction", 135, /* _Document Action */
false, "AD_Ref_List.Value IN ('CO','PR')");
docAction = new VLookup("DocAction", true, false, true, docActionL);
// lDcoACtion.setText((Msg.translate(Env.getCtx(), "DocAction")););
docAction.addVetoableChangeListener(this);
//@Trifon - Pre-select "Prepare"
docAction.setValue("PR");
//
MLookup bpL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 2762, DisplayType.Search);
fBPartner = new VLookup("C_BPartner_ID", false, false, true, bpL);
// lBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
fBPartner.addVetoableChangeListener(this);
//Document Type: Shipment/Vendor RMA
lDocType.setText(Msg.translate(Env.getCtx(), "C_DocType_ID"));
cmbDocType.addItem(new KeyNamePair(MInOut.Table_ID, Msg.translate(Env.getCtx(), "M_InOut_ID")));
//cmbDocType.addItem(new KeyNamePair(MRMA.Table_ID, Msg.translate(Env.getCtx(), "CustomerRMA")));
cmbDocType.addActionListener(this);
//@@
panel.getStatusBar().setStatusLine(Msg.getMsg(Env.getCtx(), "InvGenerateSel"));
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VPayment method dynInit.
// jbInit
/**************************************************************************
* Dynamic Init.
* B (Cash) (Currency)
* K (CreditCard) Type, Number, Exp, Approval
* L (DirectDebit) BPartner_Bank
* P (PaymentTerm) PaymentTerm
* S (Check) (Currency) CheckNo, Routing
*
* Currencies are shown, if member of EMU
* @param button payment type button
* @return true if init OK
* @throws Exception
*/
private boolean dynInit(VButton button) throws Exception {
m_DocStatus = (String) m_mTab.getValue("DocStatus");
log.config(m_DocStatus);
if (m_mTab.getValue("C_BPartner_ID") == null) {
ADialog.error(0, this, "SaveErrorRowNotFound");
return false;
}
// Is the Trx posted?
// String Posted = (String)m_mTab.getValue("Posted");
// if (Posted != null && Posted.equals("Y"))
// return false;
// DocStatus
m_DocStatus = (String) m_mTab.getValue("DocStatus");
if (m_DocStatus == null)
m_DocStatus = "";
// Is the Trx closed? Reversed / Voided / Closed
if (m_DocStatus.equals("RE") || m_DocStatus.equals("VO") || m_DocStatus.equals("CL"))
return false;
// Document is not complete - allow to change the Payment Rule only
if (m_DocStatus.equals("CO") || m_DocStatus.equals("WP"))
m_onlyRule = false;
else
m_onlyRule = true;
// PO only Rule
if (// Only order has Warehouse
!m_onlyRule && !m_isSOTrx && m_mTab.getValue("M_Warehouse_ID") != null)
m_onlyRule = true;
centerPanel.setVisible(!m_onlyRule);
// Amount
m_Amount = (BigDecimal) m_mTab.getValue("GrandTotal");
if (!m_onlyRule && m_Amount.compareTo(Env.ZERO) == 0) {
ADialog.error(m_WindowNo, this, "PaymentZero");
return false;
}
bAmountField.setValue(m_Amount);
sAmountField.setValue(m_Amount);
kAmountField.setValue(m_Amount);
/**
* Get Data from Grid
*/
m_AD_Client_ID = ((Integer) m_mTab.getValue("AD_Client_ID")).intValue();
m_Cash_As_Payment = MSysConfig.getBooleanValue("CASH_AS_PAYMENT", true, m_AD_Client_ID);
m_AD_Org_ID = ((Integer) m_mTab.getValue("AD_Org_ID")).intValue();
m_C_BPartner_ID = ((Integer) m_mTab.getValue("C_BPartner_ID")).intValue();
m_PaymentRule = (String) m_mTab.getValue("PaymentRule");
m_C_Currency_ID = ((Integer) m_mTab.getValue("C_Currency_ID")).intValue();
m_DateAcct = (Timestamp) m_mTab.getValue("DateAcct");
if (m_mTab.getValue("C_PaymentTerm_ID") != null)
m_C_PaymentTerm_ID = ((Integer) m_mTab.getValue("C_PaymentTerm_ID")).intValue();
// Existing Payment
if (m_mTab.getValue("C_Payment_ID") != null) {
m_C_Payment_ID = ((Integer) m_mTab.getValue("C_Payment_ID")).intValue();
if (m_C_Payment_ID != 0) {
m_mPayment = new MPayment(Env.getCtx(), m_C_Payment_ID, null);
// full copy
m_mPaymentOriginal = new MPayment(Env.getCtx(), m_C_Payment_ID, null);
// CreditCard
m_CCType = m_mPayment.getCreditCardType();
kNumberField.setText(m_mPayment.getCreditCardNumber());
kNameField.setText(m_mPayment.getA_Name());
kExpField.setText(m_mPayment.getCreditCardExp(null));
kApprovalField.setText(m_mPayment.getVoiceAuthCode());
kStatus.setText(m_mPayment.getR_PnRef());
kAmountField.setValue(m_mPayment.getPayAmt());
// if approved/paid, don't let it change
kTypeCombo.setReadWrite(!m_mPayment.isApproved());
kNumberField.setReadWrite(!m_mPayment.isApproved());
kNameField.setReadWrite(!m_mPayment.isApproved());
kExpField.setReadWrite(!m_mPayment.isApproved());
kApprovalField.setReadWrite(!m_mPayment.isApproved());
kOnline.setReadWrite(!m_mPayment.isApproved());
kAmountField.setReadWrite(!m_mPayment.isApproved());
// Check
m_C_BankAccount_ID = m_mPayment.getC_BankAccount_ID();
sRoutingField.setText(m_mPayment.getRoutingNo());
sNumberField.setText(m_mPayment.getAccountNo());
sCheckField.setText(m_mPayment.getCheckNo());
sStatus.setText(m_mPayment.getR_PnRef());
sAmountField.setValue(m_mPayment.getPayAmt());
// Transfer
tRoutingField.setText(m_mPayment.getRoutingNo());
tNumberField.setText(m_mPayment.getAccountNo());
tStatus.setText(m_mPayment.getR_PnRef());
// Cash
bAmountField.setValue(m_mPayment.getPayAmt());
}
}
if (m_mPayment == null) {
m_mPayment = new MPayment(Env.getCtx(), 0, null);
m_mPayment.setAD_Org_ID(m_AD_Org_ID);
m_mPayment.setAmount(m_C_Currency_ID, m_Amount);
}
// Existing Cashbook entry
m_cashLine = null;
m_C_CashLine_ID = 0;
if (m_mTab.getValue("C_CashLine_ID") != null) {
m_C_CashLine_ID = ((Integer) m_mTab.getValue("C_CashLine_ID")).intValue();
if (m_C_CashLine_ID == 0)
m_cashLine = null;
else {
m_cashLine = new MCashLine(Env.getCtx(), m_C_CashLine_ID, null);
m_DateAcct = m_cashLine.getStatementDate();
m_C_CashBook_ID = m_cashLine.getCashBook().getC_CashBook_ID();
bAmountField.setValue(m_cashLine.getAmount());
}
}
// Accounting Date
bDateField.setValue(m_DateAcct);
if (s_Currencies == null)
loadCurrencies();
// Is the currency an EMU currency?
Integer C_Currency_ID = new Integer(m_C_Currency_ID);
if (s_Currencies.containsKey(C_Currency_ID)) {
Enumeration<Integer> en = s_Currencies.keys();
while (en.hasMoreElements()) {
Object key = en.nextElement();
bCurrencyCombo.addItem(s_Currencies.get(key));
sCurrencyCombo.addItem(s_Currencies.get(key));
}
sCurrencyCombo.addActionListener(this);
sCurrencyCombo.setSelectedItem(s_Currencies.get(C_Currency_ID));
bCurrencyCombo.addActionListener(this);
bCurrencyCombo.setSelectedItem(s_Currencies.get(C_Currency_ID));
} else // No EMU Currency
{
// Cash
bCurrencyLabel.setVisible(false);
bCurrencyCombo.setVisible(false);
// Check
sCurrencyLabel.setVisible(false);
sCurrencyCombo.setVisible(false);
}
/**
* Payment Combo
*/
if (m_PaymentRule == null)
m_PaymentRule = "";
ValueNamePair vp = null;
HashMap<?, ?> values = button.getValues();
Object[] a = values.keySet().toArray();
for (int i = 0; i < a.length; i++) {
// used for Panel selection
String PaymentRule = (String) a[i];
if (// SO
X_C_Order.PAYMENTRULE_DirectDebit.equals(PaymentRule) && !m_isSOTrx)
continue;
else if (// PO
X_C_Order.PAYMENTRULE_DirectDeposit.equals(PaymentRule) && m_isSOTrx)
continue;
ValueNamePair pp = new ValueNamePair(PaymentRule, (String) values.get(a[i]));
paymentCombo.addItem(pp);
if (// to select
PaymentRule.toString().equals(m_PaymentRule))
vp = pp;
}
// Set PaymentRule
paymentCombo.addActionListener(this);
if (vp != null)
paymentCombo.setSelectedItem(vp);
/**
* Load Payment Terms
*/
String SQL = MRole.getDefault().addAccessSQL("SELECT C_PaymentTerm_ID, Name FROM C_PaymentTerm WHERE IsActive='Y' ORDER BY Name", "C_PaymentTerm", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
KeyNamePair kp = null;
try {
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
int key = rs.getInt(1);
String name = rs.getString(2);
KeyNamePair pp = new KeyNamePair(key, name);
pTermCombo.addItem(pp);
if (key == m_C_PaymentTerm_ID)
kp = pp;
}
rs.close();
pstmt.close();
} catch (SQLException ept) {
log.log(Level.SEVERE, SQL, ept);
}
// Set Selection
if (kp != null)
pTermCombo.setSelectedItem(kp);
/**
* Load Accounts
*/
SQL = "SELECT a.C_BP_BankAccount_ID, NVL(b.Name, ' ')||'_'||NVL(a.AccountNo, ' ') AS Acct " + "FROM C_BP_BankAccount a" + " LEFT OUTER JOIN C_Bank b ON (a.C_Bank_ID=b.C_Bank_ID) " + "WHERE C_BPartner_ID=?" + "AND a.IsActive='Y' AND a.IsACH='Y'";
kp = null;
try {
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, m_C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
int key = rs.getInt(1);
String name = rs.getString(2);
KeyNamePair pp = new KeyNamePair(key, name);
tAccountCombo.addItem(pp);
// kp = pp;
}
rs.close();
pstmt.close();
} catch (SQLException eac) {
log.log(Level.SEVERE, SQL, eac);
}
// Set Selection
if (kp != null)
tAccountCombo.setSelectedItem(kp);
/**
* Load Credit Cards
*/
ValueNamePair[] ccs = m_mPayment.getCreditCards();
vp = null;
for (int i = 0; i < ccs.length; i++) {
kTypeCombo.addItem(ccs[i]);
if (ccs[i].getValue().equals(m_CCType))
vp = ccs[i];
}
// Set Selection
if (vp != null)
kTypeCombo.setSelectedItem(vp);
/**
* Load Bank Accounts
*/
SQL = MRole.getDefault().addAccessSQL("SELECT C_BankAccount_ID, ba.accountno, IsDefault " + "FROM C_BankAccount ba" + " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID) " + "WHERE b.IsActive='Y'", "ba", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
kp = null;
try {
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
int key = rs.getInt(1);
String name = rs.getString(2);
KeyNamePair pp = new KeyNamePair(key, name);
sBankAccountCombo.addItem(pp);
if (key == m_C_BankAccount_ID)
kp = pp;
if (// Default
kp == null && rs.getString(3).equals("Y"))
kp = pp;
}
rs.close();
pstmt.close();
} catch (SQLException ept) {
log.log(Level.SEVERE, SQL, ept);
}
// Set Selection
if (kp != null)
sBankAccountCombo.setSelectedItem(kp);
/**
* Load Cash Books
*/
SQL = MRole.getDefault().addAccessSQL("SELECT C_CashBook_ID, Name, AD_Org_ID FROM C_CashBook WHERE IsActive='Y'", "C_CashBook", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
kp = null;
try {
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
int key = rs.getInt(1);
String name = rs.getString(2);
KeyNamePair pp = new KeyNamePair(key, name);
bCashBookCombo.addItem(pp);
if (key == m_C_CashBook_ID)
kp = pp;
if (// Default Org
kp == null && key == m_AD_Org_ID)
kp = pp;
}
rs.close();
pstmt.close();
} catch (SQLException epc) {
log.log(Level.SEVERE, SQL, epc);
}
// Set Selection
if (kp != null) {
bCashBookCombo.setSelectedItem(kp);
if (m_C_CashBook_ID == 0)
// set to default to avoid 'cashbook changed' message
m_C_CashBook_ID = kp.getKey();
}
//
return true;
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VPayment method actionPerformed.
// loadCurrencies
/**************************************************************************
* Action Listener
* @param e event
*/
public void actionPerformed(ActionEvent e) {
log.fine("VPayment.actionPerformed - " + e.getActionCommand());
// Finish
if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
if (checkMandatory()) {
// cannot recover
saveChanges();
dispose();
}
} else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
dispose();
else // Payment Method Change
if (e.getSource() == paymentCombo) {
// get selection
ValueNamePair pp = (ValueNamePair) paymentCombo.getSelectedItem();
if (pp != null) {
String s = pp.getValue().toLowerCase();
if (X_C_Order.PAYMENTRULE_DirectDebit.equalsIgnoreCase(s))
s = X_C_Order.PAYMENTRULE_DirectDeposit.toLowerCase();
s += "Panel";
// switch to panel
centerLayout.show(centerPanel, s);
//Bojana&Daniel
//If Invoice is Vendor invoice then Cash has to be created by negative amount
int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "C_Invoice_ID");
MInvoice invoice_tmp = new MInvoice(Env.getCtx(), C_Invoice_ID, null);
if (!invoice_tmp.isSOTrx()) {
bAmountField.setValue(m_Amount.negate());
} else {
bAmountField.setValue(m_Amount);
}
invoice_tmp = null;
}
} else // Check Currency change
if (e.getSource() == sCurrencyCombo) {
KeyNamePair pp = (KeyNamePair) sCurrencyCombo.getSelectedItem();
BigDecimal amt = MConversionRate.convert(Env.getCtx(), m_Amount, m_C_Currency_ID, pp.getKey(), m_AD_Client_ID, m_AD_Org_ID);
sAmountField.setValue(amt);
} else // Cash Currency change
if (e.getSource() == bCurrencyCombo) {
KeyNamePair pp = (KeyNamePair) bCurrencyCombo.getSelectedItem();
BigDecimal amt = MConversionRate.convert(Env.getCtx(), m_Amount, m_C_Currency_ID, pp.getKey(), m_AD_Client_ID, m_AD_Org_ID);
bAmountField.setValue(amt);
} else // Online
if (e.getSource() == kOnline || e.getSource() == sOnline)
processOnline();
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VPayment method checkMandatory.
/**
* Check Mandatory
* @return true if all mandatory items are OK
*/
private boolean checkMandatory() {
log.config("VPayment.checkMandatory");
ValueNamePair vp = (ValueNamePair) paymentCombo.getSelectedItem();
String PaymentRule = vp.getValue();
// only Payment Rule
if (m_onlyRule)
return true;
String CCType = m_CCType;
//
int C_BankAccount_ID = 0;
/***********************
* Mandatory Data Check
*/
boolean dataOK = true;
// B (Cash) (Currency)
if (PaymentRule.equals(MOrder.PAYMENTRULE_Cash)) {
if (m_Cash_As_Payment) {
KeyNamePair kp = (KeyNamePair) sBankAccountCombo.getSelectedItem();
if (kp != null)
C_BankAccount_ID = kp.getKey();
}
} else // K (CreditCard) Type, Number, Exp, Approval
if (PaymentRule.equals(MOrder.PAYMENTRULE_CreditCard)) {
vp = (ValueNamePair) kTypeCombo.getSelectedItem();
if (vp != null)
CCType = vp.getValue();
// Validation of the credit card number is moved to the payment processor.
// Different payment processors can have different validation rules.
} else // T (Transfer) BPartner_Bank
if (PaymentRule.equals(X_C_Order.PAYMENTRULE_DirectDeposit) || PaymentRule.equals(X_C_Order.PAYMENTRULE_DirectDebit)) {
KeyNamePair bpba = (KeyNamePair) tAccountCombo.getSelectedItem();
if (bpba == null) {
tAccountCombo.setBackground(AdempierePLAF.getFieldBackground_Error());
ADialog.error(m_WindowNo, this, "PaymentBPBankNotFound");
dataOK = false;
}
} else // P (PaymentTerm) PaymentTerm
if (PaymentRule.equals(X_C_Order.PAYMENTRULE_OnCredit)) {
// ok
} else // S (Check) (Currency) CheckNo, Routing
if (PaymentRule.equals(MOrder.PAYMENTRULE_Check)) {
// sCurrencyCombo.getSelectedItem();
KeyNamePair kp = (KeyNamePair) sBankAccountCombo.getSelectedItem();
if (kp != null)
C_BankAccount_ID = kp.getKey();
String error = MPaymentValidate.validateRoutingNo(sRoutingField.getText());
if (error.length() != 0) {
sRoutingField.setBackground(AdempierePLAF.getFieldBackground_Error());
ADialog.error(m_WindowNo, this, error);
dataOK = false;
}
error = MPaymentValidate.validateAccountNo(sNumberField.getText());
if (error.length() != 0) {
sNumberField.setBackground(AdempierePLAF.getFieldBackground_Error());
ADialog.error(m_WindowNo, this, error);
dataOK = false;
}
error = MPaymentValidate.validateCheckNo(sCheckField.getText());
if (error.length() != 0) {
sCheckField.setBackground(AdempierePLAF.getFieldBackground_Error());
ADialog.error(m_WindowNo, this, error);
dataOK = false;
}
} else {
log.log(Level.SEVERE, "Unknown PaymentRule " + PaymentRule);
ADialog.error(m_WindowNo, this, "Unknown PaymentRule " + PaymentRule);
return false;
}
// find Bank Account if not qualified yet
if (("KTSD".indexOf(PaymentRule) != -1 || (PaymentRule.equals(MOrder.PAYMENTRULE_Cash) && m_Cash_As_Payment)) && C_BankAccount_ID == 0) {
// Check & Cash (Payment) must have a bank account
if (C_BankAccount_ID == 0 && (PaymentRule.equals(MOrder.PAYMENTRULE_Check)) || (PaymentRule.equals(MOrder.PAYMENTRULE_Cash) && m_Cash_As_Payment)) {
ADialog.error(m_WindowNo, this, "PaymentNoProcessor");
dataOK = false;
}
}
//
log.config("OK=" + dataOK);
return dataOK;
}
Aggregations