Author: diveshdutta
Date: Fri Sep 2 10:02:32 2016 New Revision: 1758926 URL: http://svn.apache.org/viewvc?rev=1758926&view=rev Log: [OFBIZ-6899] Added support to add Check Account from Party profile page. Now user can add separate Check account with Bank name , routing number and other details and these details will be added in recently added new table called CheckAccount. Added Check account will also be shown in Payment method section of Party profile page. Added new service createCheckAccount to support this functionality. Thanks to Jagpreet Kaur for providing the patch and thanks Pierre for reporting the ticket and discussions. Also thanks to Jacques and Swapnil Shah for participating in discussions. Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml ofbiz/trunk/applications/accounting/minilang/payment/PaymentMapProcs.xml ofbiz/trunk/applications/accounting/minilang/payment/PaymentMethodEvents.xml ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java ofbiz/trunk/applications/party/template/party/profileblocks/PaymentMethods.ftl ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml ofbiz/trunk/applications/party/widget/partymgr/PaymentMethodScreens.xml Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml?rev=1758926&r1=1758925&r2=1758926&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml (original) +++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml Fri Sep 2 10:02:32 2016 @@ -338,6 +338,9 @@ <value xml:lang="zh">æ·»å åç±»æ»è´¦è´¦æ·</value> <value xml:lang="zh-TW">å¢å 總帳ç§ç®åé¡</value> </property> + <property key="AccountingAddCheckAccount"> + <value xml:lang="en">Add Check Account</value> + </property> <property key="AccountingAddCustomTimePeriod"> <value xml:lang="ar">إضاÙØ© Ùترة ز٠ÙÙØ© Ù ÙصÙØ©</value> <value xml:lang="de">Individueller Zeitraum hinzufügen</value> @@ -2982,6 +2985,12 @@ <value xml:lang="zh">æ¯ç¥¨éé¢</value> <value xml:lang="zh-TW">æ¯ç¥¨éé¡</value> </property> + <property key="AccountingCheckCreatedSuccessfully"> + <value xml:lang="en">Check Account information created successfully</value> + </property> + <property key="AccountingCheckNotAdded"> + <value xml:lang="en">Check Account Information can't be created</value> + </property> <property key="AccountingCheckGiftCard"> <value xml:lang="ar">تØÙ٠٠٠ا إذا Ùا٠Ùد٠بطاÙØ© ÙدÙØ© ÙÙإستخدا٠اÙÙÙÙ </value> <value xml:lang="de">Prüfen Sie, ob Sie einen Geschenkgutschein zur heutigen Verwendung haben</value> @@ -12239,6 +12248,9 @@ <value xml:lang="zh">æ¯ä»æ¹æ³ä¿¡æ¯</value> <value xml:lang="zh-TW">æ¯ä»æ¹æ³è³è¨</value> </property> + <property key="AccountingPaymentMethodTypeMissing"> + <value xml:lang="en">Payment method type is missing</value> + </property> <property key="AccountingPaymentMethodTypeNotHandled"> <value xml:lang="de">Zahlungsmethode nicht verarbeitet paymentMethodTypeId :</value> <value xml:lang="en">Payment method not handled paymentMethodTypeId :</value> Modified: ofbiz/trunk/applications/accounting/minilang/payment/PaymentMapProcs.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/minilang/payment/PaymentMapProcs.xml?rev=1758926&r1=1758925&r2=1758926&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/minilang/payment/PaymentMapProcs.xml (original) +++ ofbiz/trunk/applications/accounting/minilang/payment/PaymentMapProcs.xml Fri Sep 2 10:02:32 2016 @@ -112,4 +112,18 @@ under the License. <process field="description"><copy/></process> <!-- also call createEftAccount after calling updateEftAccount --> </simple-map-processor> + + <!-- Check map procs --> + <simple-map-processor name="createCheckAccount"> + <process field="partyId"><copy/></process> + <process field="bankName"><copy/><not-empty><fail-property resource="AccountingUiLabels" property="AccountingBankNameMissing"/></not-empty></process> + <process field="paymentMethodTypeId"><copy/><not-empty><fail-property resource="AccountingPaymentMethodTypeMissing" property="AccountingAccountTypeMissing"/></not-empty></process> + <process field="description"><copy/></process> + <process field="routingNumber"><copy/></process> + <process field="accountType"><copy/></process> + <process field="accountNumber"><copy/></process> + <process field="nameOnAccount"><copy/><not-empty><fail-property resource="AccountingUiLabels" property="AccountingNameOnAccountMissing"/></not-empty></process> + <process field="companyNameOnAccount"><copy/></process> + <process field="contactMechId"><copy/></process> + </simple-map-processor> </simple-map-processors> Modified: ofbiz/trunk/applications/accounting/minilang/payment/PaymentMethodEvents.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/minilang/payment/PaymentMethodEvents.xml?rev=1758926&r1=1758925&r2=1758926&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/minilang/payment/PaymentMethodEvents.xml (original) +++ ofbiz/trunk/applications/accounting/minilang/payment/PaymentMethodEvents.xml Fri Sep 2 10:02:32 2016 @@ -93,4 +93,14 @@ under the License. <result-to-request result-name="paymentMethodId" request-name="paymentMethodId"/> </call-service> </simple-method> + + <!-- Check events --> + <simple-method method-name="createCheckAccount" short-description="Create Check Account for party"> + <call-map-processor xml-resource="component://accounting/minilang/payment/PaymentMapProcs.xml" + processor-name="createCheckAccount" in-map-name="parameters" out-map-name="context"/> + <check-errors/> + <call-service service-name="createCheckAccount" in-map-name="context"> + <default-message resource="AccountingUiLabels" property="AccountingCheckCreatedSuccessfully"/> + <result-to-request result-name="paymentMethodId"/></call-service> + </simple-method> </simple-methods> Modified: ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml?rev=1758926&r1=1758925&r2=1758926&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml Fri Sep 2 10:02:32 2016 @@ -138,6 +138,23 @@ under the License. <attribute name="contactMechId" type="String" mode="IN" optional="true"/> <attribute name="paymentMethodId" type="String" mode="INOUT" optional="true"/> </service> + + <service name="createCheckAccount" engine="java" + location="org.apache.ofbiz.accounting.payment.PaymentMethodServices" invoke="createCheckAccount" auth="true"> + <description>Create Check</description> + <attribute name="partyId" type="String" mode="IN" optional="true"/> + <attribute name="bankName" type="String" mode="IN" optional="false"/> + <attribute name="paymentMethodTypeId" type="String" mode="IN" optional="false"/> + <attribute name="description" type="String" mode="IN" optional="true"/> + <attribute name="routingNumber" type="String" mode="IN" optional="true"/> + <attribute name="accountType" type="String" mode="IN" optional="true"/> + <attribute name="accountNumber" type="String" mode="IN" optional="true"/> + <attribute name="nameOnAccount" type="String" mode="IN" optional="false"/> + <attribute name="companyNameOnAccount" type="String" mode="IN" optional="true"/> + <attribute name="contactMechId" type="String" mode="IN" optional="true"/> + <attribute name="paymentMethodId" type="String" mode="INOUT" optional="true"/> + </service> + <service name="createEftAccountAndAddress" engine="group" location="createEftAccountAndAddress" invoke="" auth="true"> <description>Creates an EftAccount and PostalAddress</description> <attribute name="contactMechId" type="String" mode="INOUT" optional="true"/> Modified: ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java?rev=1758926&r1=1758925&r2=1758926&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java (original) +++ ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java Fri Sep 2 10:02:32 2016 @@ -907,4 +907,88 @@ public class PaymentMethodServices { result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); return result; } + public static Map<String, Object> createCheckAccount(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = new HashMap<String, Object>(); + Delegator delegator = ctx.getDelegator(); + Security security = ctx.getSecurity(); + GenericValue userLogin = (GenericValue) context.get("userLogin"); + Locale locale = (Locale) context.get("locale"); + Timestamp now = UtilDateTime.nowTimestamp(); + + String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_CREATE", "ACCOUNTING", "_CREATE"); + if (result.size() > 0) return result; + + List<GenericValue> toBeStored = new LinkedList<GenericValue>(); + GenericValue newPm = delegator.makeValue("PaymentMethod"); + toBeStored.add(newPm); + + GenericValue newCa = delegator.makeValue("CheckAccount"); + + toBeStored.add(newCa); + String newPmId = (String) context.get("paymentMethodId"); + if (UtilValidate.isEmpty(newPmId)) { + try { + newPmId = delegator.getNextSeqId("PaymentMethod"); + } catch (IllegalArgumentException e) { + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "AccountingCheckNotAdded", locale)); + } + } + + newPm.set("partyId", partyId); + newPm.set("description",context.get("description")); + newPm.set("paymentMethodTypeId", context.get("paymentMethodTypeId")); + newPm.set("fromDate", now); + newPm.set("paymentMethodId", newPmId); + + newCa.set("bankName", context.get("bankName")); + newCa.set("routingNumber", context.get("routingNumber")); + newCa.set("accountType", context.get("accountType")); + newCa.set("accountNumber", context.get("accountNumber")); + newCa.set("nameOnAccount", context.get("nameOnAccount")); + newCa.set("companyNameOnAccount", context.get("companyNameOnAccount")); + newCa.set("contactMechId", context.get("contactMechId")); + newCa.set("paymentMethodId", newPmId); + + GenericValue newPartyContactMechPurpose = null; + String contactMechId = (String) context.get("contactMechId"); + + if (UtilValidate.isNotEmpty(contactMechId)) { + // add a PartyContactMechPurpose of BILLING_LOCATION if necessary + String contactMechPurposeTypeId = "BILLING_LOCATION"; + + GenericValue tempVal = null; + try { + List<GenericValue> allPCWPs = EntityQuery.use(delegator).from("PartyContactWithPurpose") + .where("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId).queryList(); + allPCWPs = EntityUtil.filterByDate(allPCWPs, now, "contactFromDate", "contactThruDate", true); + allPCWPs = EntityUtil.filterByDate(allPCWPs, now, "purposeFromDate", "purposeThruDate", true); + + tempVal = EntityUtil.getFirst(allPCWPs); + } catch (GenericEntityException e) { + Debug.logWarning(e.getMessage(), module); + tempVal = null; + } + + if (tempVal == null) { + // no value found, create a new one + newPartyContactMechPurpose = delegator.makeValue("PartyContactMechPurpose", + UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, + "contactMechPurposeTypeId", contactMechPurposeTypeId, "fromDate", now)); + } + } + + if (newPartyContactMechPurpose != null) + toBeStored.add(newPartyContactMechPurpose); + + try { + delegator.storeAll(toBeStored); + } catch (GenericEntityException e) { + Debug.logWarning(e.getMessage(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "AccountingCheckNotAdded", UtilMisc.toMap("errorString", e.getMessage()), locale)); + } + + result.put("paymentMethodId", newPm.getString("paymentMethodId")); + result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); + return result; + } } Modified: ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java?rev=1758926&r1=1758925&r2=1758926&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java (original) +++ ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java Fri Sep 2 10:02:32 2016 @@ -79,6 +79,15 @@ public final class PaymentWorker { } else if ("EFT_ACCOUNT".equals(paymentMethod.getString("paymentMethodTypeId"))) { GenericValue eftAccount = paymentMethod.getRelatedOne("EftAccount", false); if (eftAccount != null) valueMap.put("eftAccount", eftAccount); + } else if ("COMPANY_CHECK".equals(paymentMethod.getString("paymentMethodTypeId"))) { + GenericValue companyCheckAccount = paymentMethod.getRelatedOne("CheckAccount", false); + if (companyCheckAccount != null) valueMap.put("companyCheckAccount", companyCheckAccount); + } else if ("PERSONAL_CHECK".equals(paymentMethod.getString("paymentMethodTypeId"))) { + GenericValue personalCheckAccount = paymentMethod.getRelatedOne("CheckAccount", false); + if (personalCheckAccount != null) valueMap.put("personalCheckAccount", personalCheckAccount); + } else if ("CERTIFIED_CHECK".equals(paymentMethod.getString("paymentMethodTypeId"))) { + GenericValue certifiedCheckAccount = paymentMethod.getRelatedOne("CheckAccount", false); + if (certifiedCheckAccount != null) valueMap.put("certifiedCheckAccount", certifiedCheckAccount); } } } catch (GenericEntityException e) { Modified: ofbiz/trunk/applications/party/template/party/profileblocks/PaymentMethods.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/template/party/profileblocks/PaymentMethods.ftl?rev=1758926&r1=1758925&r2=1758926&view=diff ============================================================================== --- ofbiz/trunk/applications/party/template/party/profileblocks/PaymentMethods.ftl (original) +++ ofbiz/trunk/applications/party/template/party/profileblocks/PaymentMethods.ftl Fri Sep 2 10:02:32 2016 @@ -43,6 +43,7 @@ under the License. <li><a href="<@ofbizUrl>editgiftcard?partyId=${partyId}</@ofbizUrl>">${uiLabelMap.AccountingCreateGiftCard}</a></li> <li><a href="<@ofbizUrl>editcreditcard?partyId=${partyId}</@ofbizUrl>">${uiLabelMap.AccountingCreateCreditCard}</a></li> <li><a href="<@ofbizUrl>EditBillingAccount?partyId=${partyId}</@ofbizUrl>">${uiLabelMap.AccountingCreateBillingAccount}</a></li> + <li><a href="<@ofbizUrl>AddCheckAccount?partyId=${partyId}</@ofbizUrl>">${uiLabelMap.AccountingAddCheckAccount}</a></li> </#if> </ul> <br class="clear" /> @@ -126,11 +127,14 @@ under the License. </#if> <#-- </td> --> <#elseif "COMPANY_CHECK" == paymentMethod.paymentMethodTypeId> + <#assign checkAccount = paymentMethodValueMap.companyCheckAccount> <td class="label" valign="top"> <#-- TODO: Convert hard-coded text to UI label properties --> Company Check </td> <td> + ${checkAccount.nameOnAccount} - <#if checkAccount.bankName?has_content>${uiLabelMap.PartyBank}: ${checkAccount.bankName}</#if> + <#if checkAccount.accountNumber?has_content>${uiLabelMap.PartyAccount} #: ${checkAccount.accountNumber}</#if> <#if paymentMethod.description?has_content>(${paymentMethod.description})</#if> <#if paymentMethod.glAccountId?has_content>(for GL Account ${paymentMethod.glAccountId})</#if> <#if paymentMethod.fromDate?has_content>(${uiLabelMap.CommonUpdated}: ${paymentMethod.fromDate!})</#if> @@ -139,6 +143,38 @@ under the License. <td class="button-col"> <#-- </td> --> + <#elseif "PERSONAL_CHECK" == paymentMethod.paymentMethodTypeId> + <#assign checkAccount = paymentMethodValueMap.personalCheckAccount> + <td class="label" valign="top"> + Personal Check + </td> + <td> + ${checkAccount.nameOnAccount} - <#if checkAccount.bankName?has_content>${uiLabelMap.PartyBank}: ${checkAccount.bankName}</#if> + <#if checkAccount.accountNumber?has_content>${uiLabelMap.PartyAccount} #: ${checkAccount.accountNumber}</#if> + <#if paymentMethod.description?has_content>(${paymentMethod.description})</#if> + <#if paymentMethod.glAccountId?has_content>(for GL Account ${paymentMethod.glAccountId})</#if> + <#if paymentMethod.fromDate?has_content>(${uiLabelMap.CommonUpdated}: ${paymentMethod.fromDate!})</#if> + <#if paymentMethod.thruDate?has_content>(${uiLabelMap.PartyContactEffectiveThru}: ${paymentMethod.thruDate.toString()}</#if> + </td> + <td class="button-col"> + + <#-- </td> --> + <#elseif "CERTIFIED_CHECK" == paymentMethod.paymentMethodTypeId> + <#assign checkAccount = paymentMethodValueMap.certifiedCheckAccount> + <td class="label" valign="top"> + Certified Check + </td> + <td> + ${checkAccount.nameOnAccount} - <#if checkAccount.bankName?has_content>${uiLabelMap.PartyBank}: ${checkAccount.bankName}</#if> + <#if checkAccount.accountNumber?has_content>${uiLabelMap.PartyAccount} #: ${checkAccount.accountNumber}</#if> + <#if paymentMethod.description?has_content>(${paymentMethod.description})</#if> + <#if paymentMethod.glAccountId?has_content>(for GL Account ${paymentMethod.glAccountId})</#if> + <#if paymentMethod.fromDate?has_content>(${uiLabelMap.CommonUpdated}: ${paymentMethod.fromDate!})</#if> + <#if paymentMethod.thruDate?has_content>(${uiLabelMap.PartyContactEffectiveThru}: ${paymentMethod.thruDate.toString()}</#if> + </td> + <td class="button-col"> + + <#-- </td> --> <#else> <td class="button-col"> Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml?rev=1758926&r1=1758925&r2=1758926&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml Fri Sep 2 10:02:32 2016 @@ -306,6 +306,13 @@ under the License. <response name="error" type="view" value="editeftaccount"/> </request-map> + <request-map uri="AddCheckAccount"><security https="true" auth="true"/><response name="success" type="view" value="AddCheckAccount"/></request-map> + <request-map uri="createCheckForParty"> + <security https="true" auth="true"/> + <event type="simple" path="component://accounting/minilang/payment/PaymentMethodEvents.xml" invoke="createCheckAccount"/> + <response name="success" type="view" value="AddCheckAccount"/> + <response name="error" type="view" value="AddCheckAccount"/> + </request-map> <request-map uri="editAvsOverride"><security https="true" auth="true"/><response name="success" type="view" value="editavsoverride"/></request-map> <request-map uri="updateAvsOverride"> <security https="true" auth="true"/> @@ -1297,6 +1304,7 @@ under the License. <view-map name="editgiftcard" type="screen" page="component://party/widget/partymgr/PaymentMethodScreens.xml#editgiftcard"/> <view-map name="editeftaccount" type="screen" page="component://party/widget/partymgr/PaymentMethodScreens.xml#editeftaccount"/> <view-map name="editavsoverride" type="screen" page="component://party/widget/partymgr/PaymentMethodScreens.xml#editavsoverride"/> + <view-map name="AddCheckAccount" type="screen" page="component://party/widget/partymgr/PaymentMethodScreens.xml#AddCheckAccount"/> <view-map name="ListCommContent" type="screen" page="component://party/widget/partymgr/CommunicationEventScreens.xml#ListCommContent"/> <view-map name="PendingCommunications" type="screen" page="component://party/widget/partymgr/CommunicationEventScreens.xml#PendingCommunications"/> Modified: ofbiz/trunk/applications/party/widget/partymgr/PaymentMethodScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PaymentMethodScreens.xml?rev=1758926&r1=1758925&r2=1758926&view=diff ============================================================================== --- ofbiz/trunk/applications/party/widget/partymgr/PaymentMethodScreens.xml (original) +++ ofbiz/trunk/applications/party/widget/partymgr/PaymentMethodScreens.xml Fri Sep 2 10:02:32 2016 @@ -117,6 +117,26 @@ under the License. </section> </screen> + <screen name="AddCheckAccount"> + <section> + <actions> + <set field="titleProperty" value="AccountingAddCheckAccount"/> + + <script location="component://party/groovyScripts/HasPartyPermissions.groovy"/> + <script location="component://party/groovyScripts/party/EditPaymentMethod.groovy"/> + </actions> + <widgets> + <decorator-screen name="PaymentMethodDecorator"> + <decorator-section name="body"> + <platform-specific> + <html><html-template location="component://party/template/party/AddCheckForParty.ftl"/></html> + </platform-specific> + </decorator-section> + </decorator-screen> + </widgets> + </section> + </screen> + <screen name="editavsoverride"> <section> <actions> |
Free forum by Nabble | Edit this page |