Author: jaz
Date: Thu May 17 20:45:39 2007 New Revision: 539246 URL: http://svn.apache.org/viewvc?view=rev&rev=539246 Log: refactored service credit service so it can be used for any type of financial account; the old service def remains; and new definition exists Modified: ofbiz/trunk/applications/accounting/servicedef/services_finaccount.xml ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountServices.java Modified: ofbiz/trunk/applications/accounting/servicedef/services_finaccount.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_finaccount.xml?view=diff&rev=539246&r1=539245&r2=539246 ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_finaccount.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_finaccount.xml Thu May 17 20:45:39 2007 @@ -179,12 +179,26 @@ <!-- service credit account w/ transaction --> <service name="createServiceCredit" engine="java" - location="org.ofbiz.accounting.finaccount.FinAccountServices" invoke="createServiceCredit" auth="true"> - <attribute name="finAccountId" type="String" mode="INOUT" optional="true"/> + location="org.ofbiz.accounting.finaccount.FinAccountServices" invoke="createAccountAndCredit" auth="true"> + <attribute name="finAccountId" type="String" mode="INOUT" optional="true"/> + <attribute name="finAccountName" type="String" mode="IN" optional="true"/> <attribute name="partyId" type="String" mode="IN" optional="false"/> <attribute name="amount" type="Double" mode="IN" optional="false"/> <attribute name="currencyUomId" type="String" mode="IN" optional="true"/> <attribute name="productStoreId" type="String" mode="IN" optional="true"/> + <attribute name="finAccountTypeId" type="String" mode="IN" default-value="SVCCRED_ACCOUNT"/> + </service> + + <!-- financial account w/ transaction --> + <service name="createFinAccountAndCredit" engine="java" + location="org.ofbiz.accounting.finaccount.FinAccountServices" invoke="createAccountAndCredit" auth="true"> + <attribute name="finAccountId" type="String" mode="INOUT" optional="true"/> + <attribute name="finAccountName" type="String" mode="IN" optional="true"/> + <attribute name="partyId" type="String" mode="IN" optional="false"/> + <attribute name="amount" type="Double" mode="IN" optional="false"/> + <attribute name="currencyUomId" type="String" mode="IN" optional="true"/> + <attribute name="productStoreId" type="String" mode="IN" optional="true"/> + <attribute name="finAccountTypeId" type="String" mode="IN" optional="false"/> </service> <!-- balance account created from product purchase --> Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountServices.java?view=diff&rev=539246&r1=539245&r2=539246 ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountServices.java Thu May 17 20:45:39 2007 @@ -47,16 +47,30 @@ public static final String module = FinAccountServices.class.getName(); - public static Map createServiceCredit(DispatchContext dctx, Map context) { + public static Map createAccountAndCredit(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); + String finAccountTypeId = (String) context.get("finAccountTypeId"); + String accountName = (String) context.get("accountName"); String finAccountId = (String) context.get("finAccountId"); + // check the type + if (finAccountTypeId == null) { + finAccountTypeId = "SVCCRED_ACCOUNT"; + } + if (accountName == null) { + if ("SVCCRED_ACCOUNT".equals(finAccountTypeId)) { + accountName = "Customer Service Credit Account"; + } else { + accountName = "Financial Account"; + } + } + GenericValue userLogin = (GenericValue) context.get("userLogin"); try { // find the most recent (active) service credit account for the specified party String partyId = (String) context.get("partyId"); - Map lookupMap = UtilMisc.toMap("finAccountTypeId", "SVCCRED_ACCOUNT", "ownerPartyId", partyId); + Map lookupMap = UtilMisc.toMap("finAccountTypeId", finAccountTypeId, "ownerPartyId", partyId); // if a productStoreId is present, restrict the accounts returned using the store's payToPartyId String productStoreId = (String) context.get("productStoreId"); @@ -91,8 +105,8 @@ // automatically set the parameters ModelService createAccountService = dctx.getModelService(createAccountServiceName); Map createAccountContext = createAccountService.makeValid(context, ModelService.IN_PARAM); - createAccountContext.put("finAccountTypeId", "SVCCRED_ACCOUNT"); - createAccountContext.put("finAccountName", "Customer Service Credit Account"); + createAccountContext.put("finAccountTypeId", finAccountTypeId); + createAccountContext.put("finAccountName", accountName); createAccountContext.put("ownerPartyId", partyId); createAccountContext.put("userLogin", userLogin); |
Free forum by Nabble | Edit this page |