Enhanced the account type/id mapping service to support the upcoming posting services for payment, payment applications and invoices.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@602841 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacopo Cappellato
2007-12-10 10:20:07 +00:00
parent 66fd07b20b
commit bcac45ecfb
2 changed files with 111 additions and 21 deletions
@@ -310,21 +310,17 @@ under the License.
<!-- if the glAccountId is empty, but we have a glAccountTypeId, then we will determine the
correct glAccountId from the gl setup settings -->
<if-empty field-name="acctgTransEntry.glAccountId">
<if-not-empty field-name="acctgTransEntry.glAccountTypeId">
<clear-field field-name="getGlAccountFromAccountTypeInMap"/>
<!-- if this is an inventory variance pass the glAccountTypeId as the varianceReasonId, it will be used to lookup the account id in the VarianceReasonGlAccount entity -->
<if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="ITEM_VARIANCE_ACCTG_">
<set field="getGlAccountFromAccountTypeInMap.varianceReasonId" from-field="acctgTransEntry.glAccountTypeId"/>
</if-compare>
<if-not-empty field-name="acctgTransEntry.productId">
<set field="getGlAccountFromAccountTypeInMap.productId" from-field="acctgTransEntry.productId"/>
</if-not-empty>
<set field="getGlAccountFromAccountTypeInMap.glAccountTypeId" from-field="acctgTransEntry.glAccountTypeId"/>
<set field="getGlAccountFromAccountTypeInMap.organizationPartyId" from-field="acctgTransEntry.organizationPartyId"/>
<call-service service-name="getGlAccountFromAccountType" in-map-name="getGlAccountFromAccountTypeInMap">
<result-to-field result-name="glAccountId" field-name="acctgTransEntry.glAccountId"/>
</call-service>
</if-not-empty>
<clear-field field-name="getGlAccountFromAccountTypeInMap"/>
<set field="getGlAccountFromAccountTypeInMap.organizationPartyId" from-field="acctgTransEntry.organizationPartyId"/>
<set field="getGlAccountFromAccountTypeInMap.acctgTransTypeId" from-field="parameters.acctgTransTypeId"/>
<set field="getGlAccountFromAccountTypeInMap.glAccountTypeId" from-field="acctgTransEntry.glAccountTypeId"/>
<set field="getGlAccountFromAccountTypeInMap.debitCreditFlag" from-field="acctgTransEntry.debitCreditFlag"/>
<set field="getGlAccountFromAccountTypeInMap.productId" from-field="acctgTransEntry.productId"/>
<set field="getGlAccountFromAccountTypeInMap.invoiceId" from-field="parameters.invoiceId"/>
<set field="getGlAccountFromAccountTypeInMap.paymentId" from-field="parameters.paymentId"/>
<call-service service-name="getGlAccountFromAccountType" in-map-name="getGlAccountFromAccountTypeInMap">
<result-to-field result-name="glAccountId" field-name="acctgTransEntry.glAccountId"/>
</call-service>
</if-empty>
<if-empty field-name="acctgTransEntry.origAmount">
<set field="acctgTransEntry.origAmount" from-field="acctgTransEntry.amount"/>
@@ -382,17 +378,63 @@ under the License.
<!-- Miscellaneous services for product and inventory -->
<simple-method method-name="getGlAccountFromAccountType" short-description="Look up a GlAccountId from GlAccountTypeId">
<if-not-empty field-name="parameters.varianceReasonId">
<simple-method method-name="getGlAccountFromAccountType" short-description="Look up a GlAccountId from GlAccountTypeId">
<!-- if this is an inventory variance then the glAccountTypeId contains the varianceReasonId; the value is used to lookup the account id in the VarianceReasonGlAccount entity -->
<if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="ITEM_VARIANCE_ACCTG_">
<entity-one entity-name="VarianceReasonGlAccount" value-name="varianceReasonGlAccount">
<field-map field-name="organizationPartyId" env-name="parameters.organizationPartyId"/>
<field-map field-name="varianceReasonId" env-name="parameters.varianceReasonId"/>
<field-map field-name="varianceReasonId" env-name="parameters.glAccountTypeId"/>
</entity-one>
<if-not-empty field-name="varianceReasonGlAccount.glAccountId">
<field-to-result field-name="varianceReasonGlAccount.glAccountId" result-name="glAccountId"/>
</if-not-empty>
<return/>
</if-not-empty>
</if-compare>
<if>
<condition>
<and>
<or>
<and>
<if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="OUTGOING_PAYMENT"/>
<if-compare field-name="parameters.debitCreditFlag" operator="equals" value="C"/>
</and>
<and>
<if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="INCOMING_PAYMENT"/>
<if-compare field-name="parameters.debitCreditFlag" operator="equals" value="D"/>
</and>
</or>
<not><if-empty field-name="parameters.paymentId"/></not>
</and>
</condition>
<then>
<entity-one entity-name="Payment" value-name="payment"/>
<get-related-one value-name="payment" relation-name="PaymentMethod" to-value-name="paymentMethod"/>
<if-not-empty field-name="paymentMethod.glAccountId">
<field-to-result field-name="paymentMethod.glAccountId" result-name="glAccountId"/>
<return/>
</if-not-empty>
<if-compare field-name="payment.paymentMethodTypeId" operator="equals" value="CREDIT_CARD">
<get-related-one value-name="payment" relation-name="CreditCard" to-value-name="creditCard"/>
<entity-one entity-name="CreditCardTypeGlAccount" value-name="creditCardTypeGlAccount">
<field-map field-name="cardType" env-name="creditCard.cardType"/>
<field-map field-name="organizationPartyId" env-name="parameters.organizationPartyId"/>
</entity-one>
<if-not-empty field-name="creditCardTypeGlAccount.glAccountId">
<field-to-result field-name="creditCardTypeGlAccount.glAccountId" result-name="glAccountId"/>
<return/>
</if-not-empty>
</if-compare>
<entity-one entity-name="PaymentMethodTypeGlAccount" value-name="paymentMethodTypeGlAccount">
<field-map field-name="paymentMethodTypeId" env-name="payment.paymentMethodTypeId"/>
<field-map field-name="organizationPartyId" env-name="parameters.organizationPartyId"/>
</entity-one>
<if-not-empty field-name="paymentMethodTypeGlAccount.glAccountId">
<field-to-result field-name="paymentMethodTypeGlAccount.glAccountId" result-name="glAccountId"/>
<return/>
</if-not-empty>
<return/>
</then>
</if>
<if-not-empty field-name="parameters.productId">
<entity-one entity-name="ProductGlAccount" value-name="lookedUpValue" use-cache="true"/>
<!-- if nothing found look if the parameters.productId is member of any ProductCategory in ProductCategoryGlAccount -->
@@ -414,6 +456,52 @@ under the License.
</iterate>
</if-empty>
</if-not-empty>
<if>
<condition>
<and>
<or>
<and>
<if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="PURCHASE_INVOICE"/>
<if-compare field-name="parameters.debitCreditFlag" operator="equals" value="D"/>
</and>
<and>
<if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="SALES_INVOICE"/>
<if-compare field-name="parameters.debitCreditFlag" operator="equals" value="C"/>
</and>
</or>
<not><if-empty field-name="parameters.invoiceId"/></not>
<not><if-empty field-name="parameters.acctgTransTypeId"/></not>
</and>
</condition>
<then>
<if-not-empty field-name="parameters.productId">
<entity-one entity-name="GlAccountTypeDefault" value-name="glAccountTypeDefault" use-cache="true">
<field-map field-name="organizationPartyId" env-name="parameters.organizationPartyId"/>
<field-map field-name="glAccountTypeId" value="SALES_ACCOUNT"/>
</entity-one>
<if-not-empty field-name="glAccountTypeDefault.glAccountId">
<field-to-result field-name="glAccountTypeDefault.glAccountId" result-name="glAccountId"/>
<return/>
</if-not-empty>
</if-not-empty>
<entity-one entity-name="InvoiceItemTypeGlAccount" value-name="invoiceItemTypeGlAccount">
<field-map field-name="invoiceItemTypeId" env-name="parameters.acctgTransTypeId"/>
<field-map field-name="organizationPartyId" env-name="parameters.organizationPartyId"/>
</entity-one>
<if-not-empty field-name="invoiceItemTypeGlAccount.glAccountId">
<field-to-result field-name="invoiceItemTypeGlAccount.glAccountId" result-name="glAccountId"/>
<return/>
</if-not-empty>
<entity-one entity-name="InvoiceItemType" value-name="invoiceItemType">
<field-map field-name="invoiceItemTypeId" env-name="parameters.acctgTransTypeId"/>
</entity-one>
<if-not-empty field-name="invoiceItemType.defaultGlAccountId">
<field-to-result field-name="invoiceItemType.defaultGlAccountId" result-name="glAccountId"/>
<return/>
</if-not-empty>
<return/>
</then>
</if>
<!-- if nothing found or if no such parameters were passed (lookedUpValue empty in both cases), try GlAccountTypeDefault -->
<if-empty field-name="lookedUpValue.glAccountId">
@@ -286,9 +286,11 @@ under the License.
<description>Look up a GlAccountId first in ProductGlAccount by productId and productGlAccountTypeId, if not found,
then in organizationPartyId and glAccountTypeId </description>
<attribute name="organizationPartyId" type="String" mode="IN" optional="false"/>
<attribute name="glAccountTypeId" type="String" mode="IN" optional="false"/>
<attribute name="glAccountTypeId" type="String" mode="IN" optional="true"/>
<attribute name="acctgTransTypeId" type="String" mode="IN" optional="true"/>
<attribute name="debitCreditFlag" type="String" mode="IN" optional="true"/>
<attribute name="productId" type="String" mode="IN" optional="true"/>
<attribute name="varianceReasonId" type="String" mode="IN" optional="true"/>
<attribute name="paymentId" type="String" mode="IN" optional="true"/>
<attribute name="glAccountId" type="String" mode="OUT" optional="true"/>
</service>
<service name="getInventoryItemOwner" default-entity-name="InventoryItem" engine="simple"