You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacques Le Roux <ja...@les7arts.com> on 2013/06/03 22:31:09 UTC

Re: svn commit: r1488656 - /ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/Pa ymentServices.xml

While reviewning this commit I stumbled upon similar calls to convertUom service

<call-service service-name="convertUom" in-map-name="convertUomInMap">

I noticed this TODO for others 

<!-- TODO: set the optional asOfDate input parameter -->

Should not the change below address the same concern, at least with a TODO for now?

The idea is otherwise the convertUom takes will always use <now-timestamp /> (as fallback, when asOfDate is missing). 
But in some case we would want to use the currencies rates conversion of the time the order was done, which is not necessary the time the order is paid.

Jacques


From: <ha...@apache.org>
> Author: hansbak
> Date: Sun Jun  2 09:57:32 2013
> New Revision: 1488656
> 
> URL: http://svn.apache.org/r1488656
> Log:
> create payment in home currency when order was in foreign currency
> 
> Modified:
>    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> 
> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=1488656&r1=1488655&r2=1488656&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Sun Jun  2 09:57:32 2013
> @@ -896,6 +896,7 @@ under the License.
>                 <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>             </entity-and>
>             <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
> +            <set field="organizationPartyId" from-field="orderRoleFrom.partyId"/>
>             <else>
>                <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>                     <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
> @@ -903,6 +904,7 @@ under the License.
>                     <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>                 </entity-and>
>                 <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
> +                <set field="organizationPartyId" from-field="orderRoleTo.partyId"/>
>             </else>
>         </if-compare>
>         <first-from-list entry="agreement" list="agreementList"/>
> @@ -924,10 +926,31 @@ under the License.
>         <if-empty field="parameters.effectiveDate">
>             <now-timestamp field="parameters.effectiveDate"/>
>         </if-empty>
> +        
> +        <!-- check currency and when required convert-->
> +        <set field="partyAccountingPreferencesMap.organizationPartyId" from-field="organizationPartyId"/>
> +        <call-service service-name="getPartyAccountingPreferences" in-map-name="partyAccountingPreferencesMap">
> +             <result-to-field result-name="partyAccountingPreference" field="partyAcctgPreference"/>
> +        </call-service>
> +        <if-compare-field to-field="partyAcctgPreference.baseCurrencyUomId" operator="equals" field="orderHeader.currencyUom">
> +            <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
> +            <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
> +            <else>
> +                <set field="convertUomInMap.originalValue" from-field="orderHeader.grandTotal"/>
> +                <set field="convertUomInMap.uomId" from-field="orderHeader.currencyUom"/>
> +                <set field="convertUomInMap.uomIdTo" from-field="partyAcctgPreference.baseCurrencyUomId"/>
> +                <call-service service-name="convertUom" in-map-name="convertUomInMap">
> +                    <result-to-field result-name="convertedValue" field="parameters.amount"/>
> +                </call-service>
> +                <set field="parameters.actualCurrencyAmount" from-field="orderHeader.grandTotal"/>
> +                <set field="parameters.actualCurrencyUomId" from-field="orderHeader.currencyUom"/>
> +                <set field="parameters.currencyUomId" from-field="partyAcctgPreference.baseCurrencyUomId"/>
> +                <set field="parameters.actualCurrencyUomId" from-field="orderHeader.currencyUom"/>
> +            </else>
> +        </if-compare-field>
> +        
>         <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>         <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
> -        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
> -        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>         <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>         <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>         <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
> 
>

Re: svn commit: r1488656 - /ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/Pa ymentServices.xml

Posted by Jacques Le Roux <ja...@les7arts.com>.
Makes sense, thanks for clarification Hans

Jacques

From: "Hans Bakker" <ma...@antwebsystems.com>
> Jacques,
> 
> thanks for your review, however this is a provisional purchase payment 
> which will surely be manually adjusted when the real payment comes in. 
> Not specifying a date means it will take the latest available conversion 
> which is fine.
> 
> Regards,
> Hans
> 
> On 06/04/2013 03:31 AM, Jacques Le Roux wrote:
>> While reviewning this commit I stumbled upon similar calls to convertUom service
>>
>> <call-service service-name="convertUom" in-map-name="convertUomInMap">
>>
>> I noticed this TODO for others
>>
>> <!-- TODO: set the optional asOfDate input parameter -->
>>
>> Should not the change below address the same concern, at least with a TODO for now?
>>
>> The idea is otherwise the convertUom takes will always use <now-timestamp /> (as fallback, when asOfDate is missing).
>> But in some case we would want to use the currencies rates conversion of the time the order was done, which is not necessary the time the order is paid.
>>
>> Jacques
>>
>>
>> From: <ha...@apache.org>
>>> Author: hansbak
>>> Date: Sun Jun  2 09:57:32 2013
>>> New Revision: 1488656
>>>
>>> URL: http://svn.apache.org/r1488656
>>> Log:
>>> create payment in home currency when order was in foreign currency
>>>
>>> Modified:
>>>     ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>
>>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=1488656&r1=1488655&r2=1488656&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Sun Jun  2 09:57:32 2013
>>> @@ -896,6 +896,7 @@ under the License.
>>>                  <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>>>              </entity-and>
>>>              <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>>> +            <set field="organizationPartyId" from-field="orderRoleFrom.partyId"/>
>>>              <else>
>>>                 <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>                      <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>> @@ -903,6 +904,7 @@ under the License.
>>>                      <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>>                  </entity-and>
>>>                  <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>>> +                <set field="organizationPartyId" from-field="orderRoleTo.partyId"/>
>>>              </else>
>>>          </if-compare>
>>>          <first-from-list entry="agreement" list="agreementList"/>
>>> @@ -924,10 +926,31 @@ under the License.
>>>          <if-empty field="parameters.effectiveDate">
>>>              <now-timestamp field="parameters.effectiveDate"/>
>>>          </if-empty>
>>> +
>>> +        <!-- check currency and when required convert-->
>>> +        <set field="partyAccountingPreferencesMap.organizationPartyId" from-field="organizationPartyId"/>
>>> +        <call-service service-name="getPartyAccountingPreferences" in-map-name="partyAccountingPreferencesMap">
>>> +             <result-to-field result-name="partyAccountingPreference" field="partyAcctgPreference"/>
>>> +        </call-service>
>>> +        <if-compare-field to-field="partyAcctgPreference.baseCurrencyUomId" operator="equals" field="orderHeader.currencyUom">
>>> +            <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>> +            <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>>> +            <else>
>>> +                <set field="convertUomInMap.originalValue" from-field="orderHeader.grandTotal"/>
>>> +                <set field="convertUomInMap.uomId" from-field="orderHeader.currencyUom"/>
>>> +                <set field="convertUomInMap.uomIdTo" from-field="partyAcctgPreference.baseCurrencyUomId"/>
>>> +                <call-service service-name="convertUom" in-map-name="convertUomInMap">
>>> +                    <result-to-field result-name="convertedValue" field="parameters.amount"/>
>>> +                </call-service>
>>> +                <set field="parameters.actualCurrencyAmount" from-field="orderHeader.grandTotal"/>
>>> +                <set field="parameters.actualCurrencyUomId" from-field="orderHeader.currencyUom"/>
>>> +                <set field="parameters.currencyUomId" from-field="partyAcctgPreference.baseCurrencyUomId"/>
>>> +                <set field="parameters.actualCurrencyUomId" from-field="orderHeader.currencyUom"/>
>>> +            </else>
>>> +        </if-compare-field>
>>> +
>>>          <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>          <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>>> -        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>>> -        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>>          <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>>>          <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>>          <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>>>
>>>
>

Re: svn commit: r1488656 - /ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/Pa ymentServices.xml

Posted by Hans Bakker <ma...@antwebsystems.com>.
Jacques,

thanks for your review, however this is a provisional purchase payment 
which will surely be manually adjusted when the real payment comes in. 
Not specifying a date means it will take the latest available conversion 
which is fine.

Regards,
Hans

On 06/04/2013 03:31 AM, Jacques Le Roux wrote:
> While reviewning this commit I stumbled upon similar calls to convertUom service
>
> <call-service service-name="convertUom" in-map-name="convertUomInMap">
>
> I noticed this TODO for others
>
> <!-- TODO: set the optional asOfDate input parameter -->
>
> Should not the change below address the same concern, at least with a TODO for now?
>
> The idea is otherwise the convertUom takes will always use <now-timestamp /> (as fallback, when asOfDate is missing).
> But in some case we would want to use the currencies rates conversion of the time the order was done, which is not necessary the time the order is paid.
>
> Jacques
>
>
> From: <ha...@apache.org>
>> Author: hansbak
>> Date: Sun Jun  2 09:57:32 2013
>> New Revision: 1488656
>>
>> URL: http://svn.apache.org/r1488656
>> Log:
>> create payment in home currency when order was in foreign currency
>>
>> Modified:
>>     ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>
>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=1488656&r1=1488655&r2=1488656&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Sun Jun  2 09:57:32 2013
>> @@ -896,6 +896,7 @@ under the License.
>>                  <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>>              </entity-and>
>>              <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>> +            <set field="organizationPartyId" from-field="orderRoleFrom.partyId"/>
>>              <else>
>>                 <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>                      <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>> @@ -903,6 +904,7 @@ under the License.
>>                      <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>                  </entity-and>
>>                  <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>> +                <set field="organizationPartyId" from-field="orderRoleTo.partyId"/>
>>              </else>
>>          </if-compare>
>>          <first-from-list entry="agreement" list="agreementList"/>
>> @@ -924,10 +926,31 @@ under the License.
>>          <if-empty field="parameters.effectiveDate">
>>              <now-timestamp field="parameters.effectiveDate"/>
>>          </if-empty>
>> +
>> +        <!-- check currency and when required convert-->
>> +        <set field="partyAccountingPreferencesMap.organizationPartyId" from-field="organizationPartyId"/>
>> +        <call-service service-name="getPartyAccountingPreferences" in-map-name="partyAccountingPreferencesMap">
>> +             <result-to-field result-name="partyAccountingPreference" field="partyAcctgPreference"/>
>> +        </call-service>
>> +        <if-compare-field to-field="partyAcctgPreference.baseCurrencyUomId" operator="equals" field="orderHeader.currencyUom">
>> +            <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>> +            <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>> +            <else>
>> +                <set field="convertUomInMap.originalValue" from-field="orderHeader.grandTotal"/>
>> +                <set field="convertUomInMap.uomId" from-field="orderHeader.currencyUom"/>
>> +                <set field="convertUomInMap.uomIdTo" from-field="partyAcctgPreference.baseCurrencyUomId"/>
>> +                <call-service service-name="convertUom" in-map-name="convertUomInMap">
>> +                    <result-to-field result-name="convertedValue" field="parameters.amount"/>
>> +                </call-service>
>> +                <set field="parameters.actualCurrencyAmount" from-field="orderHeader.grandTotal"/>
>> +                <set field="parameters.actualCurrencyUomId" from-field="orderHeader.currencyUom"/>
>> +                <set field="parameters.currencyUomId" from-field="partyAcctgPreference.baseCurrencyUomId"/>
>> +                <set field="parameters.actualCurrencyUomId" from-field="orderHeader.currencyUom"/>
>> +            </else>
>> +        </if-compare-field>
>> +
>>          <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>          <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>> -        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>> -        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>          <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>>          <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>          <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>>
>>