Ticket #1001503: Credit Cards Online

This commit is contained in:
Elaine Tan 2012-10-15 17:00:07 +08:00
parent 5ccdc9aa95
commit e280cbbd70
51 changed files with 8362 additions and 622 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,90 @@
package org.adempiere.util;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.util.ArrayList;
import java.util.logging.Level;
import org.compiere.model.MBPBankAccount;
import org.compiere.model.MBPartner;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
public class PaymentUtil {
private static final CLogger logger = CLogger.getCLogger(PaymentUtil.class);
public static MBPBankAccount[] getBankAccounts(MBPartner bpartner,
String creditCardNo) {
ArrayList<MBPBankAccount> list = new ArrayList<MBPBankAccount>();
String sql = "SELECT * FROM C_BP_BankAccount WHERE C_BPartner_ID=? AND CREDITCARDNUMBER=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, bpartner.get_TrxName());
pstmt.setInt(1, bpartner.getC_BPartner_ID());
pstmt.setString(2, creditCardNo);
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MBPBankAccount(bpartner.getCtx(), rs, bpartner
.get_TrxName()));
} catch (Exception e) {
logger.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
}
MBPBankAccount[] m_accounts = new MBPBankAccount[list.size()];
list.toArray(m_accounts);
return m_accounts;
}
public static String encrpytCreditCard(String value) {
if (value == null)
return "";
else
if (value.length() <= 4)
return value;
Integer valueLength = value.length();
StringBuffer encryptedCC = new StringBuffer();
for (int i = 0; i < (valueLength - 4); i++) {
encryptedCC.append("*");
}
encryptedCC.append(value.substring(valueLength - 4, valueLength));
return encryptedCC.toString();
}
public static String encrpytCvv(String creditCardVV) {
if (creditCardVV == null)
return "";
else {
Integer valueLength = creditCardVV.length();
StringBuffer encryptedCC = new StringBuffer();
for (int i = 0; i < valueLength; i++) {
encryptedCC.append("0");
}
return encryptedCC.toString();
}
}
public static boolean isNumeric(String str) {
if (str != null && str.length() > 0) {
NumberFormat formatter = NumberFormat.getInstance();
ParsePosition pos = new ParsePosition(0);
formatter.parse(str, pos);
return str.length() == pos.getIndex();
}
return true;
}
}

View File

@ -202,6 +202,11 @@ public class GridField
MPAttributeLookup pa = new MPAttributeLookup (m_vo.ctx, m_vo.WindowNo);
m_lookup = pa;
}
else if (m_vo.displayType == DisplayType.Payment)
{
MPaymentLookup pl = new MPaymentLookup (m_vo.ctx, m_vo.WindowNo, m_vo.AD_Column_ID);
m_lookup = pl;
}
} // m_lookup
/**
@ -239,7 +244,8 @@ public class GridField
else if (m_vo.displayType == DisplayType.Location
|| m_vo.displayType == DisplayType.Locator
|| m_vo.displayType == DisplayType.Account
|| m_vo.displayType == DisplayType.PAttribute)
|| m_vo.displayType == DisplayType.PAttribute
|| m_vo.displayType == DisplayType.Payment)
retValue = true;
return retValue;

View File

@ -31,7 +31,7 @@ public interface I_C_BP_BankAccount
public static final String Table_Name = "C_BP_BankAccount";
/** AD_Table_ID=298 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
public static final int Table_ID = 298;
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
@ -41,19 +41,6 @@ public interface I_C_BP_BankAccount
/** Load Meta Data */
/** Column name AccountNo */
public static final String COLUMNNAME_AccountNo = "AccountNo";
/** Set Account No.
* Account Number
*/
public void setAccountNo (String AccountNo);
/** Get Account No.
* Account Number
*/
public String getAccountNo();
/** Column name A_City */
public static final String COLUMNNAME_A_City = "A_City";
@ -80,42 +67,6 @@ public interface I_C_BP_BankAccount
*/
public String getA_Country();
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name AD_User_ID */
public static final String COLUMNNAME_AD_User_ID = "AD_User_ID";
/** Set User/Contact.
* User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID);
/** Get User/Contact.
* User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID();
public I_AD_User getAD_User() throws RuntimeException;
/** Column name A_EMail */
public static final String COLUMNNAME_A_EMail = "A_EMail";
@ -207,6 +158,55 @@ public interface I_C_BP_BankAccount
*/
public String getA_Zip();
/** Column name AccountNo */
public static final String COLUMNNAME_AccountNo = "AccountNo";
/** Set Account No.
* Account Number
*/
public void setAccountNo (String AccountNo);
/** Get Account No.
* Account Number
*/
public String getAccountNo();
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name AD_User_ID */
public static final String COLUMNNAME_AD_User_ID = "AD_User_ID";
/** Set User/Contact.
* User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID);
/** Get User/Contact.
* User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID();
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException;
/** Column name BankAccountType */
public static final String COLUMNNAME_BankAccountType = "BankAccountType";
@ -246,7 +246,29 @@ public interface I_C_BP_BankAccount
*/
public int getC_Bank_ID();
public I_C_Bank getC_Bank() throws RuntimeException;
public org.compiere.model.I_C_Bank getC_Bank() throws RuntimeException;
/** Column name C_BP_BankAccount_ID */
public static final String COLUMNNAME_C_BP_BankAccount_ID = "C_BP_BankAccount_ID";
/** Set Partner Bank Account.
* Bank Account of the Business Partner
*/
public void setC_BP_BankAccount_ID (int C_BP_BankAccount_ID);
/** Get Partner Bank Account.
* Bank Account of the Business Partner
*/
public int getC_BP_BankAccount_ID();
/** Column name C_BP_BankAccount_UU */
public static final String COLUMNNAME_C_BP_BankAccount_UU = "C_BP_BankAccount_UU";
/** Set C_BP_BankAccount_UU */
public void setC_BP_BankAccount_UU (String C_BP_BankAccount_UU);
/** Get C_BP_BankAccount_UU */
public String getC_BP_BankAccount_UU();
/** Column name C_BPartner_ID */
public static final String COLUMNNAME_C_BPartner_ID = "C_BPartner_ID";
@ -261,20 +283,7 @@ public interface I_C_BP_BankAccount
*/
public int getC_BPartner_ID();
public I_C_BPartner getC_BPartner() throws RuntimeException;
/** Column name C_BP_BankAccount_ID */
public static final String COLUMNNAME_C_BP_BankAccount_ID = "C_BP_BankAccount_ID";
/** Set Partner Bank Account.
* Bank Account of the Business Partner
*/
public void setC_BP_BankAccount_ID (int C_BP_BankAccount_ID);
/** Get Partner Bank Account.
* Bank Account of the Business Partner
*/
public int getC_BP_BankAccount_ID();
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException;
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
@ -357,6 +366,15 @@ public interface I_C_BP_BankAccount
*/
public String getCreditCardVV();
/** Column name CustomerPaymentProfileID */
public static final String COLUMNNAME_CustomerPaymentProfileID = "CustomerPaymentProfileID";
/** Set Customer Payment Profile ID */
public void setCustomerPaymentProfileID (String CustomerPaymentProfileID);
/** Get Customer Payment Profile ID */
public String getCustomerPaymentProfileID();
/** Column name IsACH */
public static final String COLUMNNAME_IsACH = "IsACH";

View File

@ -88,19 +88,6 @@ public interface I_C_BPartner
*/
public String getAD_Language();
/** Column name AD_OrgBP_ID */
public static final String COLUMNNAME_AD_OrgBP_ID = "AD_OrgBP_ID";
/** Set Linked Organization.
* The Business Partner is another Organization for explicit Inter-Org transactions
*/
public void setAD_OrgBP_ID (String AD_OrgBP_ID);
/** Get Linked Organization.
* The Business Partner is another Organization for explicit Inter-Org transactions
*/
public String getAD_OrgBP_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
@ -114,6 +101,19 @@ public interface I_C_BPartner
*/
public int getAD_Org_ID();
/** Column name AD_OrgBP_ID */
public static final String COLUMNNAME_AD_OrgBP_ID = "AD_OrgBP_ID";
/** Set Linked Organization.
* The Business Partner is another Organization for explicit Inter-Org transactions
*/
public void setAD_OrgBP_ID (String AD_OrgBP_ID);
/** Get Linked Organization.
* The Business Partner is another Organization for explicit Inter-Org transactions
*/
public String getAD_OrgBP_ID();
/** Column name BPartner_Parent_ID */
public static final String COLUMNNAME_BPartner_Parent_ID = "BPartner_Parent_ID";
@ -127,6 +127,21 @@ public interface I_C_BPartner
*/
public int getBPartner_Parent_ID();
/** Column name C_BP_Group_ID */
public static final String COLUMNNAME_C_BP_Group_ID = "C_BP_Group_ID";
/** Set Business Partner Group.
* Business Partner Group
*/
public void setC_BP_Group_ID (int C_BP_Group_ID);
/** Get Business Partner Group.
* Business Partner Group
*/
public int getC_BP_Group_ID();
public org.compiere.model.I_C_BP_Group getC_BP_Group() throws RuntimeException;
/** Column name C_BPartner_ID */
public static final String COLUMNNAME_C_BPartner_ID = "C_BPartner_ID";
@ -149,21 +164,6 @@ public interface I_C_BPartner
/** Get C_BPartner_UU */
public String getC_BPartner_UU();
/** Column name C_BP_Group_ID */
public static final String COLUMNNAME_C_BP_Group_ID = "C_BP_Group_ID";
/** Set Business Partner Group.
* Business Partner Group
*/
public void setC_BP_Group_ID (int C_BP_Group_ID);
/** Get Business Partner Group.
* Business Partner Group
*/
public int getC_BP_Group_ID();
public org.compiere.model.I_C_BP_Group getC_BP_Group() throws RuntimeException;
/** Column name C_Dunning_ID */
public static final String COLUMNNAME_C_Dunning_ID = "C_Dunning_ID";
@ -224,6 +224,17 @@ public interface I_C_BPartner
public org.compiere.model.I_C_PaymentTerm getC_PaymentTerm() throws RuntimeException;
/** Column name C_TaxGroup_ID */
public static final String COLUMNNAME_C_TaxGroup_ID = "C_TaxGroup_ID";
/** Set Tax Group */
public void setC_TaxGroup_ID (int C_TaxGroup_ID);
/** Get Tax Group */
public int getC_TaxGroup_ID();
public org.eevolution.model.I_C_TaxGroup getC_TaxGroup() throws RuntimeException;
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
@ -240,16 +251,14 @@ public interface I_C_BPartner
*/
public int getCreatedBy();
/** Column name C_TaxGroup_ID */
public static final String COLUMNNAME_C_TaxGroup_ID = "C_TaxGroup_ID";
/** Column name CustomerProfileID */
public static final String COLUMNNAME_CustomerProfileID = "CustomerProfileID";
/** Set Tax Group */
public void setC_TaxGroup_ID (int C_TaxGroup_ID);
/** Set Customer Profile ID */
public void setCustomerProfileID (String CustomerProfileID);
/** Get Tax Group */
public int getC_TaxGroup_ID();
public org.eevolution.model.I_C_TaxGroup getC_TaxGroup() throws RuntimeException;
/** Get Customer Profile ID */
public String getCustomerProfileID();
/** Column name DeliveryRule */
public static final String COLUMNNAME_DeliveryRule = "DeliveryRule";
@ -838,19 +847,6 @@ public interface I_C_BPartner
*/
public BigDecimal getSO_CreditLimit();
/** Column name SOCreditStatus */
public static final String COLUMNNAME_SOCreditStatus = "SOCreditStatus";
/** Set Credit Status.
* Business Partner Credit Status
*/
public void setSOCreditStatus (String SOCreditStatus);
/** Get Credit Status.
* Business Partner Credit Status
*/
public String getSOCreditStatus();
/** Column name SO_CreditUsed */
public static final String COLUMNNAME_SO_CreditUsed = "SO_CreditUsed";
@ -877,6 +873,19 @@ public interface I_C_BPartner
*/
public String getSO_Description();
/** Column name SOCreditStatus */
public static final String COLUMNNAME_SOCreditStatus = "SOCreditStatus";
/** Set Credit Status.
* Business Partner Credit Status
*/
public void setSOCreditStatus (String SOCreditStatus);
/** Get Credit Status.
* Business Partner Credit Status
*/
public String getSOCreditStatus();
/** Column name TaxID */
public static final String COLUMNNAME_TaxID = "TaxID";

View File

@ -31,7 +31,7 @@ public interface I_C_BPartner_Location
public static final String Table_Name = "C_BPartner_Location";
/** AD_Table_ID=293 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
public static final int Table_ID = 293;
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
@ -75,7 +75,7 @@ public interface I_C_BPartner_Location
*/
public int getC_BPartner_ID();
public I_C_BPartner getC_BPartner() throws RuntimeException;
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException;
/** Column name C_BPartner_Location_ID */
public static final String COLUMNNAME_C_BPartner_Location_ID = "C_BPartner_Location_ID";
@ -90,6 +90,15 @@ public interface I_C_BPartner_Location
*/
public int getC_BPartner_Location_ID();
/** Column name C_BPartner_Location_UU */
public static final String COLUMNNAME_C_BPartner_Location_UU = "C_BPartner_Location_UU";
/** Set C_BPartner_Location_UU */
public void setC_BPartner_Location_UU (String C_BPartner_Location_UU);
/** Get C_BPartner_Location_UU */
public String getC_BPartner_Location_UU();
/** Column name C_Location_ID */
public static final String COLUMNNAME_C_Location_ID = "C_Location_ID";
@ -105,6 +114,21 @@ public interface I_C_BPartner_Location
public I_C_Location getC_Location() throws RuntimeException;
/** Column name C_SalesRegion_ID */
public static final String COLUMNNAME_C_SalesRegion_ID = "C_SalesRegion_ID";
/** Set Sales Region.
* Sales coverage region
*/
public void setC_SalesRegion_ID (int C_SalesRegion_ID);
/** Get Sales Region.
* Sales coverage region
*/
public int getC_SalesRegion_ID();
public org.compiere.model.I_C_SalesRegion getC_SalesRegion() throws RuntimeException;
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
@ -121,20 +145,14 @@ public interface I_C_BPartner_Location
*/
public int getCreatedBy();
/** Column name C_SalesRegion_ID */
public static final String COLUMNNAME_C_SalesRegion_ID = "C_SalesRegion_ID";
/** Column name CustomerAddressID */
public static final String COLUMNNAME_CustomerAddressID = "CustomerAddressID";
/** Set Sales Region.
* Sales coverage region
*/
public void setC_SalesRegion_ID (int C_SalesRegion_ID);
/** Set Customer Address ID */
public void setCustomerAddressID (String CustomerAddressID);
/** Get Sales Region.
* Sales coverage region
*/
public int getC_SalesRegion_ID();
public I_C_SalesRegion getC_SalesRegion() throws RuntimeException;
/** Get Customer Address ID */
public String getCustomerAddressID();
/** Column name Fax */
public static final String COLUMNNAME_Fax = "Fax";

View File

@ -41,19 +41,6 @@ public interface I_C_Payment
/** Load Meta Data */
/** Column name AccountNo */
public static final String COLUMNNAME_AccountNo = "AccountNo";
/** Set Account No.
* Account Number
*/
public void setAccountNo (String AccountNo);
/** Get Account No.
* Account Number
*/
public String getAccountNo();
/** Column name A_City */
public static final String COLUMNNAME_A_City = "A_City";
@ -80,40 +67,6 @@ public interface I_C_Payment
*/
public String getA_Country();
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name AD_OrgTrx_ID */
public static final String COLUMNNAME_AD_OrgTrx_ID = "AD_OrgTrx_ID";
/** Set Trx Organization.
* Performing or initiating organization
*/
public void setAD_OrgTrx_ID (int AD_OrgTrx_ID);
/** Get Trx Organization.
* Performing or initiating organization
*/
public int getAD_OrgTrx_ID();
/** Column name A_EMail */
public static final String COLUMNNAME_A_EMail = "A_EMail";
@ -205,6 +158,53 @@ public interface I_C_Payment
*/
public String getA_Zip();
/** Column name AccountNo */
public static final String COLUMNNAME_AccountNo = "AccountNo";
/** Set Account No.
* Account Number
*/
public void setAccountNo (String AccountNo);
/** Get Account No.
* Account Number
*/
public String getAccountNo();
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name AD_OrgTrx_ID */
public static final String COLUMNNAME_AD_OrgTrx_ID = "AD_OrgTrx_ID";
/** Set Trx Organization.
* Performing or initiating organization
*/
public void setAD_OrgTrx_ID (int AD_OrgTrx_ID);
/** Get Trx Organization.
* Performing or initiating organization
*/
public int getAD_OrgTrx_ID();
/** Column name C_Activity_ID */
public static final String COLUMNNAME_C_Activity_ID = "C_Activity_ID";
@ -235,21 +235,6 @@ public interface I_C_Payment
public org.compiere.model.I_C_BankAccount getC_BankAccount() throws RuntimeException;
/** Column name C_BPartner_ID */
public static final String COLUMNNAME_C_BPartner_ID = "C_BPartner_ID";
/** Set Business Partner .
* Identifies a Business Partner
*/
public void setC_BPartner_ID (int C_BPartner_ID);
/** Get Business Partner .
* Identifies a Business Partner
*/
public int getC_BPartner_ID();
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException;
/** Column name C_BP_BankAccount_ID */
public static final String COLUMNNAME_C_BP_BankAccount_ID = "C_BP_BankAccount_ID";
@ -265,6 +250,21 @@ public interface I_C_Payment
public org.compiere.model.I_C_BP_BankAccount getC_BP_BankAccount() throws RuntimeException;
/** Column name C_BPartner_ID */
public static final String COLUMNNAME_C_BPartner_ID = "C_BPartner_ID";
/** Set Business Partner .
* Identifies a Business Partner
*/
public void setC_BPartner_ID (int C_BPartner_ID);
/** Get Business Partner .
* Identifies a Business Partner
*/
public int getC_BPartner_ID();
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException;
/** Column name C_Campaign_ID */
public static final String COLUMNNAME_C_Campaign_ID = "C_Campaign_ID";
@ -355,32 +355,6 @@ public interface I_C_Payment
public org.compiere.model.I_C_DocType getC_DocType() throws RuntimeException;
/** Column name ChargeAmt */
public static final String COLUMNNAME_ChargeAmt = "ChargeAmt";
/** Set Charge amount.
* Charge Amount
*/
public void setChargeAmt (BigDecimal ChargeAmt);
/** Get Charge amount.
* Charge Amount
*/
public BigDecimal getChargeAmt();
/** Column name CheckNo */
public static final String COLUMNNAME_CheckNo = "CheckNo";
/** Set Check No.
* Check Number
*/
public void setCheckNo (String CheckNo);
/** Get Check No.
* Check Number
*/
public String getCheckNo();
/** Column name C_Invoice_ID */
public static final String COLUMNNAME_C_Invoice_ID = "C_Invoice_ID";
@ -411,21 +385,6 @@ public interface I_C_Payment
public org.compiere.model.I_C_Order getC_Order() throws RuntimeException;
/** Column name C_PaymentBatch_ID */
public static final String COLUMNNAME_C_PaymentBatch_ID = "C_PaymentBatch_ID";
/** Set Payment Batch.
* Payment batch for EFT
*/
public void setC_PaymentBatch_ID (int C_PaymentBatch_ID);
/** Get Payment Batch.
* Payment batch for EFT
*/
public int getC_PaymentBatch_ID();
public org.compiere.model.I_C_PaymentBatch getC_PaymentBatch() throws RuntimeException;
/** Column name C_Payment_ID */
public static final String COLUMNNAME_C_Payment_ID = "C_Payment_ID";
@ -448,6 +407,36 @@ public interface I_C_Payment
/** Get C_Payment_UU */
public String getC_Payment_UU();
/** Column name C_PaymentBatch_ID */
public static final String COLUMNNAME_C_PaymentBatch_ID = "C_PaymentBatch_ID";
/** Set Payment Batch.
* Payment batch for EFT
*/
public void setC_PaymentBatch_ID (int C_PaymentBatch_ID);
/** Get Payment Batch.
* Payment batch for EFT
*/
public int getC_PaymentBatch_ID();
public org.compiere.model.I_C_PaymentBatch getC_PaymentBatch() throws RuntimeException;
/** Column name C_PaymentProcessor_ID */
public static final String COLUMNNAME_C_PaymentProcessor_ID = "C_PaymentProcessor_ID";
/** Set Payment Processor.
* Payment processor for electronic payments
*/
public void setC_PaymentProcessor_ID (int C_PaymentProcessor_ID);
/** Get Payment Processor.
* Payment processor for electronic payments
*/
public int getC_PaymentProcessor_ID();
public org.compiere.model.I_C_PaymentProcessor getC_PaymentProcessor() throws RuntimeException;
/** Column name C_POSTenderType_ID */
public static final String COLUMNNAME_C_POSTenderType_ID = "C_POSTenderType_ID";
@ -474,6 +463,32 @@ public interface I_C_Payment
public org.compiere.model.I_C_Project getC_Project() throws RuntimeException;
/** Column name ChargeAmt */
public static final String COLUMNNAME_ChargeAmt = "ChargeAmt";
/** Set Charge amount.
* Charge Amount
*/
public void setChargeAmt (BigDecimal ChargeAmt);
/** Get Charge amount.
* Charge Amount
*/
public BigDecimal getChargeAmt();
/** Column name CheckNo */
public static final String COLUMNNAME_CheckNo = "CheckNo";
/** Set Check No.
* Check Number
*/
public void setCheckNo (String CheckNo);
/** Get Check No.
* Check Number
*/
public String getCheckNo();
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
@ -555,6 +570,33 @@ public interface I_C_Payment
*/
public String getCreditCardVV();
/** Column name CustomerAddressID */
public static final String COLUMNNAME_CustomerAddressID = "CustomerAddressID";
/** Set Customer Address ID */
public void setCustomerAddressID (String CustomerAddressID);
/** Get Customer Address ID */
public String getCustomerAddressID();
/** Column name CustomerPaymentProfileID */
public static final String COLUMNNAME_CustomerPaymentProfileID = "CustomerPaymentProfileID";
/** Set Customer Payment Profile ID */
public void setCustomerPaymentProfileID (String CustomerPaymentProfileID);
/** Get Customer Payment Profile ID */
public String getCustomerPaymentProfileID();
/** Column name CustomerProfileID */
public static final String COLUMNNAME_CustomerProfileID = "CustomerProfileID";
/** Set Customer Profile ID */
public void setCustomerProfileID (String CustomerProfileID);
/** Get Customer Profile ID */
public String getCustomerProfileID();
/** Column name DateAcct */
public static final String COLUMNNAME_DateAcct = "DateAcct";
@ -776,6 +818,15 @@ public interface I_C_Payment
*/
public boolean isSelfService();
/** Column name IsVoided */
public static final String COLUMNNAME_IsVoided = "IsVoided";
/** Set Voided */
public void setIsVoided (boolean IsVoided);
/** Get Voided */
public boolean isVoided();
/** Column name Micr */
public static final String COLUMNNAME_Micr = "Micr";
@ -967,32 +1018,6 @@ public interface I_C_Payment
*/
public boolean isR_CVV2Match();
/** Column name Ref_Payment_ID */
public static final String COLUMNNAME_Ref_Payment_ID = "Ref_Payment_ID";
/** Set Referenced Payment */
public void setRef_Payment_ID (int Ref_Payment_ID);
/** Get Referenced Payment */
public int getRef_Payment_ID();
public org.compiere.model.I_C_Payment getRef_Payment() throws RuntimeException;
/** Column name Reversal_ID */
public static final String COLUMNNAME_Reversal_ID = "Reversal_ID";
/** Set Reversal ID.
* ID of document reversal
*/
public void setReversal_ID (int Reversal_ID);
/** Get Reversal ID.
* ID of document reversal
*/
public int getReversal_ID();
public org.compiere.model.I_C_Payment getReversal() throws RuntimeException;
/** Column name R_Info */
public static final String COLUMNNAME_R_Info = "R_Info";
@ -1006,19 +1031,6 @@ public interface I_C_Payment
*/
public String getR_Info();
/** Column name RoutingNo */
public static final String COLUMNNAME_RoutingNo = "RoutingNo";
/** Set Routing No.
* Bank Routing Number
*/
public void setRoutingNo (String RoutingNo);
/** Get Routing No.
* Bank Routing Number
*/
public String getRoutingNo();
/** Column name R_PnRef */
public static final String COLUMNNAME_R_PnRef = "R_PnRef";
@ -1071,6 +1083,54 @@ public interface I_C_Payment
*/
public String getR_Result();
/** Column name R_VoidMsg */
public static final String COLUMNNAME_R_VoidMsg = "R_VoidMsg";
/** Set Void Message */
public void setR_VoidMsg (String R_VoidMsg);
/** Get Void Message */
public String getR_VoidMsg();
/** Column name Ref_Payment_ID */
public static final String COLUMNNAME_Ref_Payment_ID = "Ref_Payment_ID";
/** Set Referenced Payment */
public void setRef_Payment_ID (int Ref_Payment_ID);
/** Get Referenced Payment */
public int getRef_Payment_ID();
public org.compiere.model.I_C_Payment getRef_Payment() throws RuntimeException;
/** Column name Reversal_ID */
public static final String COLUMNNAME_Reversal_ID = "Reversal_ID";
/** Set Reversal ID.
* ID of document reversal
*/
public void setReversal_ID (int Reversal_ID);
/** Get Reversal ID.
* ID of document reversal
*/
public int getReversal_ID();
public org.compiere.model.I_C_Payment getReversal() throws RuntimeException;
/** Column name RoutingNo */
public static final String COLUMNNAME_RoutingNo = "RoutingNo";
/** Set Routing No.
* Bank Routing Number
*/
public void setRoutingNo (String RoutingNo);
/** Get Routing No.
* Bank Routing Number
*/
public String getRoutingNo();
/** Column name Swipe */
public static final String COLUMNNAME_Swipe = "Swipe";

View File

@ -0,0 +1,203 @@
package org.compiere.model;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.NamePair;
import org.compiere.util.ValueNamePair;
public class MPaymentLookup extends Lookup implements Serializable {
private static final int PAYMENT_RULE_REFERENCE_ID = 195;
/** Context */
private Properties m_ctx;
/** IsSOTrx */
private boolean m_isSOTrx = false;
/** AD_Column_ID */
private int m_AD_Column_ID;
public MPaymentLookup(Properties ctx, int windowNo, int columnID) {
super(DisplayType.TableDir, windowNo);
m_ctx = ctx;
m_AD_Column_ID = columnID;
m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), windowNo, "IsSOTrx"));
}
@Override
public String getDisplay(Object key) {
if (key == null)
return null;
ValueNamePair[] values = getData();
for (ValueNamePair value : values)
{
if(value.getValue().equals(key.toString()))
return value.getName();
}
StringBuilder msgreturn = new StringBuilder("<").append(key.toString()).append(">");
return msgreturn.toString();
}
@Override
public NamePair get(Object key) {
if (key == null)
return null;
ValueNamePair[] values = getData();
for (ValueNamePair value : values)
{
if(value.getValue().equals(key.toString()))
return value;
}
return null;
}
@Override
public boolean containsKey(Object key) {
ValueNamePair[] values = getData();
for (ValueNamePair value : values)
{
if(value.getValue().equals(key.toString()))
return true;
}
return false;
}
@Override
public String getColumnName() {
return "PaymentRule";
}
private ValueNamePair[] getData()
{
String ad_language = Env.getAD_Language(m_ctx);
boolean isBaseLanguage = Env.isBaseLanguage(ad_language, "AD_Ref_List");
StringBuilder sb = new StringBuilder();
if (isBaseLanguage)
sb.append("SELECT r.Value, r.Name FROM AD_Ref_List r WHERE r.AD_Reference_ID=? AND r.IsActive='Y'");
else
{
sb.append("SELECT r.Value, t.Name FROM AD_Ref_List_Trl t");
sb.append(" INNER JOIN AD_Ref_List r ON (r.AD_Ref_List_ID=t.AD_Ref_List_ID)");
sb.append(" WHERE r.AD_Reference_ID=? AND t.AD_Language=? AND r.IsActive='Y'");
}
String wc = getWhereClause();
if (wc != null && wc.length() > 0)
{
wc = wc.replace("AD_Ref_List", "r");
wc = wc.replace("AD_Ref_List_Trl", "t");
sb.append(" AND ").append(wc);
}
if (isBaseLanguage)
sb.append(" ORDER BY r.Name");
else
sb.append(" ORDER BY t.Name");
PreparedStatement pstmt = null;
ResultSet rs = null;
ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>();
try
{
pstmt = DB.prepareStatement(sb.toString(), null);
pstmt.setInt(1, PAYMENT_RULE_REFERENCE_ID);
if (!isBaseLanguage)
pstmt.setString(2, ad_language);
rs = pstmt.executeQuery();
while (rs.next())
list.add(new ValueNamePair(rs.getString(1), rs.getString(2)));
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException e)
{
log.log(Level.SEVERE, sb.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
ValueNamePair[] retValue = new ValueNamePair[list.size()];
list.toArray(retValue);
return retValue;
}
public String getValidation()
{
StringBuilder sb = new StringBuilder();
sb.append("SELECT vr.Code ");
sb.append("FROM AD_Column c");
sb.append(" LEFT OUTER JOIN AD_Val_Rule vr ON (c.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) ");
sb.append("WHERE c.AD_Column_ID=?");
String validation = DB.getSQLValueString(null, sb.toString(), m_AD_Column_ID);
if (validation == null)
return "";
return validation.trim();
}
private String getWhereClause()
{
String whereClause = "";
String validation = getValidation();
if (validation == null)
validation = "";
if (whereClause.length() == 0)
whereClause = validation;
else if (validation.length() > 0)
whereClause += " AND " + validation;
if (whereClause.indexOf('@') != -1)
{
String validated = Env.parseContext(Env.getCtx(), getWindowNo(), whereClause, false);
if (validated.length() == 0)
log.severe(getColumnName() + " - Cannot Parse=" + whereClause);
else
{
log.fine(getColumnName() + " - Parsed: " + validated);
return validated;
}
}
return whereClause;
}
@Override
public ArrayList<Object> getData(boolean mandatory, boolean onlyValidated,
boolean onlyActive, boolean temporary) {
ArrayList<Object> list = new ArrayList<Object>();
ValueNamePair[] values = getData();
for (ValueNamePair value : values)
{
String PaymentRule = value.getValue();
if (MInvoice.PAYMENTRULE_DirectDebit.equals(PaymentRule) // SO
&& !m_isSOTrx)
continue;
else if (MInvoice.PAYMENTRULE_DirectDeposit.equals(PaymentRule) // PO
&& m_isSOTrx)
continue;
list.add(value);
}
return list;
}
@Override
public int refresh() {
fillComboBox(isMandatory(), true, true, false);
return super.getSize();
}
}

View File

@ -96,6 +96,7 @@ public class SystemIDs
public final static int REFERENCE_DATATYPE_LOCATOR = 31;
public final static int REFERENCE_DATATYPE_MEMO = 34;
public final static int REFERENCE_DATATYPE_NUMBER = 22;
public final static int REFERENCE_DATATYPE_PAYMENT = 200012;
public final static int REFERENCE_DATATYPE_PRINTNAME = 42;
public final static int REFERENCE_DATATYPE_PRODUCTATTRIBUTE = 35;
public final static int REFERENCE_DATATYPE_QUANTITY = 29;

View File

@ -30,7 +30,7 @@ public class X_C_BP_BankAccount extends PO implements I_C_BP_BankAccount, I_Pers
/**
*
*/
private static final long serialVersionUID = 20100614L;
private static final long serialVersionUID = 20121012L;
/** Standard Constructor */
public X_C_BP_BankAccount (Properties ctx, int C_BP_BankAccount_ID, String trxName)
@ -39,8 +39,8 @@ public class X_C_BP_BankAccount extends PO implements I_C_BP_BankAccount, I_Pers
/** if (C_BP_BankAccount_ID == 0)
{
setA_Name (null);
setC_BPartner_ID (0);
setC_BP_BankAccount_ID (0);
setC_BPartner_ID (0);
setIsACH (false);
} */
}
@ -73,23 +73,6 @@ public class X_C_BP_BankAccount extends PO implements I_C_BP_BankAccount, I_Pers
return sb.toString();
}
/** Set Account No.
@param AccountNo
Account Number
*/
public void setAccountNo (String AccountNo)
{
set_Value (COLUMNNAME_AccountNo, AccountNo);
}
/** Get Account No.
@return Account Number
*/
public String getAccountNo ()
{
return (String)get_Value(COLUMNNAME_AccountNo);
}
/** Set Account City.
@param A_City
City or the Credit Card or Account Holder
@ -124,34 +107,6 @@ public class X_C_BP_BankAccount extends PO implements I_C_BP_BankAccount, I_Pers
return (String)get_Value(COLUMNNAME_A_Country);
}
public I_AD_User getAD_User() throws RuntimeException
{
return (I_AD_User)MTable.get(getCtx(), I_AD_User.Table_Name)
.getPO(getAD_User_ID(), get_TrxName()); }
/** Set User/Contact.
@param AD_User_ID
User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID)
{
if (AD_User_ID < 1)
set_Value (COLUMNNAME_AD_User_ID, null);
else
set_Value (COLUMNNAME_AD_User_ID, Integer.valueOf(AD_User_ID));
}
/** Get User/Contact.
@return User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_User_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Account EMail.
@param A_EMail
Email Address
@ -279,12 +234,61 @@ public class X_C_BP_BankAccount extends PO implements I_C_BP_BankAccount, I_Pers
return (String)get_Value(COLUMNNAME_A_Zip);
}
/** Set Account No.
@param AccountNo
Account Number
*/
public void setAccountNo (String AccountNo)
{
set_Value (COLUMNNAME_AccountNo, AccountNo);
}
/** Get Account No.
@return Account Number
*/
public String getAccountNo ()
{
return (String)get_Value(COLUMNNAME_AccountNo);
}
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException
{
return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name)
.getPO(getAD_User_ID(), get_TrxName()); }
/** Set User/Contact.
@param AD_User_ID
User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID)
{
if (AD_User_ID < 1)
set_Value (COLUMNNAME_AD_User_ID, null);
else
set_Value (COLUMNNAME_AD_User_ID, Integer.valueOf(AD_User_ID));
}
/** Get User/Contact.
@return User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_User_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** BankAccountType AD_Reference_ID=216 */
public static final int BANKACCOUNTTYPE_AD_Reference_ID=216;
/** Checking = C */
public static final String BANKACCOUNTTYPE_Checking = "C";
/** Savings = S */
public static final String BANKACCOUNTTYPE_Savings = "S";
/** Cash = B */
public static final String BANKACCOUNTTYPE_Cash = "B";
/** Card = D */
public static final String BANKACCOUNTTYPE_Card = "D";
/** Set Bank Account Type.
@param BankAccountType
Bank Account Type
@ -331,9 +335,9 @@ public class X_C_BP_BankAccount extends PO implements I_C_BP_BankAccount, I_Pers
return (String)get_Value(COLUMNNAME_BPBankAcctUse);
}
public I_C_Bank getC_Bank() throws RuntimeException
public org.compiere.model.I_C_Bank getC_Bank() throws RuntimeException
{
return (I_C_Bank)MTable.get(getCtx(), I_C_Bank.Table_Name)
return (org.compiere.model.I_C_Bank)MTable.get(getCtx(), org.compiere.model.I_C_Bank.Table_Name)
.getPO(getC_Bank_ID(), get_TrxName()); }
/** Set Bank.
@ -359,9 +363,46 @@ public class X_C_BP_BankAccount extends PO implements I_C_BP_BankAccount, I_Pers
return ii.intValue();
}
public I_C_BPartner getC_BPartner() throws RuntimeException
/** Set Partner Bank Account.
@param C_BP_BankAccount_ID
Bank Account of the Business Partner
*/
public void setC_BP_BankAccount_ID (int C_BP_BankAccount_ID)
{
if (C_BP_BankAccount_ID < 1)
set_ValueNoCheck (COLUMNNAME_C_BP_BankAccount_ID, null);
else
set_ValueNoCheck (COLUMNNAME_C_BP_BankAccount_ID, Integer.valueOf(C_BP_BankAccount_ID));
}
/** Get Partner Bank Account.
@return Bank Account of the Business Partner
*/
public int getC_BP_BankAccount_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_BP_BankAccount_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set C_BP_BankAccount_UU.
@param C_BP_BankAccount_UU C_BP_BankAccount_UU */
public void setC_BP_BankAccount_UU (String C_BP_BankAccount_UU)
{
set_Value (COLUMNNAME_C_BP_BankAccount_UU, C_BP_BankAccount_UU);
}
/** Get C_BP_BankAccount_UU.
@return C_BP_BankAccount_UU */
public String getC_BP_BankAccount_UU ()
{
return (String)get_Value(COLUMNNAME_C_BP_BankAccount_UU);
}
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException
{
return (I_C_BPartner)MTable.get(getCtx(), I_C_BPartner.Table_Name)
return (org.compiere.model.I_C_BPartner)MTable.get(getCtx(), org.compiere.model.I_C_BPartner.Table_Name)
.getPO(getC_BPartner_ID(), get_TrxName()); }
/** Set Business Partner .
@ -387,29 +428,6 @@ public class X_C_BP_BankAccount extends PO implements I_C_BP_BankAccount, I_Pers
return ii.intValue();
}
/** Set Partner Bank Account.
@param C_BP_BankAccount_ID
Bank Account of the Business Partner
*/
public void setC_BP_BankAccount_ID (int C_BP_BankAccount_ID)
{
if (C_BP_BankAccount_ID < 1)
set_ValueNoCheck (COLUMNNAME_C_BP_BankAccount_ID, null);
else
set_ValueNoCheck (COLUMNNAME_C_BP_BankAccount_ID, Integer.valueOf(C_BP_BankAccount_ID));
}
/** Get Partner Bank Account.
@return Bank Account of the Business Partner
*/
public int getC_BP_BankAccount_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_BP_BankAccount_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Exp. Month.
@param CreditCardExpMM
Expiry Month
@ -518,6 +536,20 @@ public class X_C_BP_BankAccount extends PO implements I_C_BP_BankAccount, I_Pers
return (String)get_Value(COLUMNNAME_CreditCardVV);
}
/** Set Customer Payment Profile ID.
@param CustomerPaymentProfileID Customer Payment Profile ID */
public void setCustomerPaymentProfileID (String CustomerPaymentProfileID)
{
set_Value (COLUMNNAME_CustomerPaymentProfileID, CustomerPaymentProfileID);
}
/** Get Customer Payment Profile ID.
@return Customer Payment Profile ID */
public String getCustomerPaymentProfileID ()
{
return (String)get_Value(COLUMNNAME_CustomerPaymentProfileID);
}
/** Set ACH.
@param IsACH
Automatic Clearing House

View File

@ -33,7 +33,7 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20120906L;
private static final long serialVersionUID = 20121012L;
/** Standard Constructor */
public X_C_BPartner (Properties ctx, int C_BPartner_ID, String trxName)
@ -41,8 +41,8 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent
super (ctx, C_BPartner_ID, trxName);
/** if (C_BPartner_ID == 0)
{
setC_BPartner_ID (0);
setC_BP_Group_ID (0);
setC_BPartner_ID (0);
setIsCustomer (false);
setIsEmployee (false);
setIsOneTime (false);
@ -188,6 +188,34 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent
return ii.intValue();
}
public org.compiere.model.I_C_BP_Group getC_BP_Group() throws RuntimeException
{
return (org.compiere.model.I_C_BP_Group)MTable.get(getCtx(), org.compiere.model.I_C_BP_Group.Table_Name)
.getPO(getC_BP_Group_ID(), get_TrxName()); }
/** Set Business Partner Group.
@param C_BP_Group_ID
Business Partner Group
*/
public void setC_BP_Group_ID (int C_BP_Group_ID)
{
if (C_BP_Group_ID < 1)
set_Value (COLUMNNAME_C_BP_Group_ID, null);
else
set_Value (COLUMNNAME_C_BP_Group_ID, Integer.valueOf(C_BP_Group_ID));
}
/** Get Business Partner Group.
@return Business Partner Group
*/
public int getC_BP_Group_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_BP_Group_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Business Partner .
@param C_BPartner_ID
Identifies a Business Partner
@ -225,34 +253,6 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent
return (String)get_Value(COLUMNNAME_C_BPartner_UU);
}
public org.compiere.model.I_C_BP_Group getC_BP_Group() throws RuntimeException
{
return (org.compiere.model.I_C_BP_Group)MTable.get(getCtx(), org.compiere.model.I_C_BP_Group.Table_Name)
.getPO(getC_BP_Group_ID(), get_TrxName()); }
/** Set Business Partner Group.
@param C_BP_Group_ID
Business Partner Group
*/
public void setC_BP_Group_ID (int C_BP_Group_ID)
{
if (C_BP_Group_ID < 1)
set_Value (COLUMNNAME_C_BP_Group_ID, null);
else
set_Value (COLUMNNAME_C_BP_Group_ID, Integer.valueOf(C_BP_Group_ID));
}
/** Get Business Partner Group.
@return Business Partner Group
*/
public int getC_BP_Group_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_BP_Group_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_C_Dunning getC_Dunning() throws RuntimeException
{
return (org.compiere.model.I_C_Dunning)MTable.get(getCtx(), org.compiere.model.I_C_Dunning.Table_Name)
@ -390,6 +390,20 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent
return ii.intValue();
}
/** Set Customer Profile ID.
@param CustomerProfileID Customer Profile ID */
public void setCustomerProfileID (String CustomerProfileID)
{
set_Value (COLUMNNAME_CustomerProfileID, CustomerProfileID);
}
/** Get Customer Profile ID.
@return Customer Profile ID */
public String getCustomerProfileID ()
{
return (String)get_Value(COLUMNNAME_CustomerProfileID);
}
/** DeliveryRule AD_Reference_ID=151 */
public static final int DELIVERYRULE_AD_Reference_ID=151;
/** After Receipt = R */
@ -1408,36 +1422,6 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent
return bd;
}
/** SOCreditStatus AD_Reference_ID=289 */
public static final int SOCREDITSTATUS_AD_Reference_ID=289;
/** Credit Stop = S */
public static final String SOCREDITSTATUS_CreditStop = "S";
/** Credit Hold = H */
public static final String SOCREDITSTATUS_CreditHold = "H";
/** Credit Watch = W */
public static final String SOCREDITSTATUS_CreditWatch = "W";
/** No Credit Check = X */
public static final String SOCREDITSTATUS_NoCreditCheck = "X";
/** Credit OK = O */
public static final String SOCREDITSTATUS_CreditOK = "O";
/** Set Credit Status.
@param SOCreditStatus
Business Partner Credit Status
*/
public void setSOCreditStatus (String SOCreditStatus)
{
set_Value (COLUMNNAME_SOCreditStatus, SOCreditStatus);
}
/** Get Credit Status.
@return Business Partner Credit Status
*/
public String getSOCreditStatus ()
{
return (String)get_Value(COLUMNNAME_SOCreditStatus);
}
/** Set Credit Used.
@param SO_CreditUsed
Current open balance
@ -1475,6 +1459,36 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent
return (String)get_Value(COLUMNNAME_SO_Description);
}
/** SOCreditStatus AD_Reference_ID=289 */
public static final int SOCREDITSTATUS_AD_Reference_ID=289;
/** Credit Stop = S */
public static final String SOCREDITSTATUS_CreditStop = "S";
/** Credit Hold = H */
public static final String SOCREDITSTATUS_CreditHold = "H";
/** Credit Watch = W */
public static final String SOCREDITSTATUS_CreditWatch = "W";
/** No Credit Check = X */
public static final String SOCREDITSTATUS_NoCreditCheck = "X";
/** Credit OK = O */
public static final String SOCREDITSTATUS_CreditOK = "O";
/** Set Credit Status.
@param SOCreditStatus
Business Partner Credit Status
*/
public void setSOCreditStatus (String SOCreditStatus)
{
set_Value (COLUMNNAME_SOCreditStatus, SOCreditStatus);
}
/** Get Credit Status.
@return Business Partner Credit Status
*/
public String getSOCreditStatus ()
{
return (String)get_Value(COLUMNNAME_SOCreditStatus);
}
/** Set Tax ID.
@param TaxID
Tax Identification

View File

@ -30,7 +30,7 @@ public class X_C_BPartner_Location extends PO implements I_C_BPartner_Location,
/**
*
*/
private static final long serialVersionUID = 20100614L;
private static final long serialVersionUID = 20121012L;
/** Standard Constructor */
public X_C_BPartner_Location (Properties ctx, int C_BPartner_Location_ID, String trxName)
@ -82,9 +82,9 @@ public class X_C_BPartner_Location extends PO implements I_C_BPartner_Location,
return sb.toString();
}
public I_C_BPartner getC_BPartner() throws RuntimeException
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException
{
return (I_C_BPartner)MTable.get(getCtx(), I_C_BPartner.Table_Name)
return (org.compiere.model.I_C_BPartner)MTable.get(getCtx(), org.compiere.model.I_C_BPartner.Table_Name)
.getPO(getC_BPartner_ID(), get_TrxName()); }
/** Set Business Partner .
@ -133,6 +133,20 @@ public class X_C_BPartner_Location extends PO implements I_C_BPartner_Location,
return ii.intValue();
}
/** Set C_BPartner_Location_UU.
@param C_BPartner_Location_UU C_BPartner_Location_UU */
public void setC_BPartner_Location_UU (String C_BPartner_Location_UU)
{
set_Value (COLUMNNAME_C_BPartner_Location_UU, C_BPartner_Location_UU);
}
/** Get C_BPartner_Location_UU.
@return C_BPartner_Location_UU */
public String getC_BPartner_Location_UU ()
{
return (String)get_Value(COLUMNNAME_C_BPartner_Location_UU);
}
public I_C_Location getC_Location() throws RuntimeException
{
return (I_C_Location)MTable.get(getCtx(), I_C_Location.Table_Name)
@ -161,9 +175,9 @@ public class X_C_BPartner_Location extends PO implements I_C_BPartner_Location,
return ii.intValue();
}
public I_C_SalesRegion getC_SalesRegion() throws RuntimeException
public org.compiere.model.I_C_SalesRegion getC_SalesRegion() throws RuntimeException
{
return (I_C_SalesRegion)MTable.get(getCtx(), I_C_SalesRegion.Table_Name)
return (org.compiere.model.I_C_SalesRegion)MTable.get(getCtx(), org.compiere.model.I_C_SalesRegion.Table_Name)
.getPO(getC_SalesRegion_ID(), get_TrxName()); }
/** Set Sales Region.
@ -189,6 +203,20 @@ public class X_C_BPartner_Location extends PO implements I_C_BPartner_Location,
return ii.intValue();
}
/** Set Customer Address ID.
@param CustomerAddressID Customer Address ID */
public void setCustomerAddressID (String CustomerAddressID)
{
set_Value (COLUMNNAME_CustomerAddressID, CustomerAddressID);
}
/** Get Customer Address ID.
@return Customer Address ID */
public String getCustomerAddressID ()
{
return (String)get_Value(COLUMNNAME_CustomerAddressID);
}
/** Set Fax.
@param Fax
Facsimile number

View File

@ -33,7 +33,7 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20120906L;
private static final long serialVersionUID = 20121012L;
/** Standard Constructor */
public X_C_Payment (Properties ctx, int C_Payment_ID, String trxName)
@ -65,6 +65,8 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
setIsReceipt (false);
setIsReconciled (false);
setIsSelfService (false);
setIsVoided (false);
// N
setPayAmt (Env.ZERO);
// 0
setPosted (false);
@ -105,23 +107,6 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return sb.toString();
}
/** Set Account No.
@param AccountNo
Account Number
*/
public void setAccountNo (String AccountNo)
{
set_Value (COLUMNNAME_AccountNo, AccountNo);
}
/** Get Account No.
@return Account Number
*/
public String getAccountNo ()
{
return (String)get_Value(COLUMNNAME_AccountNo);
}
/** Set Account City.
@param A_City
City or the Credit Card or Account Holder
@ -156,29 +141,6 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return (String)get_Value(COLUMNNAME_A_Country);
}
/** Set Trx Organization.
@param AD_OrgTrx_ID
Performing or initiating organization
*/
public void setAD_OrgTrx_ID (int AD_OrgTrx_ID)
{
if (AD_OrgTrx_ID < 1)
set_Value (COLUMNNAME_AD_OrgTrx_ID, null);
else
set_Value (COLUMNNAME_AD_OrgTrx_ID, Integer.valueOf(AD_OrgTrx_ID));
}
/** Get Trx Organization.
@return Performing or initiating organization
*/
public int getAD_OrgTrx_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_OrgTrx_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Account EMail.
@param A_EMail
Email Address
@ -298,6 +260,46 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return (String)get_Value(COLUMNNAME_A_Zip);
}
/** Set Account No.
@param AccountNo
Account Number
*/
public void setAccountNo (String AccountNo)
{
set_Value (COLUMNNAME_AccountNo, AccountNo);
}
/** Get Account No.
@return Account Number
*/
public String getAccountNo ()
{
return (String)get_Value(COLUMNNAME_AccountNo);
}
/** Set Trx Organization.
@param AD_OrgTrx_ID
Performing or initiating organization
*/
public void setAD_OrgTrx_ID (int AD_OrgTrx_ID)
{
if (AD_OrgTrx_ID < 1)
set_Value (COLUMNNAME_AD_OrgTrx_ID, null);
else
set_Value (COLUMNNAME_AD_OrgTrx_ID, Integer.valueOf(AD_OrgTrx_ID));
}
/** Get Trx Organization.
@return Performing or initiating organization
*/
public int getAD_OrgTrx_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_OrgTrx_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_C_Activity getC_Activity() throws RuntimeException
{
return (org.compiere.model.I_C_Activity)MTable.get(getCtx(), org.compiere.model.I_C_Activity.Table_Name)
@ -354,34 +356,6 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return ii.intValue();
}
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException
{
return (org.compiere.model.I_C_BPartner)MTable.get(getCtx(), org.compiere.model.I_C_BPartner.Table_Name)
.getPO(getC_BPartner_ID(), get_TrxName()); }
/** Set Business Partner .
@param C_BPartner_ID
Identifies a Business Partner
*/
public void setC_BPartner_ID (int C_BPartner_ID)
{
if (C_BPartner_ID < 1)
set_Value (COLUMNNAME_C_BPartner_ID, null);
else
set_Value (COLUMNNAME_C_BPartner_ID, Integer.valueOf(C_BPartner_ID));
}
/** Get Business Partner .
@return Identifies a Business Partner
*/
public int getC_BPartner_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_BPartner_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_C_BP_BankAccount getC_BP_BankAccount() throws RuntimeException
{
return (org.compiere.model.I_C_BP_BankAccount)MTable.get(getCtx(), org.compiere.model.I_C_BP_BankAccount.Table_Name)
@ -410,6 +384,34 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return ii.intValue();
}
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException
{
return (org.compiere.model.I_C_BPartner)MTable.get(getCtx(), org.compiere.model.I_C_BPartner.Table_Name)
.getPO(getC_BPartner_ID(), get_TrxName()); }
/** Set Business Partner .
@param C_BPartner_ID
Identifies a Business Partner
*/
public void setC_BPartner_ID (int C_BPartner_ID)
{
if (C_BPartner_ID < 1)
set_Value (COLUMNNAME_C_BPartner_ID, null);
else
set_Value (COLUMNNAME_C_BPartner_ID, Integer.valueOf(C_BPartner_ID));
}
/** Get Business Partner .
@return Identifies a Business Partner
*/
public int getC_BPartner_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_BPartner_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_C_Campaign getC_Campaign() throws RuntimeException
{
return (org.compiere.model.I_C_Campaign)MTable.get(getCtx(), org.compiere.model.I_C_Campaign.Table_Name)
@ -578,43 +580,6 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return ii.intValue();
}
/** Set Charge amount.
@param ChargeAmt
Charge Amount
*/
public void setChargeAmt (BigDecimal ChargeAmt)
{
set_Value (COLUMNNAME_ChargeAmt, ChargeAmt);
}
/** Get Charge amount.
@return Charge Amount
*/
public BigDecimal getChargeAmt ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_ChargeAmt);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Check No.
@param CheckNo
Check Number
*/
public void setCheckNo (String CheckNo)
{
set_Value (COLUMNNAME_CheckNo, CheckNo);
}
/** Get Check No.
@return Check Number
*/
public String getCheckNo ()
{
return (String)get_Value(COLUMNNAME_CheckNo);
}
public org.compiere.model.I_C_Invoice getC_Invoice() throws RuntimeException
{
return (org.compiere.model.I_C_Invoice)MTable.get(getCtx(), org.compiere.model.I_C_Invoice.Table_Name)
@ -671,34 +636,6 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return ii.intValue();
}
public org.compiere.model.I_C_PaymentBatch getC_PaymentBatch() throws RuntimeException
{
return (org.compiere.model.I_C_PaymentBatch)MTable.get(getCtx(), org.compiere.model.I_C_PaymentBatch.Table_Name)
.getPO(getC_PaymentBatch_ID(), get_TrxName()); }
/** Set Payment Batch.
@param C_PaymentBatch_ID
Payment batch for EFT
*/
public void setC_PaymentBatch_ID (int C_PaymentBatch_ID)
{
if (C_PaymentBatch_ID < 1)
set_Value (COLUMNNAME_C_PaymentBatch_ID, null);
else
set_Value (COLUMNNAME_C_PaymentBatch_ID, Integer.valueOf(C_PaymentBatch_ID));
}
/** Get Payment Batch.
@return Payment batch for EFT
*/
public int getC_PaymentBatch_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_PaymentBatch_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Payment.
@param C_Payment_ID
Payment identifier
@ -736,6 +673,62 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return (String)get_Value(COLUMNNAME_C_Payment_UU);
}
public org.compiere.model.I_C_PaymentBatch getC_PaymentBatch() throws RuntimeException
{
return (org.compiere.model.I_C_PaymentBatch)MTable.get(getCtx(), org.compiere.model.I_C_PaymentBatch.Table_Name)
.getPO(getC_PaymentBatch_ID(), get_TrxName()); }
/** Set Payment Batch.
@param C_PaymentBatch_ID
Payment batch for EFT
*/
public void setC_PaymentBatch_ID (int C_PaymentBatch_ID)
{
if (C_PaymentBatch_ID < 1)
set_Value (COLUMNNAME_C_PaymentBatch_ID, null);
else
set_Value (COLUMNNAME_C_PaymentBatch_ID, Integer.valueOf(C_PaymentBatch_ID));
}
/** Get Payment Batch.
@return Payment batch for EFT
*/
public int getC_PaymentBatch_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_PaymentBatch_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_C_PaymentProcessor getC_PaymentProcessor() throws RuntimeException
{
return (org.compiere.model.I_C_PaymentProcessor)MTable.get(getCtx(), org.compiere.model.I_C_PaymentProcessor.Table_Name)
.getPO(getC_PaymentProcessor_ID(), get_TrxName()); }
/** Set Payment Processor.
@param C_PaymentProcessor_ID
Payment processor for electronic payments
*/
public void setC_PaymentProcessor_ID (int C_PaymentProcessor_ID)
{
if (C_PaymentProcessor_ID < 1)
set_Value (COLUMNNAME_C_PaymentProcessor_ID, null);
else
set_Value (COLUMNNAME_C_PaymentProcessor_ID, Integer.valueOf(C_PaymentProcessor_ID));
}
/** Get Payment Processor.
@return Payment processor for electronic payments
*/
public int getC_PaymentProcessor_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_PaymentProcessor_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_C_POSTenderType getC_POSTenderType() throws RuntimeException
{
return (org.compiere.model.I_C_POSTenderType)MTable.get(getCtx(), org.compiere.model.I_C_POSTenderType.Table_Name)
@ -789,6 +782,43 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return ii.intValue();
}
/** Set Charge amount.
@param ChargeAmt
Charge Amount
*/
public void setChargeAmt (BigDecimal ChargeAmt)
{
set_Value (COLUMNNAME_ChargeAmt, ChargeAmt);
}
/** Get Charge amount.
@return Charge Amount
*/
public BigDecimal getChargeAmt ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_ChargeAmt);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Check No.
@param CheckNo
Check Number
*/
public void setCheckNo (String CheckNo)
{
set_Value (COLUMNNAME_CheckNo, CheckNo);
}
/** Get Check No.
@return Check Number
*/
public String getCheckNo ()
{
return (String)get_Value(COLUMNNAME_CheckNo);
}
/** Set Exp. Month.
@param CreditCardExpMM
Expiry Month
@ -897,6 +927,48 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return (String)get_Value(COLUMNNAME_CreditCardVV);
}
/** Set Customer Address ID.
@param CustomerAddressID Customer Address ID */
public void setCustomerAddressID (String CustomerAddressID)
{
set_Value (COLUMNNAME_CustomerAddressID, CustomerAddressID);
}
/** Get Customer Address ID.
@return Customer Address ID */
public String getCustomerAddressID ()
{
return (String)get_Value(COLUMNNAME_CustomerAddressID);
}
/** Set Customer Payment Profile ID.
@param CustomerPaymentProfileID Customer Payment Profile ID */
public void setCustomerPaymentProfileID (String CustomerPaymentProfileID)
{
set_Value (COLUMNNAME_CustomerPaymentProfileID, CustomerPaymentProfileID);
}
/** Get Customer Payment Profile ID.
@return Customer Payment Profile ID */
public String getCustomerPaymentProfileID ()
{
return (String)get_Value(COLUMNNAME_CustomerPaymentProfileID);
}
/** Set Customer Profile ID.
@param CustomerProfileID Customer Profile ID */
public void setCustomerProfileID (String CustomerProfileID)
{
set_Value (COLUMNNAME_CustomerProfileID, CustomerProfileID);
}
/** Get Customer Profile ID.
@return Customer Profile ID */
public String getCustomerProfileID ()
{
return (String)get_Value(COLUMNNAME_CustomerProfileID);
}
/** Set Account Date.
@param DateAcct
Accounting Date
@ -1301,6 +1373,27 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return false;
}
/** Set Voided.
@param IsVoided Voided */
public void setIsVoided (boolean IsVoided)
{
set_Value (COLUMNNAME_IsVoided, Boolean.valueOf(IsVoided));
}
/** Get Voided.
@return Voided */
public boolean isVoided ()
{
Object oo = get_Value(COLUMNNAME_IsVoided);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Micr.
@param Micr
Combination of routing no, account and check no
@ -1608,59 +1701,6 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return false;
}
public org.compiere.model.I_C_Payment getRef_Payment() throws RuntimeException
{
return (org.compiere.model.I_C_Payment)MTable.get(getCtx(), org.compiere.model.I_C_Payment.Table_Name)
.getPO(getRef_Payment_ID(), get_TrxName()); }
/** Set Referenced Payment.
@param Ref_Payment_ID Referenced Payment */
public void setRef_Payment_ID (int Ref_Payment_ID)
{
if (Ref_Payment_ID < 1)
set_ValueNoCheck (COLUMNNAME_Ref_Payment_ID, null);
else
set_ValueNoCheck (COLUMNNAME_Ref_Payment_ID, Integer.valueOf(Ref_Payment_ID));
}
/** Get Referenced Payment.
@return Referenced Payment */
public int getRef_Payment_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_Ref_Payment_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_C_Payment getReversal() throws RuntimeException
{
return (org.compiere.model.I_C_Payment)MTable.get(getCtx(), org.compiere.model.I_C_Payment.Table_Name)
.getPO(getReversal_ID(), get_TrxName()); }
/** Set Reversal ID.
@param Reversal_ID
ID of document reversal
*/
public void setReversal_ID (int Reversal_ID)
{
if (Reversal_ID < 1)
set_Value (COLUMNNAME_Reversal_ID, null);
else
set_Value (COLUMNNAME_Reversal_ID, Integer.valueOf(Reversal_ID));
}
/** Get Reversal ID.
@return ID of document reversal
*/
public int getReversal_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_Reversal_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Info.
@param R_Info
Response info
@ -1678,23 +1718,6 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return (String)get_Value(COLUMNNAME_R_Info);
}
/** Set Routing No.
@param RoutingNo
Bank Routing Number
*/
public void setRoutingNo (String RoutingNo)
{
set_Value (COLUMNNAME_RoutingNo, RoutingNo);
}
/** Get Routing No.
@return Bank Routing Number
*/
public String getRoutingNo ()
{
return (String)get_Value(COLUMNNAME_RoutingNo);
}
/** Set Reference.
@param R_PnRef
Payment reference
@ -1763,6 +1786,90 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
return (String)get_Value(COLUMNNAME_R_Result);
}
/** Set Void Message.
@param R_VoidMsg Void Message */
public void setR_VoidMsg (String R_VoidMsg)
{
set_Value (COLUMNNAME_R_VoidMsg, R_VoidMsg);
}
/** Get Void Message.
@return Void Message */
public String getR_VoidMsg ()
{
return (String)get_Value(COLUMNNAME_R_VoidMsg);
}
public org.compiere.model.I_C_Payment getRef_Payment() throws RuntimeException
{
return (org.compiere.model.I_C_Payment)MTable.get(getCtx(), org.compiere.model.I_C_Payment.Table_Name)
.getPO(getRef_Payment_ID(), get_TrxName()); }
/** Set Referenced Payment.
@param Ref_Payment_ID Referenced Payment */
public void setRef_Payment_ID (int Ref_Payment_ID)
{
if (Ref_Payment_ID < 1)
set_ValueNoCheck (COLUMNNAME_Ref_Payment_ID, null);
else
set_ValueNoCheck (COLUMNNAME_Ref_Payment_ID, Integer.valueOf(Ref_Payment_ID));
}
/** Get Referenced Payment.
@return Referenced Payment */
public int getRef_Payment_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_Ref_Payment_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_C_Payment getReversal() throws RuntimeException
{
return (org.compiere.model.I_C_Payment)MTable.get(getCtx(), org.compiere.model.I_C_Payment.Table_Name)
.getPO(getReversal_ID(), get_TrxName()); }
/** Set Reversal ID.
@param Reversal_ID
ID of document reversal
*/
public void setReversal_ID (int Reversal_ID)
{
if (Reversal_ID < 1)
set_Value (COLUMNNAME_Reversal_ID, null);
else
set_Value (COLUMNNAME_Reversal_ID, Integer.valueOf(Reversal_ID));
}
/** Get Reversal ID.
@return ID of document reversal
*/
public int getReversal_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_Reversal_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Routing No.
@param RoutingNo
Bank Routing Number
*/
public void setRoutingNo (String RoutingNo)
{
set_Value (COLUMNNAME_RoutingNo, RoutingNo);
}
/** Get Routing No.
@return Bank Routing Number
*/
public String getRoutingNo ()
{
return (String)get_Value(COLUMNNAME_RoutingNo);
}
/** Set Swipe.
@param Swipe
Track 1 and 2 of the Credit Card

View File

@ -16,6 +16,40 @@
*****************************************************************************/
package org.compiere.util;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_ACCOUNT;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_AMOUNT;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_ASSIGNMENT;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_BINARY;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_BUTTON;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_COLOR;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_COSTPRICE;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_DATE;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_DATETIME;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_FILENAME;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_FILEPATH;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_ID;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_IMAGE;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_INTEGER;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_LIST;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_LOCATION;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_LOCATOR;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_MEMO;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_NUMBER;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_PAYMENT;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_PRINTNAME;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_PRODUCTATTRIBUTE;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_QUANTITY;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_ROWID;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_SEARCH;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_STRING;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_TABLE;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_TABLEDIR;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_TEXT;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_TEXTLONG;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_TIME;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_URL;
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_YES_NO;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
@ -23,8 +57,6 @@ import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.logging.Level;
import static org.compiere.model.SystemIDs.*;
/**
* System Display Types.
* <pre>
@ -103,6 +135,8 @@ public final class DisplayType
/** Display Type 42 PrinterName */
public static final int PrinterName = REFERENCE_DATATYPE_PRINTNAME;
// Candidates:
/** Display Type 200012 Payment */
public static final int Payment = REFERENCE_DATATYPE_PAYMENT;
/**
* - New Display Type
@ -428,7 +462,7 @@ public final class DisplayType
*/
public static Class getClass (int displayType, boolean yesNoAsBoolean)
{
if (isText(displayType) || displayType == List)
if (isText(displayType) || displayType == List || displayType == Payment)
return String.class;
else if (isID(displayType) || displayType == Integer) // note that Integer is stored as BD
return Integer.class;
@ -488,7 +522,7 @@ public final class DisplayType
return "CLOB";
if (displayType == DisplayType.YesNo)
return "CHAR(1)";
if (displayType == DisplayType.List) {
if (displayType == DisplayType.List || displayType == DisplayType.Payment) {
if (fieldLength == 1)
return "CHAR(" + fieldLength + ")";
else
@ -585,6 +619,8 @@ public final class DisplayType
return "URL";
if (displayType == PrinterName)
return "PrinterName";
if (displayType == Payment)
return "Payment";
//
return "UNKNOWN DisplayType=" + displayType;
} // getDescription

View File

@ -31,6 +31,7 @@ import org.compiere.grid.ed.VMemo;
import org.compiere.grid.ed.VNumber;
import org.compiere.grid.ed.VPAttribute;
import org.compiere.grid.ed.VPassword;
import org.compiere.grid.ed.VPaymentEditor;
import org.compiere.grid.ed.VString;
import org.compiere.grid.ed.VText;
import org.compiere.grid.ed.VTextLong;
@ -41,6 +42,7 @@ import org.compiere.model.MAccountLookup;
import org.compiere.model.MLocationLookup;
import org.compiere.model.MLocatorLookup;
import org.compiere.model.MPAttributeLookup;
import org.compiere.model.MPaymentLookup;
import org.compiere.util.DisplayType;
/**
@ -285,6 +287,12 @@ public class DefaultEditorFactory implements IEditorFactory {
bin.setField (mField);
editor = bin;
}
else if (displayType == DisplayType.Payment)
{
VPaymentEditor p = new VPaymentEditor (mField, columnName, mandatory, readOnly, updateable, (MPaymentLookup) mField.getLookup());
editor = p;
}
return editor;
}

View File

@ -0,0 +1,231 @@
package org.compiere.grid;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Enumeration;
import org.compiere.apps.ADialog;
import org.compiere.grid.ed.VDate;
import org.compiere.grid.ed.VNumber;
import org.compiere.model.GridTab;
import org.compiere.model.MConversionRate;
import org.compiere.model.MInvoice;
import org.compiere.swing.CComboBox;
import org.compiere.swing.CLabel;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
public class VPaymentFormCash extends PaymentFormCash implements ActionListener {
private VPaymentFormDialog dialog;
private CLabel bBankAccountLabel = new CLabel();
private CComboBox bBankAccountCombo = new CComboBox();
private CLabel bCashBookLabel = new CLabel();
private CComboBox bCashBookCombo = new CComboBox();
private CLabel bCurrencyLabel = new CLabel();
private CComboBox bCurrencyCombo = new CComboBox();
private VDate bDateField;
private CLabel bDateLabel = new CLabel();
private CLabel bAmountLabel = new CLabel();
private VNumber bAmountField = new VNumber();
public VPaymentFormCash(int windowNo, GridTab mTab) {
super(windowNo, mTab);
bDateField = new VDate("DateAcct", false, false, true, DisplayType.Date, "DateAcct");
dialog = new VPaymentFormDialog(this, windowNo);
init();
//Bojana&Daniel
//If Invoice is Vendor invoice then Cash has to be created by negative amount
int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), 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;
}
public void init() {
GridBagLayout bPanelLayout = new GridBagLayout();
bBankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
bCurrencyLabel.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
dialog.getPanel().setLayout(bPanelLayout);
bAmountLabel.setText(Msg.getMsg(Env.getCtx(), "Amount"));
//bAmountField.setText("");
bDateLabel.setText(Msg.translate(Env.getCtx(), "DateAcct"));
if (m_Cash_As_Payment){
dialog.getPanel().add(bBankAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
dialog.getPanel().add(bBankAccountCombo, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
} else {
bCashBookLabel.setText(Msg.translate(Env.getCtx(), "C_CashBook_ID"));
dialog.getPanel().add(bCashBookLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
dialog.getPanel().add(bCashBookCombo, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
}
dialog.getPanel().add(bCurrencyLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
dialog.getPanel().add(bCurrencyCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
dialog.getPanel().add(bDateLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 2, 0), 0, 0));
dialog.getPanel().add(bDateField, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0));
dialog.getPanel().add(bAmountLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 2, 0), 0, 0));
dialog.getPanel().add(bAmountField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0));
}
@Override
public void loadData() {
bAmountField.setValue(m_Amount);
if (m_C_Payment_ID != 0)
bAmountField.setValue(m_mPayment.getPayAmt());
// Existing Cashbook entry
if (m_C_CashLine_ID != 0)
bAmountField.setValue(m_cashLine.getAmount());
// Accounting Date
bDateField.setValue(m_DateAcct);
// 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));
}
bCurrencyCombo.addActionListener(this);
bCurrencyCombo.setSelectedItem(s_Currencies.get(C_Currency_ID));
}
else // No EMU Currency
{
bCurrencyLabel.setVisible(false); // Cash
bCurrencyCombo.setVisible(false);
}
ArrayList<KeyNamePair> list = getBankAccountList();
for (KeyNamePair pp : list)
bBankAccountCombo.addItem(pp);
// Set Selection
if (selectedBankAccount != null)
bBankAccountCombo.setSelectedItem(selectedBankAccount);
list = getCashBookList();
for (KeyNamePair pp : list)
bCashBookCombo.addItem(pp);
// Set Selection
if (selectedCashBook != null)
bCashBookCombo.setSelectedItem(selectedCashBook);
}
public void actionPerformed(ActionEvent e)
{
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);
}
}
@Override
public boolean checkMandatory() {
int C_BankAccount_ID = 0;
/***********************
* Mandatory Data Check
*/
boolean dataOK = true;
if (m_Cash_As_Payment)
{
KeyNamePair kp = (KeyNamePair)bBankAccountCombo.getSelectedItem();
if (kp != null)
C_BankAccount_ID = kp.getKey();
}
// find Bank Account if not qualified yet
if (m_Cash_As_Payment && C_BankAccount_ID == 0)
{
// Check & Cash (Payment) must have a bank account
if (C_BankAccount_ID == 0 && m_Cash_As_Payment)
{
ADialog.error(getWindowNo(), dialog, "FillMandatory", bBankAccountLabel.getText());
dataOK = false;
}
}
return dataOK;
}
@Override
public boolean saveChangesInTrx(String trxName) {
int newC_CashBook_ID = m_C_CashBook_ID;
int newC_BankAccount_ID = 0;
if (m_Cash_As_Payment){
// get bank account
KeyNamePair kp = (KeyNamePair)bBankAccountCombo.getSelectedItem();
if (kp != null)
newC_BankAccount_ID = kp.getKey();
} else {
// get cash book
KeyNamePair kp = (KeyNamePair)bCashBookCombo.getSelectedItem();
if (kp != null)
newC_CashBook_ID = kp.getKey();
}
Timestamp newDateAcct = (Timestamp)bDateField.getValue();
boolean ok = save(newC_BankAccount_ID,newC_CashBook_ID, newDateAcct, (BigDecimal) bAmountField.getValue(), trxName);
if (!ok)
ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg);
else if (processMsg != null)
ADialog.info(getWindowNo(), dialog, "PaymentCreated", processMsg);
return true;
}
@Override
public void showWindow()
{
dialog.setVisible(true);
}
@Override
public void closeWindow()
{
dialog.dispose();
}
@Override
public Object getWindow() {
return dialog;
}
}

View File

@ -0,0 +1,225 @@
package org.compiere.grid;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Enumeration;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.apps.ADialog;
import org.compiere.grid.ed.VNumber;
import org.compiere.model.GridTab;
import org.compiere.model.MConversionRate;
import org.compiere.model.MPaymentValidate;
import org.compiere.swing.CButton;
import org.compiere.swing.CComboBox;
import org.compiere.swing.CLabel;
import org.compiere.swing.CTextField;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
public class VPaymentFormCheck extends PaymentFormCheck implements ActionListener {
private VPaymentFormDialog dialog;
private CLabel sBankAccountLabel = new CLabel();
private CComboBox sBankAccountCombo = new CComboBox();
private CLabel sCurrencyLabel = new CLabel();
private CComboBox sCurrencyCombo = new CComboBox();
private CLabel sAmountLabel = new CLabel();
private VNumber sAmountField = new VNumber();
private CLabel sRoutingLabel = new CLabel();
private CTextField sRoutingField = new CTextField();
private CLabel sNumberLabel = new CLabel();
private CTextField sNumberField = new CTextField();
private CLabel sCheckLabel = new CLabel();
private CTextField sCheckField = new CTextField();
private CButton sOnline = new CButton();
private CLabel sStatus = new CLabel();
public VPaymentFormCheck(int windowNo, GridTab mTab) {
super(windowNo, mTab);
dialog = new VPaymentFormDialog(this, windowNo);
init();
}
public void init() {
GridBagLayout sPanelLayout = new GridBagLayout();
dialog.getPanel().setLayout(sPanelLayout);
sBankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
sAmountLabel.setText(Msg.getMsg(Env.getCtx(), "Amount"));
//sAmountField.setText("");
sRoutingLabel.setText(Msg.translate(Env.getCtx(), "RoutingNo"));
sNumberLabel.setText(Msg.translate(Env.getCtx(), "AccountNo"));
sCheckLabel.setText(Msg.translate(Env.getCtx(), "CheckNo"));
sCheckField.setColumns(8);
sCurrencyLabel.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
sNumberField.setPreferredSize(new Dimension(100, 21));
sRoutingField.setPreferredSize(new Dimension(70, 21));
sStatus.setText(" ");
sOnline.setText(Msg.getMsg(Env.getCtx(), "Online"));
dialog.getPanel().add(sBankAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 2, 0), 0, 0));
dialog.getPanel().add(sBankAccountCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0));
dialog.getPanel().add(sCurrencyLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
dialog.getPanel().add(sCurrencyCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
dialog.getPanel().add(sAmountLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 5, 0), 0, 0));
dialog.getPanel().add(sAmountField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 5, 5), 0, 0));
dialog.getPanel().add(sRoutingLabel, new GridBagConstraints(0, 3, 1, 2, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 2, 0), 0, 0));
dialog.getPanel().add(sRoutingField, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 2, 0), 0, 0));
dialog.getPanel().add(sNumberLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
dialog.getPanel().add(sNumberField, new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 2, 0), 0, 0));
dialog.getPanel().add(sCheckLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
dialog.getPanel().add(sCheckField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 0), 0, 0));
dialog.getPanel().add(sOnline, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
dialog.getPanel().add(sStatus, new GridBagConstraints(0, 7, 3, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
@Override
public void loadData() {
sAmountField.setValue(m_Amount);
if (m_C_Payment_ID != 0)
{
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());
}
// 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();
sCurrencyCombo.addItem(s_Currencies.get(key));
}
sCurrencyCombo.addActionListener(this);
sCurrencyCombo.setSelectedItem(s_Currencies.get(C_Currency_ID));
}
else // No EMU Currency
{
sCurrencyLabel.setVisible(false); // Check
sCurrencyCombo.setVisible(false);
}
ArrayList<KeyNamePair> list = getBankAccountList();
for (KeyNamePair pp : list)
sBankAccountCombo.addItem(pp);
// Set Selection
if (selectedBankAccount != null)
sBankAccountCombo.setSelectedItem(selectedBankAccount);
}
public void actionPerformed(ActionEvent e)
{
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 if (e.getSource() == sOnline)
// processOnline();
}
@Override
public boolean checkMandatory() {
int C_BankAccount_ID = 0;
/***********************
* Mandatory Data Check
*/
boolean dataOK = true;
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(getWindowNo(), dialog, error);
dataOK = false;
}
error = MPaymentValidate.validateAccountNo(sNumberField.getText());
if (error.length() != 0)
{
sNumberField.setBackground(AdempierePLAF.getFieldBackground_Error());
ADialog.error(getWindowNo(), dialog, error);
dataOK = false;
}
error = MPaymentValidate.validateCheckNo(sCheckField.getText());
if (error.length() != 0)
{
sCheckField.setBackground(AdempierePLAF.getFieldBackground_Error());
ADialog.error(getWindowNo(), dialog, error);
dataOK = false;
}
// Check & Cash (Payment) must have a bank account
if (C_BankAccount_ID == 0)
{
ADialog.error(getWindowNo(), dialog, "FillMandatory", sBankAccountLabel.getText());
dataOK = false;
}
return dataOK;
}
@Override
public boolean saveChangesInTrx(String trxName) {
int newC_BankAccount_ID = 0;
KeyNamePair kp = (KeyNamePair)sBankAccountCombo.getSelectedItem();
if (kp != null)
newC_BankAccount_ID = kp.getKey();
boolean ok = save(newC_BankAccount_ID, sRoutingField.getText(), sNumberField.getText(), sCheckField.getText(), (BigDecimal) sAmountField.getValue());
if (!ok)
ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg);
else if (processMsg != null)
ADialog.info(getWindowNo(), dialog, "PaymentCreated", m_mPayment.getDocumentNo());
return true;
}
@Override
public void showWindow()
{
dialog.setVisible(true);
}
@Override
public void closeWindow()
{
dialog.dispose();
}
@Override
public Object getWindow() {
return dialog;
}
}

View File

@ -0,0 +1,188 @@
package org.compiere.grid;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import org.compiere.apps.ADialog;
import org.compiere.grid.ed.VNumber;
import org.compiere.model.GridTab;
import org.compiere.swing.CButton;
import org.compiere.swing.CComboBox;
import org.compiere.swing.CLabel;
import org.compiere.swing.CTextField;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.ValueNamePair;
public class VPaymentFormCreditCard extends PaymentFormCreditCard implements ActionListener {
private VPaymentFormDialog dialog;
private CLabel kTypeLabel = new CLabel();
private CComboBox kTypeCombo = new CComboBox();
private CLabel kNumberLabel = new CLabel();
private CTextField kNumberField = new CTextField();
private CLabel kNameLabel = new CLabel();
private CTextField kNameField = new CTextField();
private CLabel kExpLabel = new CLabel();
private CTextField kExpField = new CTextField();
private CLabel kAmountLabel = new CLabel();
private VNumber kAmountField = new VNumber();
private CLabel kApprovalLabel = new CLabel();
private CTextField kApprovalField = new CTextField();
private CButton kOnline = new CButton();
private CLabel kStatus = new CLabel();
public VPaymentFormCreditCard(int windowNo, GridTab mTab) {
super(windowNo, mTab);
dialog = new VPaymentFormDialog(this, windowNo);
init();
}
public void init() {
GridBagLayout kLayout = new GridBagLayout();
dialog.getPanel().setLayout(kLayout);
kNumberField.setPreferredSize(new Dimension(160, 21));
kNameField.setPreferredSize(new Dimension(160, 21));
kExpField.setPreferredSize(new Dimension(40, 21));
kApprovalField.setPreferredSize(new Dimension(120, 21));
kTypeLabel.setText(Msg.translate(Env.getCtx(), "CreditCardType"));
kNumberLabel.setText(Msg.translate(Env.getCtx(), "CreditCardNumber"));
kNameLabel.setText(Msg.translate(Env.getCtx(),"Name"));
kExpLabel.setText(Msg.getMsg(Env.getCtx(), "Expires"));
kApprovalLabel.setText(Msg.translate(Env.getCtx(), "VoiceAuthCode"));
kAmountLabel.setText(Msg.getMsg(Env.getCtx(), "Amount"));
kOnline.setText(Msg.getMsg(Env.getCtx(), "Online"));
kOnline.addActionListener(this);
kStatus.setText(" ");
dialog.getPanel().add(kTypeLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
dialog.getPanel().add(kTypeCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
dialog.getPanel().add(kNumberLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
dialog.getPanel().add(kNumberField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2, 5, 2, 5), 0, 0));
dialog.getPanel().add(kNameLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
dialog.getPanel().add(kNameField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2, 5, 2, 5), 0, 0));
dialog.getPanel().add(kExpLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
dialog.getPanel().add(kExpField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
dialog.getPanel().add(kAmountLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 5, 0), 0, 0));
dialog.getPanel().add(kAmountField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 5, 5), 0, 0));
dialog.getPanel().add(kApprovalLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
dialog.getPanel().add(kApprovalField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
dialog.getPanel().add(kStatus, new GridBagConstraints(0, 6, 2, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
dialog.getPanel().add(kOnline, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
@Override
public void loadData() {
kAmountField.setValue(m_Amount);
if (m_C_Payment_ID != 0)
{
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());
}
/**
* Load Credit Cards
*/
ValueNamePair[] ccs = getCreditCardList();
for (int i = 0; i < ccs.length; i++)
kTypeCombo.addItem(ccs[i]);
// Set Selection
if (selectedCreditCard != null)
kTypeCombo.setSelectedItem(selectedCreditCard);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == kOnline)
processOnline();
}
@Override
public boolean checkMandatory() {
return true;
}
@Override
public boolean saveChangesInTrx(String trxName) {
String newCCType = m_CCType;
ValueNamePair vp = (ValueNamePair)kTypeCombo.getSelectedItem();
if (vp != null)
newCCType = vp.getValue();
boolean ok = save(newCCType, kNumberField.getText(), kExpField.getText(), (BigDecimal) kAmountField.getValue());
if(!ok)
ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg);
else if (processMsg != null)
ADialog.info(getWindowNo(), dialog, "PaymentCreated", processMsg);
return true;
}
/**************************************************************************
* Process Online (sales only) - if approved - exit
*/
private void processOnline()
{
ValueNamePair vp = (ValueNamePair)kTypeCombo.getSelectedItem();
String CCType = vp.getValue();
boolean ok = processOnline(CCType, kNumberField.getText(), kExpField.getText());
if (!ok)
ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg);
else if (processMsg != null)
ADialog.info(getWindowNo(), dialog, "PaymentProcessed", processMsg);
} // online
@Override
public void showWindow()
{
dialog.setVisible(true);
}
@Override
public void closeWindow()
{
dialog.dispose();
}
@Override
public Object getWindow() {
return dialog;
}
}

View File

@ -0,0 +1,93 @@
package org.compiere.grid;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import org.compiere.apps.ADialog;
import org.compiere.apps.AEnv;
import org.compiere.apps.ConfirmPanel;
import org.compiere.swing.CDialog;
import org.compiere.swing.CPanel;
import org.compiere.util.Env;
import org.compiere.util.Msg;
public class VPaymentFormDialog extends CDialog implements ActionListener
{
private PaymentForm paymentForm;
private int windowNo;
private CPanel mainPanel = new CPanel();
private BorderLayout mainLayout = new BorderLayout();
private CPanel centerPanel = new CPanel();
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private boolean initOK = false;
public VPaymentFormDialog(PaymentForm paymentForm, int windowNo)
{
super(AEnv.getWindow(windowNo), Msg.getMsg(Env.getCtx(), "Payment"), true);
this.paymentForm = paymentForm;
this.windowNo = windowNo;
try {
jbInit();
initOK = dynInit(); // Null Pointer if order/invoice not saved yet
} catch (Exception ex) {
ADialog.error(windowNo, this, ex.getMessage());
initOK = false;
}
setPreferredSize(new Dimension(500, 400));
pack();
}
private void jbInit() throws Exception
{
getContentPane().add(mainPanel);
mainPanel.setLayout(mainLayout);
centerPanel.setBorder(BorderFactory.createRaisedBevelBorder());
mainPanel.add(centerPanel, BorderLayout.CENTER);
mainPanel.add(confirmPanel, BorderLayout.SOUTH);
confirmPanel.addActionListener(this);
}
private boolean dynInit() throws Exception
{
boolean isInitOK = paymentForm.dynInit();
centerPanel.setVisible(!paymentForm.isOnlyRule());
return isInitOK;
}
public CPanel getPanel() {
return centerPanel;
}
/**************************************************************************
* Action Listener
* @param e event
*/
public void actionPerformed(ActionEvent e)
{
// Finish
if (e.getActionCommand().equals(ConfirmPanel.A_OK))
{
if (paymentForm.checkMandatory())
{
paymentForm.saveChanges(); // cannot recover
dispose ();
}
}
else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
dispose();
}
public boolean isInitOK()
{
return initOK;
}
}

View File

@ -0,0 +1,11 @@
package org.compiere.grid;
import org.compiere.model.GridTab;
public class VPaymentFormDirectDebit extends VPaymentFormDirectDeposit {
public VPaymentFormDirectDebit(int WindowNo, GridTab mTab) {
super(WindowNo, mTab);
}
}

View File

@ -0,0 +1,125 @@
package org.compiere.grid;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.apps.ADialog;
import org.compiere.model.GridTab;
import org.compiere.swing.CButton;
import org.compiere.swing.CComboBox;
import org.compiere.swing.CLabel;
import org.compiere.swing.CTextField;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
public class VPaymentFormDirectDeposit extends PaymentFormDirectDeposit {
private VPaymentFormDialog dialog;
private CLabel tAccountLabel = new CLabel();
private CComboBox tAccountCombo = new CComboBox();
private CButton tOnline = new CButton();
private CTextField tRoutingField = new CTextField();
private CTextField tNumberField = new CTextField();
private CLabel tStatus = new CLabel();
private CLabel tRoutingText = new CLabel();
private CLabel tNumberText = new CLabel();
public VPaymentFormDirectDeposit(int windowNo, GridTab mTab) {
super(windowNo, mTab);
dialog = new VPaymentFormDialog(this, windowNo);
init();
}
public void init() {
GridBagLayout tPanelLayout = new GridBagLayout();
dialog.getPanel().setLayout(tPanelLayout);
tAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BP_BankAccount_ID"));
tRoutingField.setColumns(8);
tNumberField.setColumns(10);
tRoutingText.setText(Msg.translate(Env.getCtx(), "RoutingNo"));
tNumberText.setText(Msg.translate(Env.getCtx(), "AccountNo"));
tOnline.setText(Msg.getMsg(Env.getCtx(), "Online"));
tStatus.setText(" ");
dialog.getPanel().add(tAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
dialog.getPanel().add(tAccountCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
dialog.getPanel().add(tRoutingField, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
dialog.getPanel().add(tNumberField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
dialog.getPanel().add(tStatus, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
dialog.getPanel().add(tRoutingText, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0));
dialog.getPanel().add(tNumberText, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0));
dialog.getPanel().add(tOnline, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
@Override
public void loadData() {
if (m_C_Payment_ID != 0)
{
tRoutingField.setText(m_mPayment.getRoutingNo());
tNumberField.setText(m_mPayment.getAccountNo());
tStatus.setText(m_mPayment.getR_PnRef());
}
ArrayList<KeyNamePair> list = getBankAccountList();
for (KeyNamePair pp : list)
tAccountCombo.addItem(pp);
}
@Override
public boolean checkMandatory() {
/***********************
* Mandatory Data Check
*/
boolean dataOK = true;
KeyNamePair bpba = (KeyNamePair)tAccountCombo.getSelectedItem();
if (bpba == null)
{
tAccountCombo.setBackground(AdempierePLAF.getFieldBackground_Error());
ADialog.error(getWindowNo(), dialog, "PaymentBPBankNotFound");
dataOK = false;
}
//
log.config("OK=" + dataOK);
return dataOK;
}
@Override
public boolean saveChangesInTrx(String trxName) {
boolean ok = save();
if (!ok)
ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg);
else if (processMsg != null)
ADialog.info(getWindowNo(), dialog, "PaymentCreated", m_mPayment.getDocumentNo());
return true;
}
@Override
public void showWindow()
{
dialog.setVisible(true);
}
@Override
public void closeWindow()
{
dialog.dispose();
}
@Override
public Object getWindow() {
return dialog;
}
}

View File

@ -0,0 +1,63 @@
package org.compiere.grid;
import java.util.HashMap;
import java.util.logging.Level;
import org.compiere.model.GridTab;
import org.compiere.util.CLogger;
public class VPaymentFormFactory {
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (VPaymentFormFactory.class);
private static HashMap<String, Class<? extends IPaymentForm>> s_registeredClasses = null;
/**
* Register custom VPaymentForm* class
* @param ad_table_id
* @param cl custom class
*/
public static final void registerClass(String paymentRule, Class<? extends IPaymentForm> cl)
{
s_registeredClasses.put(paymentRule, cl);
s_log.info("Registered PaymentRule="+paymentRule+", Class="+cl);
}
static
{
// Register defaults:
s_registeredClasses = new HashMap<String, Class<? extends IPaymentForm>>();
s_registeredClasses.put(PaymentFormCash.PAYMENTRULE, VPaymentFormCash.class);
s_registeredClasses.put(PaymentFormCheck.PAYMENTRULE, VPaymentFormCheck.class);
s_registeredClasses.put(PaymentFormCreditCard.PAYMENTRULE, VPaymentFormCreditCard.class);
s_registeredClasses.put(PaymentFormDirectDebit.PAYMENTRULE, VPaymentFormDirectDebit.class);
s_registeredClasses.put(PaymentFormDirectDeposit.PAYMENTRULE, VPaymentFormDirectDeposit.class);
s_registeredClasses.put(PaymentFormMixedPOS.PAYMENTRULE, VPaymentFormMixedPOS.class);
s_registeredClasses.put(PaymentFormOnCredit.PAYMENTRULE, VPaymentFormOnCredit.class);
}
public static IPaymentForm create (int windowNo, GridTab mTab, String paymentRule)
{
IPaymentForm retValue = null;
Class<? extends IPaymentForm> cl = s_registeredClasses.get(paymentRule);
if (cl != null)
{
try
{
java.lang.reflect.Constructor<? extends IPaymentForm> ctor = cl.getConstructor(int.class, GridTab.class);
retValue = ctor.newInstance(windowNo, mTab);
}
catch (Throwable e)
{
s_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
return null;
}
}
if (retValue == null)
{
s_log.info("Unsupported PaymentRule=" + paymentRule);
return null;
}
return retValue;
} // create
}

View File

@ -0,0 +1,43 @@
package org.compiere.grid;
import org.compiere.model.GridTab;
public class VPaymentFormMixedPOS extends PaymentFormMixedPOS {
private VPaymentFormDialog dialog;
public VPaymentFormMixedPOS(int windowNo, GridTab mTab) {
super(windowNo, mTab);
dialog = new VPaymentFormDialog(this, windowNo);
}
@Override
public void loadData() {
}
@Override
public boolean checkMandatory() {
return true;
}
@Override
public boolean saveChangesInTrx(String trxName) {
return true;
}
@Override
public void showWindow()
{
dialog.setVisible(true);
}
@Override
public void closeWindow()
{
dialog.dispose();
}
@Override
public Object getWindow() {
return dialog;
}
}

View File

@ -0,0 +1,80 @@
package org.compiere.grid;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;
import org.compiere.model.GridTab;
import org.compiere.swing.CComboBox;
import org.compiere.swing.CLabel;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
public class VPaymentFormOnCredit extends PaymentFormOnCredit {
private VPaymentFormDialog dialog;
private CLabel pTermLabel = new CLabel();
private CComboBox pTermCombo = new CComboBox();
public VPaymentFormOnCredit(int windowNo, GridTab mTab) {
super(windowNo, mTab);
dialog = new VPaymentFormDialog(this, windowNo);
init();
}
public void init() {
GridBagLayout pPanelLayout = new GridBagLayout();
dialog.getPanel().setLayout(pPanelLayout);
pTermLabel.setText(Msg.translate(Env.getCtx(), "C_PaymentTerm_ID"));
dialog.getPanel().add(pTermLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 2, 0), 0, 0));
dialog.getPanel().add(pTermCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
}
@Override
public void loadData() {
ArrayList<KeyNamePair> list = getPaymentTermList();
for (KeyNamePair pp : list)
pTermCombo.addItem(pp);
// Set Selection
if (selectedPaymentTerm != null)
pTermCombo.setSelectedItem(selectedPaymentTerm);
}
@Override
public boolean checkMandatory() {
return true;
}
@Override
public boolean saveChangesInTrx(String trxName) {
int newC_PaymentTerm_ID = 0;
KeyNamePair kp = (KeyNamePair)pTermCombo.getSelectedItem();
if (kp != null)
newC_PaymentTerm_ID = kp.getKey();
return save(newC_PaymentTerm_ID);
}
@Override
public void showWindow()
{
dialog.setVisible(true);
}
@Override
public void closeWindow()
{
dialog.dispose();
}
@Override
public Object getWindow() {
return dialog;
}
}

View File

@ -0,0 +1,534 @@
package org.compiere.grid.ed;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.util.logging.Level;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComponent;
import org.compiere.grid.IPaymentForm;
import org.compiere.grid.VPaymentFormDialog;
import org.compiere.grid.VPaymentFormFactory;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.MLookup;
import org.compiere.model.MPaymentLookup;
import org.compiere.swing.CButton;
import org.compiere.util.CLogger;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.NamePair;
public class VPaymentEditor extends JComponent implements VEditor, ActionListener, FocusListener {
/** Logger */
private static CLogger log = CLogger.getCLogger(VPaymentEditor.class);
/** Search: The Button to open Editor */
private CButton m_button = new CButton();
/** The Combo Box if not a Search Lookup */
private VComboBox m_combo = new VComboBox();
/** Column Name */
private String m_columnName;
/** Lookup */
private MPaymentLookup m_lookup;
/** The Value */
private Object m_value;
/** Indicator that value is being set */
private volatile boolean m_settingValue = false;
/** Indicator that docus is being set */
private volatile boolean m_settingFocus = false;
/** Indicator that Lookup has focus */
private volatile boolean m_haveFocus = false;
/** Indicator - inserting new value */
private volatile boolean m_inserting = false;
/** Last Display */
private String m_lastDisplay = "";
private boolean m_stopediting = false;
private GridField m_mField;
public VPaymentEditor(GridField gridField, String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, MPaymentLookup lookup) {
super();
m_mField = gridField;
super.setName(columnName);
m_combo.setName(columnName);
m_columnName = columnName;
setMandatory(mandatory);
m_lookup = lookup;
if (m_lookup != null)
m_lookup.setMandatory(mandatory);
//
setLayout(new BorderLayout());
// Button
m_button.addActionListener(this);
m_button.setFocusable(false); // don't focus when tabbing
m_button.setMargin(new Insets(0, 0, 0, 0));
m_button.setIcon(Env.getImageIcon("Payment10.gif"));
// *** VComboBox ***
if (m_lookup != null)
{
// Don't have to fill up combobox if it is readonly
if (!isReadOnly && isUpdateable)
m_lookup.fillComboBox (isMandatory(), true, true, false);
m_combo.setModel(m_lookup);
//
// AutoCompletion.enable(m_combo);
m_combo.addActionListener(this); // Selection
// FocusListener to refresh selection before opening
m_combo.addFocusListener(this);
}
setUI (true);
// ReadWrite - decides what components to show
if (isReadOnly || !isUpdateable || m_lookup == null)
setReadWrite(false);
else
setReadWrite(true);
}
@Override
public void dispose() {
m_button = null;
m_lookup = null;
m_mField = null;
//
m_combo.getEditor().getEditorComponent().removeFocusListener(this);
m_combo.removeFocusListener(this);
m_combo.removeActionListener(this);
m_combo.setModel(new DefaultComboBoxModel()); // remove reference
// m_combo.removeAllItems();
m_combo = null;
}
private void setUI (boolean initial)
{
if (initial)
{
Dimension size = m_combo.getPreferredSize();
setPreferredSize(new Dimension(size)); // causes r/o to be the same length
setMinimumSize(new Dimension (30, size.height));
//
Dimension bSize = new Dimension(size.height, size.height);
m_button.setPreferredSize (bSize);
}
// What to show
this.remove(m_combo);
this.remove(m_button);
//
this.setBorder(null);
this.add(m_combo, BorderLayout.CENTER);
this.add(m_button, BorderLayout.EAST);
}
@Override
public void setReadWrite(boolean value) {
setReadWrite0(value);
GridTab m_mTab = m_mField.getGridTab();
String m_DocStatus = (String) m_mTab.getValue("DocStatus");
// DocStatus
if (m_DocStatus == null)
m_DocStatus = "";
// Is the Trx closed? Reversed / Voided / Cloased
if (m_DocStatus.equals("RE") || m_DocStatus.equals("VO") || m_DocStatus.equals("CL"))
{
m_button.setVisible(false);
return;
}
boolean m_onlyRule = 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;
boolean m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), m_mField.getWindowNo(), "IsSOTrx"));
// PO only Rule
if (!m_onlyRule // Only order has Warehouse
&& !m_isSOTrx && m_mTab.getValue("M_Warehouse_ID") != null)
m_onlyRule = true;
m_button.setVisible(value && !m_onlyRule);
}
private void setReadWrite0(boolean value)
{
boolean rw = value;
if (m_lookup == null)
rw = false;
if (m_combo.isReadWrite() != value)
{
m_combo.setReadWrite(rw);
setUI (false);
if (value) {
m_settingValue = true; // disable actions
refresh();
m_settingValue = false;
}
setValue (m_value);
}
}
@Override
public boolean isReadWrite() {
return m_combo.isReadWrite();
}
@Override
public void setMandatory(boolean mandatory) {
m_combo.setMandatory(mandatory);
}
@Override
public boolean isMandatory() {
return m_combo.isMandatory();
}
@Override
public void setBackground(boolean error) {
m_combo.setBackground(error);
}
@Override
public void requestFocus ()
{
if (m_lookup != null)
m_combo.requestFocus ();
}
@Override
public void setValue(Object value) {
log.fine(m_columnName + "=" + value);
m_settingValue = true; // disable actions
m_value = value;
// Set both for switching
if (value == null)
{
m_combo.setValue (value);
m_lastDisplay = "";
m_settingValue = false;
return;
}
if (m_lookup == null)
{
m_combo.setValue (value);
m_lastDisplay = value.toString();
m_settingValue = false;
return;
}
//must call m_combo.setvalue after m_lookup as
//loading of combo data might happen in m_lookup.getDisplay
m_lastDisplay = m_lookup.getDisplay(value);
m_combo.setValue (value);
if (m_lastDisplay.equals("<-1>"))
{
m_lastDisplay = "";
m_value = null;
}
boolean notFound = m_lastDisplay.startsWith("<") && m_lastDisplay.endsWith(">");
// Nothing showing in Combo and should be showing
if (m_combo.getSelectedItem() == null)
{
// lookup found nothing too
if (notFound)
{
log.finest(m_columnName + "=" + value + ": Not found - " + m_lastDisplay);
// we may have a new value
m_lookup.refresh();
m_combo.setValue (value);
m_lastDisplay = m_lookup.getDisplay(value);
notFound = m_lastDisplay.startsWith("<") && m_lastDisplay.endsWith(">");
}
if (notFound && value instanceof Integer && m_lookup.getDisplayType() != DisplayType.ID) // for IDs is ok to be out of the list
{
m_value = null;
actionCombo (null); // data binding
log.fine(m_columnName + "=" + value + ": Not found");
}
// we have lookup
else if (m_combo.getSelectedItem() == null)
{
NamePair pp = m_lookup.get(value);
if (pp != null)
{
log.fine(m_columnName + " added to combo - " + pp);
// Add to Combo
m_combo.addItem (pp);
m_combo.setValue (value);
}
}
// Not in Lookup - set to Null
if (m_combo.getSelectedItem() == null)
{
if (value instanceof Integer && m_lookup.getDisplayType() != DisplayType.ID) // for IDs is ok to be out of the list
{
log.info(m_columnName + "=" + value + ": not in Lookup - set to NULL");
actionCombo (null); // data binding (calls setValue again)
m_value = null;
}
}
}
m_settingValue = false;
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (m_stopediting)
return;
// log.fine( "VLookup.propertyChange", evt);
if (evt.getPropertyName().equals(GridField.PROPERTY))
{
m_inserting = GridField.INSERTING.equals(evt.getOldValue()); // MField.setValue
setValue(evt.getNewValue());
m_inserting = false;
}
}
@Override
public Object getValue() {
return m_combo.getValue ();
}
@Override
public String getDisplay() {
return m_combo.getDisplay();
}
@Override
public void setField(GridField mField) {
m_mField = mField;
}
@Override
public GridField getField() {
return m_mField;
}
@Override
public void actionPerformed(ActionEvent e) {
if (m_settingValue || m_settingFocus || m_stopediting)
return;
log.config(m_columnName + " - " + e.getActionCommand() + ", ComboValue=" + m_combo.getSelectedItem());
// Combo Selection
if (e.getSource() == m_combo)
{
Object value = getValue();
Object o = m_combo.getSelectedItem();
if (o != null)
{
String s = o.toString();
// don't allow selection of inactive
if (s.startsWith(MLookup.INACTIVE_S) && s.endsWith(MLookup.INACTIVE_E))
{
log.info(m_columnName + " - selection inactive set to NULL");
value = null;
}
}
actionCombo (value); // data binding
}
// Button pressed
else if (e.getSource() == m_button)
actionButton ();
}
@Override
public void addActionListener(ActionListener listener) {
m_combo.addActionListener(listener);
}
private void actionCombo (Object value)
{
log.fine("Value=" + value);
try
{
// -> GridController.vetoableChange
fireVetoableChange (m_columnName, null, value);
}
catch (PropertyVetoException pve)
{
log.log(Level.SEVERE, m_columnName, pve);
}
// is the value updated ?
boolean updated = false;
Object updatedValue = value;
if (updatedValue instanceof Object[] && ((Object[])updatedValue).length > 0)
{
updatedValue = ((Object[])updatedValue)[0];
}
if (updatedValue == null && m_value == null)
updated = true;
else if (updatedValue != null && value.equals(m_value))
updated = true;
if (!updated)
{
// happens if VLookup is used outside of APanel/GridController (no property listener)
log.fine(m_columnName + " - Value explicitly set - new=" + updatedValue + ", old=" + m_value);
// phib: the following check causes the update to fail on jre > 1.6.0_13
// commenting out as it does not appear to be necessary
//if (getListeners(PropertyChangeListener.class).length <= 0)
setValue(updatedValue);
}
} // actionCombo
private void actionButton ()
{
m_button.setEnabled(false); // disable double click
if (m_lookup == null)
return; // leave button disabled
m_combo.requestFocus(); // closes other editors
int windowNo = m_lookup.getWindowNo();
Object newValue = getValue();
if (newValue != null)
{
IPaymentForm pf = VPaymentFormFactory.create(windowNo, getField().getGridTab(), (String) newValue);
if(pf != null)
{
VPaymentFormDialog dialog = (VPaymentFormDialog) pf.getWindow();
if(dialog.isInitOK())
{
dialog.setLocationRelativeTo(null);
pf.showWindow();
pf.closeWindow();
getField().getGridTab().dataRefresh();
}
else
pf.closeWindow();
}
}
m_button.setEnabled(true);
m_combo.requestFocus();
} // actionButton
@Override
public void focusGained (FocusEvent e)
{
if (m_combo == null || m_combo.getEditor() == null)
return;
if ((e.getSource() != m_combo && e.getSource() != m_combo.getEditor().getEditorComponent())
|| e.isTemporary() || m_haveFocus || m_lookup == null)
return;
//avoid repeated query
if (m_lookup.isValidated() && m_lookup.isLoaded())
{
m_haveFocus = true;
return;
}
//
m_haveFocus = true; // prevents calling focus gained twice
m_settingFocus = true; // prevents actionPerformed
//
Object obj = m_lookup.getSelectedItem();
log.config(m_columnName
+ " - Start Count=" + m_combo.getItemCount() + ", Selected=" + obj);
// log.fine( "VLookupHash=" + this.hashCode());
boolean popupVisible = m_combo.isPopupVisible();
m_lookup.fillComboBox(isMandatory(), true, true, false); // only validated & active
if (popupVisible)
{
//refresh
m_combo.hidePopup();
m_combo.showPopup();
}
log.config(m_columnName
+ " - Update Count=" + m_combo.getItemCount() + ", Selected=" + m_lookup.getSelectedItem());
m_lookup.setSelectedItem(obj);
log.config(m_columnName
+ " - Selected Count=" + m_combo.getItemCount() + ", Selected=" + m_lookup.getSelectedItem());
//
m_settingFocus = false;
} // focusGained
@Override
public void focusLost(FocusEvent e)
{
if (e.isTemporary()
|| m_lookup == null
|| !m_button.isEnabled() ) // set by actionButton
return;
// Combo lost focus
if (e.getSource() != m_combo && e.getSource() != m_combo.getEditor().getEditorComponent())
return;
if (m_lookup.isValidated() && !m_lookup.hasInactive())
{
m_haveFocus = false;
return;
}
//
m_settingFocus = true; // prevents actionPerformed
//
log.config(m_columnName + " = " + m_combo.getSelectedItem());
Object obj = m_combo.getSelectedItem();
/*
// set original model
if (!m_lookup.isValidated())
m_lookup.fillComboBox(true); // previous selection
*/
// Set value
if (obj != null)
{
m_combo.setSelectedItem(obj);
// original model may not have item
if (!m_combo.getSelectedItem().equals(obj))
{
log.fine(m_columnName + " - added to combo - " + obj);
m_combo.addItem(obj);
m_combo.setSelectedItem(obj);
}
}
// actionCombo(getValue());
m_settingFocus = false;
m_haveFocus = false; // can gain focus again
} // focusLost
public void setToolTipText(String text)
{
super.setToolTipText(text);
m_button.setToolTipText(text);
m_combo.setToolTipText(text);
}
public int refresh()
{
if (m_lookup == null)
return -1;
//no need to refresh readonly lookup, just remove direct cache
if (!isReadWrite()) {
m_lookup.removeAllElements();
return 0;
}
return m_lookup.refresh();
} // refresh
public void setStopEditing(boolean stopediting) {
m_stopediting = stopediting;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

View File

@ -42,6 +42,7 @@ import org.adempiere.webui.editor.IZoomableEditor;
import org.adempiere.webui.editor.WButtonEditor;
import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WEditorPopupMenu;
import org.adempiere.webui.editor.WPaymentEditor;
import org.adempiere.webui.editor.WebEditorFactory;
import org.adempiere.webui.event.ContextMenuListener;
import org.adempiere.webui.util.GridTabDataBinder;
@ -103,7 +104,7 @@ DataStatusListener, IADTabpanel
private static final long serialVersionUID = -6082680802978974909L;
private static final String ON_DEFER_SET_SELECTED_NODE = "onDeferSetSelectedNode";
private static final CLogger logger;
static
@ -161,6 +162,7 @@ DataStatusListener, IADTabpanel
{
initComponents();
addEventListener(ON_DEFER_SET_SELECTED_NODE, this);
addEventListener(WPaymentEditor.ON_SAVE_PAYMENT, this);
}
private void initComponents()
@ -854,7 +856,7 @@ DataStatusListener, IADTabpanel
{
Events.sendEvent(this, new Event(ON_TOGGLE_EVENT, this));
}
else if (event.getTarget() == treePanel.getTree()) {
else if (treePanel != null && event.getTarget() == treePanel.getTree()) {
Treeitem item = treePanel.getTree().getSelectedItem();
navigateTo((DefaultTreeNode)item.getValue());
}
@ -862,7 +864,10 @@ DataStatusListener, IADTabpanel
if (gridTab.getRecord_ID() > 0 && gridTab.isTreeTab() && treePanel != null) {
setSelectedNode(gridTab.getRecord_ID());
}
}
}
else if (WPaymentEditor.ON_SAVE_PAYMENT.equals(event.getName())) {
windowPanel.onSavePayment();
}
}
private void navigateTo(DefaultTreeNode value) {

View File

@ -87,7 +87,6 @@ import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.compiere.util.WebDoc;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
@ -1589,6 +1588,18 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
}
});
}
public void onSavePayment()
{
onSave(false, false, new Callback<Boolean>() {
@Override
public void onCallback(Boolean result) {
onRefresh(false, false);
}
});
}
/**
* @param onSaveEvent

View File

@ -0,0 +1,244 @@
package org.adempiere.webui.apps.form;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Enumeration;
import org.adempiere.webui.component.Column;
import org.adempiere.webui.component.Columns;
import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.GridFactory;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.ListboxFactory;
import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows;
import org.adempiere.webui.editor.WDateEditor;
import org.adempiere.webui.editor.WNumberEditor;
import org.adempiere.webui.window.FDialog;
import org.compiere.grid.PaymentFormCash;
import org.compiere.model.GridTab;
import org.compiere.model.MConversionRate;
import org.compiere.model.MInvoice;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
public class WPaymentFormCash extends PaymentFormCash implements EventListener<Event> {
private WPaymentFormWindow window;
private Label bBankAccountLabel = new Label();
private Listbox bBankAccountCombo = ListboxFactory.newDropdownListbox();
private Label bCashBookLabel = new Label();
private Listbox bCashBookCombo = ListboxFactory.newDropdownListbox();
private Label bCurrencyLabel = new Label();
private Listbox bCurrencyCombo = ListboxFactory.newDropdownListbox();
private Label bDateLabel = new Label();
private WDateEditor bDateField;
private Label bAmountLabel = new Label();
private WNumberEditor bAmountField = new WNumberEditor();
public WPaymentFormCash(int windowNo, GridTab mTab) {
super(windowNo, mTab);
bDateField = new WDateEditor("DateAcct", false, false, true, "DateAcct");
window = new WPaymentFormWindow(this, windowNo);
init();
//Bojana&Daniel
//If Invoice is Vendor invoice then Cash has to be created by negative amount
int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "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;
}
public void init() {
Grid bPanelLayout = GridFactory.newGridLayout();
window.getPanel().appendChild(bPanelLayout);
bCashBookLabel.setText(Msg.translate(Env.getCtx(), "C_CashBook_ID"));
bCurrencyLabel.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
bAmountLabel.setText(Msg.getMsg(Env.getCtx(), "Amount"));
//bAmountField.setText("");
bDateLabel.setText(Msg.translate(Env.getCtx(), "DateAcct"));
window.getPanel().setId("bPanel");
Columns columns = new Columns();
bPanelLayout.appendChild(columns);
Column column = new Column();
columns.appendChild(column);
column.setWidth("40%");
column = new Column();
columns.appendChild(column);
column.setWidth("60%");
bAmountField.getComponent().setWidth("150px");
Rows rows = bPanelLayout.newRows();
Row row = rows.newRow();
if (m_Cash_As_Payment) {
bBankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
row.appendChild(bBankAccountLabel.rightAlign());
row.appendChild(bBankAccountCombo);
} else {
row.appendChild(bCashBookLabel.rightAlign());
row.appendChild(bCashBookCombo);
}
row = rows.newRow();
row.appendChild(bCurrencyLabel.rightAlign());
row.appendChild(bCurrencyCombo);
row = rows.newRow();
row.appendChild(bDateLabel.rightAlign());
row.appendChild(bDateField.getComponent());
row = rows.newRow();
row.appendChild(bAmountLabel.rightAlign());
row.appendChild(bAmountField.getComponent());
}
@Override
public void loadData() {
bAmountField.setValue(m_Amount);
if (m_C_Payment_ID != 0)
bAmountField.setValue(m_mPayment.getPayAmt());
// Existing Cashbook entry
if (m_C_CashLine_ID != 0)
bAmountField.setValue(m_cashLine.getAmount());
// Accounting Date
bDateField.setValue(m_DateAcct);
// 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));
}
bCurrencyCombo.addActionListener(this);
bCurrencyCombo.setSelectedKeyNamePair(s_Currencies.get(C_Currency_ID));
}
else // No EMU Currency
{
bCurrencyLabel.setVisible(false); // Cash
bCurrencyCombo.setVisible(false);
}
ArrayList<KeyNamePair> list = getBankAccountList();
for (KeyNamePair pp : list)
bBankAccountCombo.addItem(pp);
// Set Selection
if (selectedBankAccount != null)
bBankAccountCombo.setSelectedKeyNamePair(selectedBankAccount);
list = getCashBookList();
for (KeyNamePair pp : list)
bCashBookCombo.addItem(pp);
// Set Selection
if (selectedCashBook != null)
bCashBookCombo.setSelectedKeyNamePair(selectedCashBook);
}
public void onEvent(Event e)
{
if (e.getTarget() == bCurrencyCombo)
{
KeyNamePair pp = bCurrencyCombo.getSelectedItem().toKeyNamePair();
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);
}
}
@Override
public boolean checkMandatory() {
int C_BankAccount_ID = 0;
/***********************
* Mandatory Data Check
*/
boolean dataOK = true;
if (m_Cash_As_Payment)
{
ListItem selected = bBankAccountCombo.getSelectedItem();
KeyNamePair kp = selected != null ? selected.toKeyNamePair() : null;
if (kp != null)
C_BankAccount_ID = kp.getKey();
}
// find Bank Account if not qualified yet
if (m_Cash_As_Payment && C_BankAccount_ID == 0)
{
// Check & Cash (Payment) must have a bank account
if (C_BankAccount_ID == 0 && m_Cash_As_Payment)
{
FDialog.error(getWindowNo(), window, "FillMandatory", bBankAccountLabel.getValue());
dataOK = false;
}
}
return dataOK;
}
@Override
public boolean saveChangesInTrx(final String trxName) {
int newC_CashBook_ID = m_C_CashBook_ID;
int newC_BankAccount_ID = 0;
if (m_Cash_As_Payment){
// get bank account
ListItem selected = bBankAccountCombo.getSelectedItem();
KeyNamePair kp = selected != null ? selected.toKeyNamePair() : null;
if (kp != null)
newC_BankAccount_ID = kp.getKey();
} else {
// get cash book
ListItem selected = bCashBookCombo.getSelectedItem();
KeyNamePair kp = selected != null ? selected.toKeyNamePair() : null;
if (kp != null)
newC_CashBook_ID = kp.getKey();
}
Timestamp newDateAcct = (Timestamp)bDateField.getValue();
boolean ok = save(newC_BankAccount_ID,newC_CashBook_ID, newDateAcct, (BigDecimal) bAmountField.getValue(), trxName);
if (!ok)
FDialog.error(getWindowNo(), window, "PaymentError", processMsg);
else if (processMsg != null)
FDialog.info(getWindowNo(), window, "PaymentCreated", processMsg);
return true;
}
@Override
public void showWindow() {
window.setVisible(true);
}
@Override
public void closeWindow() {
window.dispose();
}
@Override
public Object getWindow() {
return window;
}
}

View File

@ -0,0 +1,260 @@
package org.adempiere.webui.apps.form;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Enumeration;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Column;
import org.adempiere.webui.component.Columns;
import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.GridFactory;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.ListboxFactory;
import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.editor.WNumberEditor;
import org.adempiere.webui.window.FDialog;
import org.compiere.grid.PaymentFormCheck;
import org.compiere.model.GridTab;
import org.compiere.model.MConversionRate;
import org.compiere.model.MPaymentValidate;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Cell;
import org.zkoss.zul.Space;
public class WPaymentFormCheck extends PaymentFormCheck implements EventListener<Event> {
private WPaymentFormWindow window;
private Label sBankAccountLabel = new Label();
private Listbox sBankAccountCombo = ListboxFactory.newDropdownListbox();
private Label sCurrencyLabel = new Label();
private Listbox sCurrencyCombo = ListboxFactory.newDropdownListbox();
private Label sAmountLabel = new Label();
private WNumberEditor sAmountField = new WNumberEditor();
private Label sRoutingLabel = new Label();
private Textbox sRoutingField = new Textbox();
private Label sNumberLabel = new Label();
private Textbox sNumberField = new Textbox();
private Textbox sCheckField = new Textbox();
private Label sCheckLabel = new Label();
private Button sOnline = new Button();
private Label sStatus = new Label();
public WPaymentFormCheck(int windowNo, GridTab mTab) {
super(windowNo, mTab);
window = new WPaymentFormWindow(this, windowNo);
init();
}
public void init() {
Grid sPanelLayout = GridFactory.newGridLayout();
window.getPanel().appendChild(sPanelLayout);
sBankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
sAmountLabel.setText(Msg.getMsg(Env.getCtx(), "Amount"));
sRoutingLabel.setText(Msg.translate(Env.getCtx(), "RoutingNo"));
sNumberLabel.setText(Msg.translate(Env.getCtx(), "AccountNo"));
sCheckLabel.setText(Msg.translate(Env.getCtx(), "CheckNo"));
sCheckField.setCols(8);
sCurrencyLabel.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
sNumberField.setWidth("100pt");
sRoutingField.setWidth("70pt");
sStatus.setText(" ");
sOnline.setLabel(Msg.getMsg(Env.getCtx(), "Online"));
LayoutUtils.addSclass("action-text-button", sOnline);
// sOnline.addActionListener(this);
window.getPanel().setId("sPanel");
Columns columns = new Columns();
sPanelLayout.appendChild(columns);
Column column = new Column();
columns.appendChild(column);
column.setWidth("30%");
column = new Column();
columns.appendChild(column);
column.setWidth("50%");
column = new Column();
columns.appendChild(column);
column.setWidth("20%");
sAmountField.getComponent().setWidth("150px");
Rows rows = sPanelLayout.newRows();
Row row = rows.newRow();
row.appendChild(sBankAccountLabel.rightAlign());
row.appendChild(sBankAccountCombo);
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(sCurrencyLabel.rightAlign());
row.appendChild(sCurrencyCombo);
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(sAmountLabel.rightAlign());
row.appendChild(sAmountField.getComponent());
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(sRoutingLabel.rightAlign());
row.appendChild(sRoutingField);
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(sNumberLabel.rightAlign());
row.appendChild(sNumberField);
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(sCheckLabel.rightAlign());
row.appendChild(sCheckField);
row.appendChild(sOnline);
row = rows.newRow();
Cell cell = new Cell();
row.appendChild(cell);
cell.appendChild(sStatus);
cell.setColspan(3);
}
@Override
public void loadData() {
sAmountField.setValue(m_Amount);
if (m_C_Payment_ID != 0)
{
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());
}
// 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();
sCurrencyCombo.addItem(s_Currencies.get(key));
}
sCurrencyCombo.addActionListener(this);
sCurrencyCombo.setSelectedKeyNamePair(s_Currencies.get(C_Currency_ID));
}
else // No EMU Currency
{
sCurrencyLabel.setVisible(false); // Check
sCurrencyCombo.setVisible(false);
}
ArrayList<KeyNamePair> list = getBankAccountList();
for (KeyNamePair pp : list)
sBankAccountCombo.addItem(pp);
// Set Selection
if (selectedBankAccount != null)
sBankAccountCombo.setSelectedKeyNamePair(selectedBankAccount);
}
public void onEvent(Event e)
{
if (e.getTarget() == sCurrencyCombo)
{
KeyNamePair pp = sCurrencyCombo.getSelectedItem().toKeyNamePair();
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 if (e.getTarget() == sOnline) {
// window.lockUI();
// Clients.response(new AuEcho(window, "runProcessOnline", null));
// }
}
@Override
public boolean checkMandatory() {
int C_BankAccount_ID = 0;
/***********************
* Mandatory Data Check
*/
boolean dataOK = true;
ListItem selected = sBankAccountCombo.getSelectedItem();
KeyNamePair kp = selected != null ? selected.toKeyNamePair() : null;
if (kp != null)
C_BankAccount_ID = kp.getKey();
String error = MPaymentValidate.validateRoutingNo(sRoutingField.getText());
if (error.length() != 0)
{
FDialog.error(getWindowNo(), window, error);
dataOK = false;
}
error = MPaymentValidate.validateAccountNo(sNumberField.getText());
if (error.length() != 0)
{
FDialog.error(getWindowNo(), window, error);
dataOK = false;
}
error = MPaymentValidate.validateCheckNo(sCheckField.getText());
if (error.length() != 0)
{
FDialog.error(getWindowNo(), window, error);
dataOK = false;
}
// Check & Cash (Payment) must have a bank account
if (C_BankAccount_ID == 0)
{
FDialog.error(getWindowNo(), window, "FillMandatory", sBankAccountLabel.getValue());
dataOK = false;
}
//
log.config("OK=" + dataOK);
return dataOK;
}
@Override
public boolean saveChangesInTrx(final String trxName) {
int newC_BankAccount_ID = 0;
ListItem selected = sBankAccountCombo.getSelectedItem();
KeyNamePair kp = selected != null ? selected.toKeyNamePair() : null;
if (kp != null)
newC_BankAccount_ID = kp.getKey();
boolean ok = save(newC_BankAccount_ID, sRoutingField.getText(), sNumberField.getText(), sCheckField.getText(), (BigDecimal) sAmountField.getValue());
if (!ok)
FDialog.error(getWindowNo(), window, "PaymentError", processMsg);
else if (processMsg != null)
FDialog.info(getWindowNo(), window, "PaymentCreated", m_mPayment.getDocumentNo());
return true;
}
@Override
public void showWindow() {
window.setVisible(true);
}
@Override
public void closeWindow() {
window.dispose();
}
@Override
public Object getWindow() {
return window;
}
}

View File

@ -0,0 +1,222 @@
package org.adempiere.webui.apps.form;
import java.math.BigDecimal;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Column;
import org.adempiere.webui.component.Columns;
import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.GridFactory;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.ListboxFactory;
import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.editor.WNumberEditor;
import org.adempiere.webui.window.FDialog;
import org.compiere.grid.PaymentFormCreditCard;
import org.compiere.model.GridTab;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.ValueNamePair;
import org.zkoss.zk.au.out.AuEcho;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Space;
public class WPaymentFormCreditCard extends PaymentFormCreditCard implements EventListener<Event> {
private WPaymentFormWindow window;
private Label kTypeLabel = new Label();
private Listbox kTypeCombo = ListboxFactory.newDropdownListbox();
private Label kNumberLabel = new Label();
private Textbox kNumberField = new Textbox();
private Label kExpLabel = new Label();
private Textbox kExpField = new Textbox();
private Label kAmountLabel = new Label();
private WNumberEditor kAmountField = new WNumberEditor();
private Label kApprovalLabel = new Label();
private Textbox kApprovalField = new Textbox();
private Button kOnline = new Button();
private Label kStatus = new Label();
public WPaymentFormCreditCard(int windowNo, GridTab mTab) {
super(windowNo, mTab);
window = new WPaymentFormWindow(this, windowNo);
init();
}
public void init() {
Grid kLayout = GridFactory.newGridLayout();
window.getPanel().appendChild(kLayout);
kNumberField.setCols(16);
kExpField.setCols(4);
kApprovalField.setCols(4);
kTypeLabel.setText(Msg.translate(Env.getCtx(), "CreditCardType"));
kNumberLabel.setText(Msg.translate(Env.getCtx(), "CreditCardNumber"));
kExpLabel.setText(Msg.getMsg(Env.getCtx(), "Expires"));
kApprovalLabel.setText(Msg.translate(Env.getCtx(), "VoiceAuthCode"));
kAmountLabel.setText(Msg.getMsg(Env.getCtx(), "Amount"));
kOnline.setLabel(Msg.getMsg(Env.getCtx(), "Online"));
LayoutUtils.addSclass("action-text-button", kOnline);
kOnline.addActionListener(this);
kStatus.setText(" ");
window.getPanel().setId("kPanel");
Columns columns = new Columns();
kLayout.appendChild(columns);
Column column = new Column();
columns.appendChild(column);
column.setWidth("30%");
column = new Column();
columns.appendChild(column);
column.setWidth("50%");
column = new Column();
columns.appendChild(column);
column.setWidth("20%");
kAmountField.getComponent().setWidth("150px");
Rows rows = kLayout.newRows();
Row row = rows.newRow();
row.appendChild(kTypeLabel.rightAlign());
row.appendChild(kTypeCombo);
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(kNumberLabel.rightAlign());
row.appendChild(kNumberField);
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(kExpLabel.rightAlign());
row.appendChild(kExpField);
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(kAmountLabel.rightAlign());
row.appendChild(kAmountField.getComponent());
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(kApprovalLabel.rightAlign());
row.appendChild(kApprovalField);
row.appendChild(kOnline);
row = rows.newRow();
row.appendCellChild(kStatus, 3);
}
@Override
public void loadData() {
kAmountField.setValue(m_Amount);
if (m_C_Payment_ID != 0)
{
kNumberField.setText(m_mPayment.getCreditCardNumber());
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.setEnabled(!m_mPayment.isApproved());
kNumberField.setReadonly(m_mPayment.isApproved());
kExpField.setReadonly(m_mPayment.isApproved());
kApprovalField.setReadonly(m_mPayment.isApproved());
kOnline.setEnabled(!m_mPayment.isApproved());
kAmountField.setReadWrite(!m_mPayment.isApproved());
}
/**
* Load Credit Cards
*/
ValueNamePair[] ccs = getCreditCardList();
for (int i = 0; i < ccs.length; i++)
kTypeCombo.addItem(ccs[i]);
// Set Selection
if (selectedCreditCard != null)
kTypeCombo.setSelectedValueNamePair(selectedCreditCard);
}
public void onEvent(Event e)
{
if (e.getTarget() == kOnline) {
window.lockUI();
Clients.response(new AuEcho(window, "runProcessOnline", null));
}
}
public void runProcessOnline() {
try {
processOnline();
} finally {
window.unlockUI();
}
}
@Override
public boolean checkMandatory() {
return true;
}
@Override
public boolean saveChangesInTrx(final String trxName) {
String newCCType = m_CCType;
ListItem selected = kTypeCombo.getSelectedItem();
ValueNamePair vp = selected != null ? selected.toValueNamePair() : null;
if (vp != null)
newCCType = vp.getValue();
boolean ok = save(newCCType, kNumberField.getText(), kExpField.getText(), (BigDecimal) kAmountField.getValue());
if(!ok)
FDialog.error(getWindowNo(), window, "PaymentError", processMsg);
else if (processMsg != null)
FDialog.info(getWindowNo(), window, "PaymentCreated", processMsg);
return true;
}
/**************************************************************************
* Process Online (sales only) - if approved - exit
*/
private void processOnline()
{
log.config("");
if (!checkMandatory())
return;
ValueNamePair vp = kTypeCombo.getSelectedItem().toValueNamePair();
String CCType = vp.getValue();
boolean ok = processOnline(CCType, kNumberField.getText(), kExpField.getText());
if (!ok)
FDialog.error(getWindowNo(), window, "PaymentError", processMsg);
else if (processMsg != null)
FDialog.info(getWindowNo(), window, "PaymentProcessed", processMsg);
} // online
@Override
public void showWindow() {
window.setVisible(true);
}
@Override
public void closeWindow() {
window.dispose();
}
@Override
public Object getWindow() {
return window;
}
}

View File

@ -0,0 +1,10 @@
package org.adempiere.webui.apps.form;
import org.compiere.model.GridTab;
public class WPaymentFormDirectDebit extends WPaymentFormDirectDeposit {
public WPaymentFormDirectDebit(int windowNo, GridTab mTab) {
super(windowNo, mTab);
}
}

View File

@ -0,0 +1,150 @@
package org.adempiere.webui.apps.form;
import java.util.ArrayList;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Column;
import org.adempiere.webui.component.Columns;
import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.GridFactory;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.ListboxFactory;
import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.window.FDialog;
import org.compiere.grid.PaymentFormDirectDeposit;
import org.compiere.model.GridTab;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.zkoss.zul.Space;
public class WPaymentFormDirectDeposit extends PaymentFormDirectDeposit {
private WPaymentFormWindow window;
private Label tAccountLabel = new Label();
private Listbox tAccountCombo = ListboxFactory.newDropdownListbox();
private Button tOnline = new Button();
private Textbox tRoutingField = new Textbox();
private Textbox tNumberField = new Textbox();
private Label tStatus = new Label();
private Label tRoutingText = new Label();
private Label tNumberText = new Label();
public WPaymentFormDirectDeposit(int windowNo, GridTab mTab) {
super(windowNo, mTab);
window = new WPaymentFormWindow(this, windowNo);
init();
}
public void init() {
Grid tPanelLayout = GridFactory.newGridLayout();
window.getPanel().appendChild(tPanelLayout);
tAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BP_BankAccount_ID"));
tRoutingField.setCols(8);
tNumberField.setCols(10);
tRoutingText.setText(Msg.translate(Env.getCtx(), "RoutingNo"));
tNumberText.setText(Msg.translate(Env.getCtx(), "AccountNo"));
tOnline.setLabel(Msg.getMsg(Env.getCtx(), "Online"));
LayoutUtils.addSclass("action-text-button", tOnline);
tStatus.setText(" ");
window.getPanel().setId("tPanel");
Columns columns = new Columns();
tPanelLayout.appendChild(columns);
Column column = new Column();
columns.appendChild(column);
column.setWidth("30%");
column = new Column();
columns.appendChild(column);
column.setWidth("50%");
column = new Column();
columns.appendChild(column);
column.setWidth("20%");
Rows rows = tPanelLayout.newRows();
Row row = rows.newRow();
row.appendChild(tAccountLabel.rightAlign());
row.appendChild(tAccountCombo);
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(tRoutingText.rightAlign());
row.appendChild(tRoutingField);
row.appendChild(new Space());
row = rows.newRow();
row.appendChild(tNumberText.rightAlign());
row.appendChild(tNumberField);
row.appendChild(tOnline);
row = rows.newRow();
row.appendCellChild(tStatus, 3);
}
@Override
public void loadData() {
if (m_C_Payment_ID != 0)
{
tRoutingField.setText(m_mPayment.getRoutingNo());
tNumberField.setText(m_mPayment.getAccountNo());
tStatus.setText(m_mPayment.getR_PnRef());
}
ArrayList<KeyNamePair> list = getBankAccountList();
for (KeyNamePair pp : list)
tAccountCombo.addItem(pp);
}
@Override
public boolean checkMandatory() {
/***********************
* Mandatory Data Check
*/
boolean dataOK = true;
ListItem selected = tAccountCombo.getSelectedItem();
KeyNamePair bpba = selected != null ? selected.toKeyNamePair() : null;
if (bpba == null)
{
FDialog.error(getWindowNo(), window, "PaymentBPBankNotFound");
dataOK = false;
}
//
log.config("OK=" + dataOK);
return dataOK;
}
@Override
public boolean saveChangesInTrx(final String trxName) {
boolean ok = save();
if (!ok)
FDialog.error(getWindowNo(), window, "PaymentError", processMsg);
else if (processMsg != null)
FDialog.info(getWindowNo(), window, "PaymentCreated", m_mPayment.getDocumentNo());
return true;
}
@Override
public void showWindow() {
window.setVisible(true);
}
@Override
public void closeWindow() {
window.dispose();
}
@Override
public Object getWindow() {
return window;
}
}

View File

@ -0,0 +1,72 @@
package org.adempiere.webui.apps.form;
import java.util.HashMap;
import java.util.logging.Level;
import org.compiere.grid.IPaymentForm;
import org.compiere.grid.PaymentFormCash;
import org.compiere.grid.PaymentFormCheck;
import org.compiere.grid.PaymentFormCreditCard;
import org.compiere.grid.PaymentFormDirectDebit;
import org.compiere.grid.PaymentFormDirectDeposit;
import org.compiere.grid.PaymentFormMixedPOS;
import org.compiere.grid.PaymentFormOnCredit;
import org.compiere.model.GridTab;
import org.compiere.util.CLogger;
public class WPaymentFormFactory {
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (WPaymentFormFactory.class);
private static HashMap<String, Class<? extends IPaymentForm>> s_registeredClasses = null;
/**
* Register custom WPaymentForm* class
* @param ad_table_id
* @param cl custom class
*/
public static final void registerClass(String paymentRule, Class<? extends IPaymentForm> cl)
{
s_registeredClasses.put(paymentRule, cl);
s_log.info("Registered PaymentRule="+paymentRule+", Class="+cl);
}
static
{
// Register defaults:
s_registeredClasses = new HashMap<String, Class<? extends IPaymentForm>>();
s_registeredClasses.put(PaymentFormCash.PAYMENTRULE, WPaymentFormCash.class);
s_registeredClasses.put(PaymentFormCheck.PAYMENTRULE, WPaymentFormCheck.class);
s_registeredClasses.put(PaymentFormCreditCard.PAYMENTRULE, WPaymentFormCreditCard.class);
s_registeredClasses.put(PaymentFormDirectDebit.PAYMENTRULE, WPaymentFormDirectDebit.class);
s_registeredClasses.put(PaymentFormDirectDeposit.PAYMENTRULE, WPaymentFormDirectDeposit.class);
s_registeredClasses.put(PaymentFormMixedPOS.PAYMENTRULE, WPaymentFormMixedPOS.class);
s_registeredClasses.put(PaymentFormOnCredit.PAYMENTRULE, WPaymentFormOnCredit.class);
}
public static IPaymentForm create(int windowNo, GridTab mTab, String paymentRule)
{
IPaymentForm retValue = null;
Class<? extends IPaymentForm> cl = s_registeredClasses.get(paymentRule);
if (cl != null)
{
try
{
java.lang.reflect.Constructor<? extends IPaymentForm> ctor = cl.getConstructor(int.class, GridTab.class);
retValue = ctor.newInstance(windowNo, mTab);
}
catch (Throwable e)
{
s_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
return null;
}
}
if (retValue == null)
{
s_log.info("Unsupported PaymentRule=" + paymentRule);
return null;
}
return retValue;
} // create
}

View File

@ -0,0 +1,43 @@
package org.adempiere.webui.apps.form;
import org.compiere.grid.PaymentFormMixedPOS;
import org.compiere.model.GridTab;
public class WPaymentFormMixedPOS extends PaymentFormMixedPOS {
private WPaymentFormWindow window;
public WPaymentFormMixedPOS(int windowNo, GridTab mTab) {
super(windowNo, mTab);
window = new WPaymentFormWindow(this, windowNo);
}
@Override
public void loadData() {
}
@Override
public boolean checkMandatory() {
return true;
}
@Override
public boolean saveChangesInTrx(final String trxName) {
return true;
}
@Override
public void showWindow() {
window.setVisible(true);
}
@Override
public void closeWindow() {
window.dispose();
}
@Override
public Object getWindow() {
return window;
}
}

View File

@ -0,0 +1,98 @@
package org.adempiere.webui.apps.form;
import java.util.ArrayList;
import org.adempiere.webui.component.Column;
import org.adempiere.webui.component.Columns;
import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.GridFactory;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.ListboxFactory;
import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows;
import org.compiere.grid.PaymentFormOnCredit;
import org.compiere.model.GridTab;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
public class WPaymentFormOnCredit extends PaymentFormOnCredit {
private WPaymentFormWindow window;
private Label pTermLabel = new Label();
private Listbox pTermCombo = ListboxFactory.newDropdownListbox();
public WPaymentFormOnCredit(int windowNo, GridTab mTab) {
super(windowNo, mTab);
window = new WPaymentFormWindow(this, windowNo);
init();
}
public void init() {
Grid pPanelLayout = GridFactory.newGridLayout();
window.getPanel().appendChild(pPanelLayout);
pTermLabel.setText(Msg.translate(Env.getCtx(), "C_PaymentTerm_ID"));
window.getPanel().setId("pPanel");
Columns columns = new Columns();
pPanelLayout.appendChild(columns);
Column column = new Column();
columns.appendChild(column);
column.setWidth("40%");
column = new Column();
columns.appendChild(column);
column.setWidth("60%");
Rows rows = pPanelLayout.newRows();
Row row = rows.newRow();
row.appendChild(pTermLabel.rightAlign());
row.appendChild(pTermCombo);
}
@Override
public void loadData() {
ArrayList<KeyNamePair> list = getPaymentTermList();
for (KeyNamePair pp : list)
pTermCombo.addItem(pp);
// Set Selection
if (selectedPaymentTerm != null)
pTermCombo.setSelectedKeyNamePair(selectedPaymentTerm);
}
@Override
public boolean checkMandatory() {
return true;
}
@Override
public boolean saveChangesInTrx(final String trxName) {
int newC_PaymentTerm_ID = 0;
ListItem selected = pTermCombo.getSelectedItem();
KeyNamePair kp = selected != null ? selected.toKeyNamePair() : null;
if (kp != null)
newC_PaymentTerm_ID = kp.getKey();
return save(newC_PaymentTerm_ID);
}
@Override
public void showWindow() {
window.setVisible(true);
}
@Override
public void closeWindow() {
window.dispose();
}
@Override
public Object getWindow() {
return window;
}
}

View File

@ -0,0 +1,136 @@
package org.adempiere.webui.apps.form;
import org.adempiere.webui.apps.BusyDialog;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.window.FDialog;
import org.compiere.grid.PaymentForm;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.South;
public class WPaymentFormWindow extends Window implements EventListener<Event>, DialogEvents {
private PaymentForm paymentForm;
private int windowNo;
private Panel mainPanel = new Panel();
private Panel centerPanel = new Panel();
private Borderlayout mainLayout = new Borderlayout();
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private boolean m_isLocked = false;
private boolean initOK = false;
private BusyDialog progressWindow;
public WPaymentFormWindow(PaymentForm paymentForm, int windowNo)
{
super();
this.paymentForm = paymentForm;
this.windowNo = windowNo;
try {
zkInit();
initOK = dynInit(); // Null Pointer if order/invoice not saved yet
} catch (Exception ex) {
FDialog.error(windowNo, this, ex.getMessage());
initOK = false;
}
this.setTitle(Msg.getMsg(Env.getCtx(), "Payment"));
this.setHeight("400px");
this.setWidth("500px");
this.setBorder("normal");
}
private void zkInit() throws Exception {
this.appendChild(mainPanel);
mainPanel.appendChild(mainLayout);
mainPanel.setStyle("width: 100%; height: 100%; padding: 0; margin: 0");
mainLayout.setHeight("100%");
mainLayout.setWidth("100%");
Center center = new Center();
mainLayout.appendChild(center);
center.appendChild(centerPanel = getPanel());
//
South south = new South();
south.setStyle("border: none");
mainLayout.appendChild(south);
south.appendChild(confirmPanel);
confirmPanel.addActionListener(this);
}
private boolean dynInit() throws Exception {
boolean isInitOK = paymentForm.dynInit();
centerPanel.setVisible(!paymentForm.isOnlyRule());
return isInitOK;
}
public Panel getPanel() {
return centerPanel;
}
/**************************************************************************
* Action Listener
*
* @param e
* event
*/
public void onEvent(Event e) {
// Finish
if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) {
if (paymentForm.checkMandatory()) {
paymentForm.saveChanges(); // cannot recover
dispose();
}
} else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
dispose();
} // actionPerformed
public void unlockUI() {
if (!m_isLocked) return;
m_isLocked = false;
hideBusyDialog();
updateUI();
}
public void lockUI() {
if (m_isLocked) return;
m_isLocked = true;
showBusyDialog();
}
private void hideBusyDialog() {
if (progressWindow != null) {
progressWindow.dispose();
progressWindow = null;
}
}
private void updateUI() {
if (paymentForm.isApproved())
dispose();
}
private void showBusyDialog() {
progressWindow = new BusyDialog();
progressWindow.setPage(this.getPage());
progressWindow.doHighlighted();
}
public boolean isInitOK()
{
return initOK;
}
}

View File

@ -0,0 +1,92 @@
package org.adempiere.webui.component;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import org.adempiere.webui.LayoutUtils;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hlayout;
public class Paymentbox extends Div {
protected PropertyChangeSupport m_propertyChangeListeners = new PropertyChangeSupport(this);
protected Combobox combo;
protected Button btn;
public Paymentbox() {
initComponents();
}
public Paymentbox(Comboitem comboitem) {
initComponents();
setSelectedComboItem(comboitem);
}
public void setButtonImage(String imageSrc) {
btn.setImage(imageSrc);
}
private void initComponents() {
Hlayout hlayout = new Hlayout();
this.appendChild(hlayout);
hlayout.setHflex("1");
combo = new Combobox();
hlayout.appendChild(combo);
combo.setHflex("1");
btn = new Button();
btn.setTabindex(-1);
btn.setSclass("editor-button");
btn.setHflex("0");
hlayout.appendChild(btn);
LayoutUtils.addSclass("editor-box", this);
}
public Combobox getCombobox() {
return combo;
}
public void setSelectedComboItem(Comboitem comboitem) {
combo.setSelectedItem(comboitem);
}
public Comboitem getSelectedComboItem() {
return combo.getSelectedItem();
}
public void setEnabled(boolean isComboEnabled, boolean isBtnEnabled) {
combo.setReadonly(!isComboEnabled);
btn.setEnabled(isBtnEnabled);
btn.setVisible(isBtnEnabled);
if (isBtnEnabled) {
btn.setSclass("editor-button");
btn.setParent(this.getFirstChild());
} else {
btn.detach();
}
}
public boolean isEnabled() {
return !combo.isReadonly();
}
public boolean addEventListener(String evtnm, EventListener listener) {
if (Events.ON_CLICK.equals(evtnm)) {
return btn.addEventListener(evtnm, listener);
} else {
return combo.addEventListener(evtnm, listener);
}
}
public synchronized void addPropertyChangeListener(PropertyChangeListener l) {
m_propertyChangeListeners.addPropertyChangeListener(l);
}
public Button getButton() {
return btn;
}
}

View File

@ -0,0 +1,338 @@
package org.adempiere.webui.editor;
import javax.swing.event.ListDataListener;
import org.adempiere.webui.adwindow.ADTabpanel;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.apps.form.WPaymentFormFactory;
import org.adempiere.webui.apps.form.WPaymentFormWindow;
import org.adempiere.webui.component.Paymentbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent;
import org.compiere.grid.IPaymentForm;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.MPaymentLookup;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.NamePair;
import org.compiere.util.ValueNamePair;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Comboitem;
public class WPaymentEditor extends WEditor implements ListDataListener {
public final static String ON_SAVE_PAYMENT = "onSavePayment";
public final static String[] LISTENER_EVENTS = {Events.ON_SELECT};
private MPaymentLookup lookup;
private Object oldValue;
public WPaymentEditor(GridField gridField) {
super(new Paymentbox(), gridField);
lookup = (MPaymentLookup) gridField.getLookup();
init();
}
private void init()
{
getComponent().getCombobox().setAutocomplete(true);
getComponent().getCombobox().setAutodrop(true);
getComponent().getCombobox().addEventListener(Events.ON_BLUR, this);
getComponent().setButtonImage("/images/Payment10.png");
getComponent().getButton().addActionListener(this);
if (lookup != null)
{
lookup.addListDataListener(this);
//always need the empty item for zk to work correctly
lookup.setMandatory(false);
//no need to refresh readonly lookup
if (isReadWrite())
lookup.refresh();
refreshList();
}
}
@Override
public String getDisplay() {
String display = null;
Comboitem selItem = getComponent().getCombobox().getSelectedItem();
if (selItem != null)
{
display = selItem.getLabel();
}
return display;
}
@Override
public Object getValue() {
Object retVal = null;
Comboitem selItem = getComponent().getCombobox().getSelectedItem();
if (selItem != null)
{
retVal = selItem.getValue();
if ((retVal instanceof Integer) && (Integer)retVal == -1)
retVal = null;
}
return retVal;
}
@Override
public void setValue(Object value) {
if (value != null && (value instanceof Integer || value instanceof String))
{
getComponent().getCombobox().setValue(value);
if (!getComponent().getCombobox().isSelected(value))
{
if (isReadWrite() && lookup != null)
lookup.refresh();
Object curValue = oldValue;
oldValue = value;
refreshList();
//still not in list, reset to zero
if (!getComponent().getCombobox().isSelected(value))
{
if (value instanceof Integer && gridField != null && gridField.getDisplayType() != DisplayType.ID) // for IDs is ok to be out of the list
{
getComponent().getCombobox().setValue(null);
if (curValue == null)
curValue = value;
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), curValue, null);
super.fireValueChange(changeEvent);
oldValue = null;
}
}
}
else
{
oldValue = value;
}
}
else
{
getComponent().getCombobox().setValue(null);
oldValue = value;
}
}
@Override
public Paymentbox getComponent() {
return (Paymentbox) super.getComponent();
}
@Override
public boolean isReadWrite() {
return getComponent().isEnabled();
}
@Override
public void setReadWrite(boolean readWrite) {
GridTab m_mTab = gridField.getGridTab();
String m_DocStatus = (String) m_mTab.getValue("DocStatus");
// DocStatus
if (m_DocStatus == null)
m_DocStatus = "";
// Is the Trx closed? Reversed / Voided / Cloased
if (m_DocStatus.equals("RE") || m_DocStatus.equals("VO") || m_DocStatus.equals("CL"))
{
getComponent().setEnabled(readWrite, false);
return;
}
boolean m_onlyRule = 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;
boolean m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), gridField.getWindowNo(), "IsSOTrx"));
// PO only Rule
if (!m_onlyRule // Only order has Warehouse
&& !m_isSOTrx && m_mTab.getValue("M_Warehouse_ID") != null)
m_onlyRule = true;
getComponent().setEnabled(readWrite, readWrite && !m_onlyRule);
}
private void refreshList()
{
if (getComponent().getCombobox().getItemCount() > 0)
getComponent().getCombobox().removeAllItems();
if (isReadWrite())
{
if (lookup != null)
{
int size = lookup.getSize();
boolean found = false;
for (int i = 0; i < size; i++)
{
Object obj = lookup.getElementAt(i);
if (obj instanceof KeyNamePair)
{
KeyNamePair lookupKNPair = (KeyNamePair) obj;
getComponent().getCombobox().appendItem(lookupKNPair.getName(), lookupKNPair.getKey());
if (!found && oldValue != null && oldValue instanceof Integer &&
lookupKNPair.getKey() == (Integer)oldValue)
{
found = true;
}
}
else if (obj instanceof ValueNamePair)
{
ValueNamePair lookupKNPair = (ValueNamePair) obj;
getComponent().getCombobox().appendItem(lookupKNPair.getName(), lookupKNPair.getValue());
if (!found && oldValue != null && lookupKNPair.getValue().equals(oldValue.toString()))
{
found = true;
}
}
}
if (!found && oldValue != null)
{
NamePair pair = lookup.getDirect(oldValue, false, false);
if (pair != null) {
if (pair instanceof KeyNamePair) {
int key = ((KeyNamePair)pair).getKey();
getComponent().getCombobox().appendItem(pair.getName(), key);
} else if (pair instanceof ValueNamePair) {
ValueNamePair valueNamePair = (ValueNamePair) pair;
getComponent().getCombobox().appendItem(valueNamePair.getName(), valueNamePair.getValue());
}
}
}
}
}
else
{
if (lookup != null)
{
NamePair pair = lookup.getDirect(oldValue, false, false);
if (pair != null) {
if (pair instanceof KeyNamePair) {
int key = ((KeyNamePair)pair).getKey();
getComponent().getCombobox().appendItem(pair.getName(), key);
} else if (pair instanceof ValueNamePair) {
ValueNamePair valueNamePair = (ValueNamePair) pair;
getComponent().getCombobox().appendItem(valueNamePair.getName(), valueNamePair.getValue());
}
}
}
}
getComponent().getCombobox().setValue(oldValue);
}
@Override
public void onEvent(Event event) throws Exception {
if (Events.ON_SELECT.equalsIgnoreCase(event.getName()))
{
Object newValue = getValue();
if (isValueChange(newValue)) {
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
super.fireValueChange(changeEvent);
oldValue = newValue;
}
}
else if (Events.ON_BLUR.equalsIgnoreCase(event.getName()))
{
Comboitem item = getComponent().getCombobox().getSelectedItem();
if (item == null)
{
setValue(oldValue);
}
else
{
//on select not fire for empty label item
if (item.getLabel().equals(""))
{
Object newValue = getValue();
if (isValueChange(newValue)) {
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
super.fireValueChange(changeEvent);
oldValue = newValue;
}
}
}
}
else if (Events.ON_CLICK.equalsIgnoreCase(event.getName()))
{
int windowNo = lookup == null ? 0 : lookup.getWindowNo();
Object newValue = getValue();
if (newValue != null)
{
final IPaymentForm pf = WPaymentFormFactory.create(windowNo, getGridField().getGridTab(), (String) newValue);
if (pf != null)
{
final WPaymentFormWindow window = (WPaymentFormWindow) pf.getWindow();
if (window.isInitOK())
{
window.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
window.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (pf.needSave())
{
Component comp = getComponent();
while(comp != null)
{
comp = comp.getParent();
if (comp instanceof ADTabpanel)
{
Events.sendEvent(comp, new Event(ON_SAVE_PAYMENT, comp));
return;
}
}
// Events.sendEvent(new Event("onSave", this));
// onSave(false, false, new Callback<Boolean>() {
//
// @Override
// public void onCallback(Boolean result) {
// onRefresh(false, false);
// }
//
// });
}
}
});
pf.showWindow();
AEnv.showWindow(window);
}
}
}
}
}
@Override
public void contentsChanged(javax.swing.event.ListDataEvent e) {
refreshList();
}
@Override
public void intervalAdded(javax.swing.event.ListDataEvent e) {}
@Override
public void intervalRemoved(javax.swing.event.ListDataEvent e) {}
private boolean isValueChange(Object newValue) {
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|| ((oldValue != null && newValue != null) && !oldValue.equals(newValue));
}
public String[] getEvents() {
return LISTENER_EVENTS;
}
}

View File

@ -28,6 +28,7 @@ import org.adempiere.webui.editor.WLocatorEditor;
import org.adempiere.webui.editor.WNumberEditor;
import org.adempiere.webui.editor.WPAttributeEditor;
import org.adempiere.webui.editor.WPasswordEditor;
import org.adempiere.webui.editor.WPaymentEditor;
import org.adempiere.webui.editor.WSearchEditor;
import org.adempiere.webui.editor.WStringEditor;
import org.adempiere.webui.editor.WTableDirEditor;
@ -131,6 +132,11 @@ public class DefaultEditorFactory implements IEditorFactory {
{
editor = new WTableDirEditor(gridField);
}
else if (displayType == DisplayType.Payment)
{
editor = new WPaymentEditor(gridField);
}
else if (displayType == DisplayType.URL)
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

View File

@ -0,0 +1,16 @@
package org.compiere.grid;
public interface IPaymentForm {
public boolean checkMandatory();
public boolean saveChangesInTrx(final String trxName);
public boolean needSave();
public void showWindow();
public void closeWindow();
public Object getWindow();
}

View File

@ -0,0 +1,297 @@
package org.compiere.grid;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Hashtable;
import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.GridTab;
import org.compiere.model.MCashLine;
import org.compiere.model.MPayment;
import org.compiere.model.MSysConfig;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Trx;
import org.compiere.util.TrxRunnable;
public abstract class PaymentForm implements IPaymentForm {
/** Logger */
protected CLogger log = CLogger.getCLogger(getClass());
/** Window */
private int m_WindowNo = 0;
/** Tab */
private GridTab m_mTab;
// Data from Order/Invoice
public String m_DocStatus = null;
/** Start Payment Rule */
public String m_PaymentRule = "";
/** Start Payment Term */
public int m_C_PaymentTerm_ID = 0;
/** Start Acct Date */
public Timestamp m_DateAcct = null;
/** Start Payment */
public int m_C_Payment_ID = 0;
public MPayment m_mPayment = null;
public MPayment m_mPaymentOriginal = null;
/** Start CashBook Line */
public int m_C_CashLine_ID = 0;
public MCashLine m_cashLine = null;
/** Start CreditCard */
public String m_CCType = "";
/** Start Bank Account */
public int m_C_BankAccount_ID = 0;
/** Start CashBook */
public int m_C_CashBook_ID = 0;
/** Invoice Currency */
public int m_C_Currency_ID = 0;
public int m_AD_Client_ID = 0;
public boolean m_Cash_As_Payment = true;
public int m_AD_Org_ID = 0;
public int m_C_BPartner_ID = 0;
public BigDecimal m_Amount = Env.ZERO; // Payment Amount
public boolean m_needSave = false;
/** Only allow changing Rule */
public boolean m_onlyRule = false;
/** Is SOTrx */
public boolean m_isSOTrx = true;
public Hashtable<Integer,KeyNamePair> s_Currencies = null;
public PaymentForm(int WindowNo, GridTab mTab) {
m_WindowNo = WindowNo;
m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), WindowNo, "IsSOTrx"));
m_mTab = mTab;
}
public boolean dynInit() throws Exception {
m_DocStatus = (String) m_mTab.getValue("DocStatus");
log.config(m_DocStatus);
if (m_mTab.getValue("C_BPartner_ID") == null) {
throw new AdempiereException("SaveErrorRowNotFound");
}
// DocStatus
if (m_DocStatus == null)
m_DocStatus = "";
// Is the Trx closed? Reversed / Voided / Cloased
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 (!m_onlyRule // Only order has Warehouse
&& !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)
{
throw new AdempiereException("PaymentZero");
}
/**
* Get Data from Grid
*/
m_AD_Client_ID = ((Integer)m_mTab.getValue("AD_Client_ID")).intValue();
m_Cash_As_Payment = MSysConfig.getBooleanValue(MSysConfig.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);
m_mPaymentOriginal = new MPayment(Env.getCtx(), m_C_Payment_ID, null); // full copy
m_CCType = m_mPayment.getCreditCardType();
m_C_BankAccount_ID = m_mPayment.getC_BankAccount_ID();
}
}
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);
}
if (s_Currencies == null)
loadCurrencies();
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();
}
}
/**
* Payment Combo
*/
if (m_PaymentRule == null)
m_PaymentRule = "";
loadData();
return true;
}
public abstract void loadData();
/**************************************************************************
* Save Changes
* @return true, if Window can exit
*/
public boolean saveChanges() {
// BF [ 1920179 ] perform the save in a trx's context.
final boolean[] success = new boolean[] { false };
final TrxRunnable r = new TrxRunnable() {
public void run(String trxName) {
// set trxname for class objects
if (m_cashLine != null)
m_cashLine.set_TrxName(trxName);
if (m_mPayment != null)
m_mPayment.set_TrxName(trxName);
if (m_mPaymentOriginal != null)
m_mPaymentOriginal.set_TrxName(trxName);
// only Payment Rule
if (m_onlyRule)
success[0] = true;
else
success[0] = saveChangesInTrx(trxName);
}
};
try {
Trx.run(r);
} catch (Throwable e) {
success[0] = false;
throw new AdempiereException("PaymentError", e);
}
if (m_cashLine != null)
m_cashLine.set_TrxName(null);
if (m_mPayment != null)
m_mPayment.set_TrxName(null);
if (m_mPaymentOriginal != null)
m_mPayment.set_TrxName(null);
return success[0];
} // saveChanges
/**
* Fill s_Currencies with EMU currencies
*/
protected void loadCurrencies()
{
s_Currencies = new Hashtable<Integer,KeyNamePair>(12); // Currenly only 10+1
String SQL = "SELECT C_Currency_ID, ISO_Code FROM C_Currency "
+ "WHERE (IsEMUMember='Y' AND EMUEntryDate<SysDate) OR IsEuro='Y' "
+ "ORDER BY 2";
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
int id = rs.getInt(1);
String name = rs.getString(2);
s_Currencies.put(new Integer(id), new KeyNamePair(id, name));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, SQL, e);
}
} // loadCurrencies
/**
* Need Save record (payment with waiting order)
* @return true if payment with waiting order
*/
public boolean needSave()
{
return m_needSave;
} // needSave
/**
* Get Invoice ID for Order
* @param C_Order_ID order
* @return C_Invoice_ID or 0 if not found
*/
protected int getInvoiceID (int C_Order_ID)
{
int retValue = 0;
String sql = "SELECT C_Invoice_ID FROM C_Invoice WHERE C_Order_ID=? "
+ "ORDER BY C_Invoice_ID DESC"; // last invoice
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_Order_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
return retValue;
} // getInvoiceID
public GridTab getGridTab()
{
return m_mTab;
}
public boolean isOnlyRule()
{
return m_onlyRule;
}
public boolean isApproved()
{
return m_mPayment.isApproved();
}
public int getWindowNo()
{
return m_WindowNo;
}
}

View File

@ -0,0 +1,326 @@
package org.compiere.grid;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.logging.Level;
import org.compiere.model.GridTab;
import org.compiere.model.MCash;
import org.compiere.model.MCashLine;
import org.compiere.model.MInvoice;
import org.compiere.model.MOrder;
import org.compiere.model.MPayment;
import org.compiere.model.MRole;
import org.compiere.process.DocAction;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.TimeUtil;
public abstract class PaymentFormCash extends PaymentForm {
public static final String PAYMENTRULE = MInvoice.PAYMENTRULE_Cash;
public PaymentFormCash(int WindowNo, GridTab mTab) {
super(WindowNo, mTab);
}
public KeyNamePair selectedBankAccount;
public ArrayList<KeyNamePair> getBankAccountList() {
selectedBankAccount = null;
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
/**
* Load Bank Accounts
*/
String SQL = MRole.getDefault().addAccessSQL(
"SELECT C_BankAccount_ID, ba.Name || ' ' || 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);
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);
list.add(pp);
if (key == m_C_BankAccount_ID)
selectedBankAccount = pp;
if (selectedBankAccount == null && rs.getString(3).equals("Y")) // Default
selectedBankAccount = pp;
}
rs.close();
pstmt.close();
}
catch (SQLException ept)
{
log.log(Level.SEVERE, SQL, ept);
}
return list;
}
public KeyNamePair selectedCashBook;
public ArrayList<KeyNamePair> getCashBookList() {
selectedCashBook = null;
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
/**
* Load Cash Books
*/
String 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);
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);
list.add(pp);
if (key == m_C_CashBook_ID)
selectedCashBook = pp;
if (selectedCashBook == null && key == m_AD_Org_ID) // Default Org
selectedCashBook = pp;
}
rs.close();
pstmt.close();
}
catch (SQLException epc)
{
log.log(Level.SEVERE, SQL, epc);
}
if (selectedCashBook != null)
{
if (m_C_CashBook_ID == 0)
m_C_CashBook_ID = selectedCashBook.getKey(); // set to default to avoid 'cashbook changed' message
}
return list;
}
public String processMsg;
public boolean save(int newC_BankAccount_ID, int newC_CashBook_ID, Timestamp newDateAcct, BigDecimal newAmount, String trxName)
{
processMsg = null;
boolean error = false;
int newC_CashLine_ID = m_C_CashLine_ID;
/***********************
* Changed PaymentRule
*/
if (!PAYMENTRULE.equals(m_PaymentRule))
{
log.fine("Changed PaymentRule: " + m_PaymentRule + " -> " + PAYMENTRULE);
// We had a CashBook Entry
log.fine("Old Cash - " + m_cashLine);
if (m_cashLine != null)
{
MCashLine cl = m_cashLine.createReversal();
if (cl.save())
log.config( "CashCancelled");
else
{
processMsg = "CashNotCancelled";
error = true;
}
}
newC_CashLine_ID = 0; // reset
}
// Get Order and optionally Invoice
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Order_ID");
int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Invoice_ID");
if (C_Invoice_ID == 0 && m_DocStatus.equals("CO"))
C_Invoice_ID = getInvoiceID (C_Order_ID);
// Amount sign negative, if ARC (Credit Memo) or API (AP Invoice)
boolean negateAmt = false;
MInvoice invoice = null;
if (C_Invoice_ID != 0)
{
invoice = new MInvoice (Env.getCtx(), C_Invoice_ID, null);
negateAmt = invoice.isCreditMemo();
}
MOrder order = null;
if (invoice == null && C_Order_ID != 0)
order = new MOrder (Env.getCtx(), C_Order_ID, null);
BigDecimal payAmount = m_Amount;
if (negateAmt)
payAmount = m_Amount.negate();
// Info
log.config("C_Order_ID=" + C_Order_ID + ", C_Invoice_ID=" + C_Invoice_ID + ", NegateAmt=" + negateAmt);
/***********************
* CashBook
*/
if (!m_Cash_As_Payment)
{
log.fine("Cash");
if (C_Invoice_ID == 0 && order == null)
{
log.config("No Invoice!");
processMsg = "CashNotCreated";
error = false;
}
else
{
payAmount = newAmount;
// Changed Amount
if (m_cashLine != null
&& payAmount.compareTo(m_cashLine.getAmount()) != 0)
{
log.config("Changed CashBook Amount");
m_cashLine.setAmount(newAmount);
m_cashLine.saveEx();
}
// Different Date/CashBook
if (m_cashLine != null
&& (newC_CashBook_ID != m_C_CashBook_ID
|| !TimeUtil.isSameDay(m_cashLine.getStatementDate(), newDateAcct)))
{
log.config("Changed CashBook/Date: " + m_C_CashBook_ID + "->" + newC_CashBook_ID);
MCashLine reverse = m_cashLine.createReversal();
reverse.saveEx();
m_cashLine = null;
}
// Create new
if (m_cashLine == null)
{
log.config("New CashBook");
int C_Currency_ID = 0;
if (invoice != null)
C_Currency_ID = invoice.getC_Currency_ID();
if (C_Currency_ID == 0 && order != null)
C_Currency_ID = order.getC_Currency_ID();
MCash cash = null;
if (newC_CashBook_ID != 0)
cash = MCash.get (Env.getCtx(), newC_CashBook_ID, newDateAcct, null);
else // Default
cash = MCash.get (Env.getCtx(), m_AD_Org_ID, newDateAcct, C_Currency_ID, null);
if (cash == null || cash.get_ID() == 0)
{
processMsg = CLogger.retrieveErrorString("CashNotCreated");
error = true;
}
else
{
MCashLine cl = new MCashLine (cash);
// cl.setAmount(new BigDecimal(bAmountField.getText()));
//ADialog.info(m_WindowNo, this, "m_cashLine - New Cashbook", "Amount: "+cl.getAmount());
if (invoice != null)
cl.setInvoice(invoice); // overrides amount
if (order != null)
{
cl.setOrder(order, null); // overrides amount
m_needSave = true;
}
cl.setAmount(newAmount);
cl.saveEx();
log.config("CashCreated");
if (invoice == null && C_Invoice_ID != 0)
{
invoice = new MInvoice (Env.getCtx(), C_Invoice_ID, null);
}
if (invoice != null) {
invoice.setC_CashLine_ID(cl.getC_CashLine_ID());
invoice.saveEx(trxName);
}
if (order == null && C_Order_ID != 0)
{
order = new MOrder (Env.getCtx(), C_Order_ID, null);
}
if (order != null) {
order.setC_CashLine_ID(cl.getC_CashLine_ID());
order.saveEx(trxName);
}
log.config("Update Order & Invoice with CashLine");
}
}
} // have invoice
}
/***********************
* Payments
*/
if (m_Cash_As_Payment)
{
log.fine("Payment - " + PAYMENTRULE);
// Set Amount
m_mPayment.setAmount(m_C_Currency_ID, payAmount);
// Get changes to cash amount
m_mPayment.setTenderType(MPayment.TENDERTYPE_Cash);
m_mPayment.setBankCash(newC_BankAccount_ID, m_isSOTrx, MPayment.TENDERTYPE_Cash);
m_mPayment.setAmount(m_C_Currency_ID, payAmount);
m_mPayment.setC_BPartner_ID(m_C_BPartner_ID);
m_mPayment.setC_Invoice_ID(C_Invoice_ID);
if (order != null)
{
m_mPayment.setC_Order_ID(C_Order_ID);
m_needSave = true;
}
m_mPayment.setDateTrx(m_DateAcct);
m_mPayment.setDateAcct(m_DateAcct);
m_mPayment.saveEx();
// Save/Post
if (m_mPayment.get_ID() > 0 && MPayment.DOCSTATUS_Drafted.equals(m_mPayment.getDocStatus()))
{
boolean ok = m_mPayment.processIt(DocAction.ACTION_Complete);
m_mPayment.saveEx();
if (ok)
processMsg = m_mPayment.getDocumentNo();
else
{
processMsg = "PaymentNotCreated";
error = true;
}
}
else
log.fine("NotDraft " + m_mPayment);
}
/**********************
* Save Values to mTab
*/
log.config("Saving changes");
//
if (!newDateAcct.equals(m_DateAcct))
getGridTab().setValue("DateAcct", newDateAcct);
// Set Payment
if (m_mPayment.getC_Payment_ID() != m_C_Payment_ID)
{
if (m_mPayment.getC_Payment_ID() == 0)
getGridTab().setValue("C_Payment_ID", null);
else
getGridTab().setValue("C_Payment_ID", new Integer(m_mPayment.getC_Payment_ID()));
}
// Set Cash
if (newC_CashLine_ID != m_C_CashLine_ID)
{
if (newC_CashLine_ID == 0)
getGridTab().setValue("C_CashLine_ID", null);
else
getGridTab().setValue("C_CashLine_ID", new Integer(newC_CashLine_ID));
}
return !error;
}
}

View File

@ -0,0 +1,198 @@
package org.compiere.grid;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import org.compiere.model.GridTab;
import org.compiere.model.MInvoice;
import org.compiere.model.MOrder;
import org.compiere.model.MPayment;
import org.compiere.model.MRole;
import org.compiere.process.DocAction;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
public abstract class PaymentFormCheck extends PaymentForm {
public static final String PAYMENTRULE = MInvoice.PAYMENTRULE_Check;
public PaymentFormCheck(int WindowNo, GridTab mTab) {
super(WindowNo, mTab);
}
public KeyNamePair selectedBankAccount;
public ArrayList<KeyNamePair> getBankAccountList() {
selectedBankAccount = null;
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
/**
* Load Bank Accounts
*/
String SQL = MRole.getDefault().addAccessSQL(
"SELECT C_BankAccount_ID, ba.Name || ' ' || 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);
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);
list.add(pp);
if (key == m_C_BankAccount_ID)
selectedBankAccount = pp;
if (selectedBankAccount == null && rs.getString(3).equals("Y")) // Default
selectedBankAccount = pp;
}
rs.close();
pstmt.close();
}
catch (SQLException ept)
{
log.log(Level.SEVERE, SQL, ept);
}
return list;
}
public String processMsg = null;
public boolean save(int newC_BankAccount_ID, String routing, String number, String check, BigDecimal amount)
{
processMsg = null;
boolean error = false;
String payTypes = m_Cash_As_Payment ? "KTSDB" : "KTSD";
/***********************
* Changed PaymentRule
*/
if (!PAYMENTRULE.equals(m_PaymentRule))
{
log.fine("Changed PaymentRule: " + m_PaymentRule + " -> " + PAYMENTRULE);
// We had a change in Payment type (e.g. Check to CC)
if (payTypes.indexOf(m_PaymentRule) != -1 && payTypes.indexOf(PAYMENTRULE) != -1 && m_mPaymentOriginal != null)
{
log.fine("Old Payment(1) - " + m_mPaymentOriginal);
m_mPaymentOriginal.setDocAction(DocAction.ACTION_Reverse_Correct);
boolean ok = m_mPaymentOriginal.processIt(DocAction.ACTION_Reverse_Correct);
m_mPaymentOriginal.saveEx();
if (ok)
log.info( "Payment Canecelled - " + m_mPaymentOriginal);
else
{
processMsg = "PaymentNotCancelled " + m_mPaymentOriginal.getDocumentNo();
error = true;
}
m_mPayment.resetNew();
}
// We had a Payment and something else (e.g. Check to Cash)
else if (payTypes.indexOf(m_PaymentRule) != -1 && payTypes.indexOf(PAYMENTRULE) == -1)
{
log.fine("Old Payment(2) - " + m_mPaymentOriginal);
if (m_mPaymentOriginal != null)
{
m_mPaymentOriginal.setDocAction(DocAction.ACTION_Reverse_Correct);
boolean ok = m_mPaymentOriginal.processIt(DocAction.ACTION_Reverse_Correct);
m_mPaymentOriginal.saveEx();
if (ok) // Cancel Payment
{
log.fine("PaymentCancelled " + m_mPayment.getDocumentNo ());
getGridTab().getTableModel().dataSave(true);
m_mPayment.resetNew();
m_mPayment.setAmount(m_C_Currency_ID, m_Amount);
}
else
{
processMsg = "PaymentNotCancelled " + m_mPayment.getDocumentNo();
error = true;
}
}
}
}
// Get Order and optionally Invoice
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Order_ID");
int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Invoice_ID");
if (C_Invoice_ID == 0 && m_DocStatus.equals("CO"))
C_Invoice_ID = getInvoiceID (C_Order_ID);
// Amount sign negative, if ARC (Credit Memo) or API (AP Invoice)
boolean negateAmt = false;
MInvoice invoice = null;
if (C_Invoice_ID != 0)
{
invoice = new MInvoice (Env.getCtx(), C_Invoice_ID, null);
negateAmt = invoice.isCreditMemo();
}
MOrder order = null;
if (invoice == null && C_Order_ID != 0)
order = new MOrder (Env.getCtx(), C_Order_ID, null);
BigDecimal payAmount = m_Amount;
if (negateAmt)
payAmount = m_Amount.negate();
// Info
log.config("C_Order_ID=" + C_Order_ID + ", C_Invoice_ID=" + C_Invoice_ID + ", NegateAmt=" + negateAmt);
/***********************
* Payments
*/
log.fine("Payment - " + PAYMENTRULE);
// Set Amount
m_mPayment.setAmount(m_C_Currency_ID, payAmount);
m_mPayment.setBankCheck(newC_BankAccount_ID, m_isSOTrx, routing,
number, check);
// Get changes to check amount
m_mPayment.setAmount(m_C_Currency_ID, amount);
m_mPayment.setC_BPartner_ID(m_C_BPartner_ID);
m_mPayment.setC_Invoice_ID(C_Invoice_ID);
if (order != null)
{
m_mPayment.setC_Order_ID(C_Order_ID);
m_needSave = true;
}
m_mPayment.setDateTrx(m_DateAcct);
m_mPayment.setDateAcct(m_DateAcct);
m_mPayment.saveEx();
// Save/Post
if (m_mPayment.get_ID() > 0 && MPayment.DOCSTATUS_Drafted.equals(m_mPayment.getDocStatus()))
{
boolean ok = m_mPayment.processIt(DocAction.ACTION_Complete);
m_mPayment.saveEx();
if (ok)
processMsg = m_mPayment.getDocumentNo();
else
{
processMsg = "PaymentNotCreated";
error = true;
}
}
else
log.fine("NotDraft " + m_mPayment);
/**********************
* Save Values to mTab
*/
log.config("Saving changes");
// Set Payment
if (m_mPayment.getC_Payment_ID() != m_C_Payment_ID)
{
if (m_mPayment.getC_Payment_ID() == 0)
getGridTab().setValue("C_Payment_ID", null);
else
getGridTab().setValue("C_Payment_ID", new Integer(m_mPayment.getC_Payment_ID()));
}
return !error;
}
}

View File

@ -0,0 +1,221 @@
package org.compiere.grid;
import java.math.BigDecimal;
import org.compiere.model.GridTab;
import org.compiere.model.MInvoice;
import org.compiere.model.MOrder;
import org.compiere.model.MPayment;
import org.compiere.process.DocAction;
import org.compiere.util.Env;
import org.compiere.util.ValueNamePair;
public abstract class PaymentFormCreditCard extends PaymentForm {
public static final String PAYMENTRULE = MInvoice.PAYMENTRULE_CreditCard;
public PaymentFormCreditCard(int WindowNo, GridTab mTab) {
super(WindowNo, mTab);
}
public ValueNamePair selectedCreditCard;
public ValueNamePair[] getCreditCardList()
{
selectedCreditCard = null;
ValueNamePair[] ccs = m_mPayment.getCreditCards();
for (int i = 0; i < ccs.length; i++)
{
if (ccs[i].getValue().equals(m_CCType))
selectedCreditCard = ccs[i];
}
return ccs;
}
public String processMsg = null;
public boolean save(String newCCType, String newCCNumber, String newCCExp, BigDecimal newAmount)
{
processMsg = null;
boolean error = false;
String payTypes = m_Cash_As_Payment ? "KTSDB" : "KTSD";
/***********************
* Changed PaymentRule
*/
if (!PAYMENTRULE.equals(m_PaymentRule))
{
log.fine("Changed PaymentRule: " + m_PaymentRule + " -> " + PAYMENTRULE);
// We had a change in Payment type (e.g. Check to CC)
if (payTypes.indexOf(m_PaymentRule) != -1 && payTypes.indexOf(PAYMENTRULE) != -1 && m_mPaymentOriginal != null)
{
log.fine("Old Payment(1) - " + m_mPaymentOriginal);
m_mPaymentOriginal.setDocAction(DocAction.ACTION_Reverse_Correct);
boolean ok = m_mPaymentOriginal.processIt(DocAction.ACTION_Reverse_Correct);
m_mPaymentOriginal.saveEx();
if (ok)
log.info( "Payment Canecelled - " + m_mPaymentOriginal);
else
{
processMsg = "PaymentNotCancelled " + m_mPaymentOriginal.getDocumentNo();
error = true;
}
m_mPayment.resetNew();
}
// We had a Payment and something else (e.g. Check to Cash)
else if (payTypes.indexOf(m_PaymentRule) != -1 && payTypes.indexOf(PAYMENTRULE) == -1)
{
log.fine("Old Payment(2) - " + m_mPaymentOriginal);
if (m_mPaymentOriginal != null)
{
m_mPaymentOriginal.setDocAction(DocAction.ACTION_Reverse_Correct);
boolean ok = m_mPaymentOriginal.processIt(DocAction.ACTION_Reverse_Correct);
m_mPaymentOriginal.saveEx();
if (ok) // Cancel Payment
{
log.fine("PaymentCancelled " + m_mPayment.getDocumentNo ());
getGridTab().getTableModel().dataSave(true);
m_mPayment.resetNew();
m_mPayment.setAmount(m_C_Currency_ID, m_Amount);
}
else
{
processMsg = "PaymentNotCancelled " + m_mPayment.getDocumentNo();
error = true;
}
}
}
}
// Get Order and optionally Invoice
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Order_ID");
int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Invoice_ID");
if (C_Invoice_ID == 0 && m_DocStatus.equals("CO"))
C_Invoice_ID = getInvoiceID (C_Order_ID);
// Amount sign negative, if ARC (Credit Memo) or API (AP Invoice)
boolean negateAmt = false;
MInvoice invoice = null;
if (C_Invoice_ID != 0)
{
invoice = new MInvoice (Env.getCtx(), C_Invoice_ID, null);
negateAmt = invoice.isCreditMemo();
}
MOrder order = null;
if (invoice == null && C_Order_ID != 0)
order = new MOrder (Env.getCtx(), C_Order_ID, null);
BigDecimal payAmount = m_Amount;
if (negateAmt)
payAmount = m_Amount.negate();
// Info
log.config("C_Order_ID=" + C_Order_ID + ", C_Invoice_ID=" + C_Invoice_ID + ", NegateAmt=" + negateAmt);
/***********************
* Payments
*/
log.fine("Payment - " + PAYMENTRULE);
// Set Amount
m_mPayment.setAmount(m_C_Currency_ID, payAmount);
m_mPayment.setCreditCard(MPayment.TRXTYPE_Sales, newCCType, newCCNumber, "", newCCExp);
// Get changes to credit card amount
m_mPayment.setAmount(m_C_Currency_ID, newAmount);
m_mPayment.setPaymentProcessor();
m_mPayment.setC_BPartner_ID(m_C_BPartner_ID);
m_mPayment.setC_Invoice_ID(C_Invoice_ID);
if (order != null)
{
m_mPayment.setC_Order_ID(C_Order_ID);
m_needSave = true;
}
m_mPayment.setDateTrx(m_DateAcct);
m_mPayment.setDateAcct(m_DateAcct);
m_mPayment.saveEx();
// Save/Post
if (m_mPayment.get_ID() > 0 && MPayment.DOCSTATUS_Drafted.equals(m_mPayment.getDocStatus()))
{
boolean ok = m_mPayment.processIt(DocAction.ACTION_Complete);
m_mPayment.saveEx();
if (ok)
processMsg = m_mPayment.getDocumentNo();
else
{
processMsg = "PaymentNotCreated";
error = true;
}
}
else
log.fine("NotDraft " + m_mPayment);
/**********************
* Save Values to mTab
*/
log.config("Saving changes");
// Set Payment
if (m_mPayment.getC_Payment_ID() != m_C_Payment_ID)
{
if (m_mPayment.getC_Payment_ID() == 0)
getGridTab().setValue("C_Payment_ID", null);
else
getGridTab().setValue("C_Payment_ID", new Integer(m_mPayment.getC_Payment_ID()));
}
return !error;
}
public boolean processOnline(String CCType, String CCNumber, String CCExp)
{
processMsg = null;
boolean error = false;
boolean approved = false;
String info = "";
m_mPayment.setCreditCard(MPayment.TRXTYPE_Sales, CCType,
CCNumber, "", CCExp);
m_mPayment.setAmount(m_C_Currency_ID, m_Amount);
m_mPayment.setPaymentProcessor();
m_mPayment.setC_BPartner_ID(m_C_BPartner_ID);
//
int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Invoice_ID");
if (C_Invoice_ID == 0 && m_DocStatus.equals("CO"))
{
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Order_ID");
C_Invoice_ID = getInvoiceID (C_Order_ID);
}
m_mPayment.setC_Invoice_ID(C_Invoice_ID);
m_mPayment.setDateTrx(m_DateAcct);
// Set Amount
m_mPayment.setAmount(m_C_Currency_ID, m_Amount);
if (!m_mPayment.save()) {
processMsg = "PaymentNotCreated";
return false;
} else {
approved = m_mPayment.processOnline();
info = m_mPayment.getR_RespMsg() + " (" + m_mPayment.getR_AuthCode()
+ ") ID=" + m_mPayment.getR_PnRef();
m_mPayment.saveEx();
if (approved)
{
boolean ok = m_mPayment.processIt(DocAction.ACTION_Complete);
m_mPayment.saveEx();
if (ok)
processMsg = info + "\n" + m_mPayment.getDocumentNo();
else
{
processMsg = "PaymentNotCreated";
error = true;
}
saveChanges();
}
else
{
processMsg = info;
error = true;
}
}
return !error;
}
}

View File

@ -0,0 +1,12 @@
package org.compiere.grid;
import org.compiere.model.GridTab;
import org.compiere.model.MInvoice;
public abstract class PaymentFormDirectDebit extends PaymentFormDirectDeposit {
public static final String PAYMENTRULE = MInvoice.PAYMENTRULE_DirectDebit;
public PaymentFormDirectDebit(int WindowNo, GridTab mTab) {
super(WindowNo, mTab);
}
}

View File

@ -0,0 +1,125 @@
package org.compiere.grid;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import org.compiere.model.GridTab;
import org.compiere.model.MInvoice;
import org.compiere.process.DocAction;
import org.compiere.util.DB;
import org.compiere.util.KeyNamePair;
public abstract class PaymentFormDirectDeposit extends PaymentForm {
public static final String PAYMENTRULE = MInvoice.PAYMENTRULE_DirectDeposit;
public PaymentFormDirectDeposit(int WindowNo, GridTab mTab) {
super(WindowNo, mTab);
}
public ArrayList<KeyNamePair> getBankAccountList() {
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
/**
* Load Accounts
*/
String 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'";
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);
list.add(pp);
}
rs.close();
pstmt.close();
}
catch (SQLException eac)
{
log.log(Level.SEVERE, SQL, eac);
}
return list;
}
public String processMsg;
public boolean save()
{
processMsg = null;
boolean error = false;
String payTypes = m_Cash_As_Payment ? "KTSDB" : "KTSD";
/***********************
* Changed PaymentRule
*/
if (!PAYMENTRULE.equals(m_PaymentRule))
{
log.fine("Changed PaymentRule: " + m_PaymentRule + " -> " + PAYMENTRULE);
// We had a change in Payment type (e.g. Check to CC)
if (payTypes.indexOf(m_PaymentRule) != -1 && payTypes.indexOf(PAYMENTRULE) != -1 && m_mPaymentOriginal != null)
{
log.fine("Old Payment(1) - " + m_mPaymentOriginal);
m_mPaymentOriginal.setDocAction(DocAction.ACTION_Reverse_Correct);
boolean ok = m_mPaymentOriginal.processIt(DocAction.ACTION_Reverse_Correct);
m_mPaymentOriginal.saveEx();
if (ok)
log.info( "Payment Canecelled - " + m_mPaymentOriginal);
else
{
processMsg = "PaymentNotCancelled " + m_mPaymentOriginal.getDocumentNo();
error = true;
}
m_mPayment.resetNew();
}
// We had a Payment and something else (e.g. Check to Cash)
else if (payTypes.indexOf(m_PaymentRule) != -1 && payTypes.indexOf(PAYMENTRULE) == -1)
{
log.fine("Old Payment(2) - " + m_mPaymentOriginal);
if (m_mPaymentOriginal != null)
{
m_mPaymentOriginal.setDocAction(DocAction.ACTION_Reverse_Correct);
boolean ok = m_mPaymentOriginal.processIt(DocAction.ACTION_Reverse_Correct);
m_mPaymentOriginal.saveEx();
if (ok) // Cancel Payment
{
log.fine("PaymentCancelled " + m_mPayment.getDocumentNo ());
getGridTab().getTableModel().dataSave(true);
m_mPayment.resetNew();
m_mPayment.setAmount(m_C_Currency_ID, m_Amount);
}
else
{
processMsg = "PaymentNotCancelled " + m_mPayment.getDocumentNo();
error = true;
}
}
}
}
/**********************
* Save Values to mTab
*/
log.config("Saving changes");
// Set Payment
if (m_mPayment.getC_Payment_ID() != m_C_Payment_ID)
{
if (m_mPayment.getC_Payment_ID() == 0)
getGridTab().setValue("C_Payment_ID", null);
else
getGridTab().setValue("C_Payment_ID", new Integer(m_mPayment.getC_Payment_ID()));
}
return !error;
}
}

View File

@ -0,0 +1,12 @@
package org.compiere.grid;
import org.compiere.model.GridTab;
import org.compiere.model.MInvoice;
public abstract class PaymentFormMixedPOS extends PaymentForm {
public static final String PAYMENTRULE = MInvoice.PAYMENTRULE_MixedPOSPayment;
public PaymentFormMixedPOS(int WindowNo, GridTab mTab) {
super(WindowNo, mTab);
}
}

View File

@ -0,0 +1,69 @@
package org.compiere.grid;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import org.compiere.model.GridTab;
import org.compiere.model.MInvoice;
import org.compiere.model.MRole;
import org.compiere.util.DB;
import org.compiere.util.KeyNamePair;
public abstract class PaymentFormOnCredit extends PaymentForm {
public static final String PAYMENTRULE = MInvoice.PAYMENTRULE_OnCredit;
/** Start Payment Term */
public int m_C_PaymentTerm_ID = 0;
public PaymentFormOnCredit(int WindowNo, GridTab mTab) {
super(WindowNo, mTab);
if (mTab.getValue("C_PaymentTerm_ID") != null)
m_C_PaymentTerm_ID = ((Integer)mTab.getValue("C_PaymentTerm_ID")).intValue();
}
public KeyNamePair selectedPaymentTerm = null;
public ArrayList<KeyNamePair> getPaymentTermList() {
selectedPaymentTerm = null;
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
/**
* 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);
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);
list.add(pp);
if (pp.getKey() == m_C_PaymentTerm_ID)
selectedPaymentTerm = pp;
}
rs.close();
pstmt.close();
}
catch (SQLException ept)
{
log.log(Level.SEVERE, SQL, ept);
}
return list;
}
public boolean save(int newC_PaymentTerm_ID)
{
if (newC_PaymentTerm_ID != m_C_PaymentTerm_ID)
getGridTab().setValue("C_PaymentTerm_ID", new Integer(newC_PaymentTerm_ID));
return true;
}
}