Re: svn commit: r570894 - in /ofbiz/trunk/applications/accounting: config/arithmetic.properties script/org/ofbiz/accounting/ledger/AcctgTransServices.xml script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/services_ledger.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r570894 - in /ofbiz/trunk/applications/accounting: config/arithmetic.properties script/org/ofbiz/accounting/ledger/AcctgTransServices.xml script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/services_ledger.xml

Jacques Le Roux
Administrator
I wonder if we should not back port this in release. There are changes but mostly it's a fix.

WDYT ?

Jacques

> Author: sichen
> Date: Wed Aug 29 11:39:40 2007
> New Revision: 570894
>
> URL: http://svn.apache.org/viewvc?rev=570894&view=rev
> Log:
> Fix rounding issues in general ledger posting routines because they did not have configurable BigDecimal rounding properties.
>
> Modified:
>     ofbiz/trunk/applications/accounting/config/arithmetic.properties
>     ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml
>     ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
>     ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml
>
> Modified: ofbiz/trunk/applications/accounting/config/arithmetic.properties
> URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/arithmetic.properties?rev=570894&r1=570893&r2=570894&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/accounting/config/arithmetic.properties (original)
> +++ ofbiz/trunk/applications/accounting/config/arithmetic.properties Wed Aug 29 11:39:40 2007
> @@ -20,6 +20,10 @@
>  # Arithmetic properties for configuring BigDecimal calculations
>  #
>
> +# These should correspond to the convention in minilang which is different than that for BigDecimal in Java.  See
simple-methods.xsd
> +ledger.decimals = 2
> +ledger.rounding = HalfUp
> +
>  # For setting decimal precision and rounding method of operations related to invoices
>  invoice.decimals = 2
>  invoice.rounding = ROUND_HALF_UP
>
> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml
> URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml?rev=570894&r1=570893&r2=570894&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml (original)
> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml Wed Aug 29 11:39:40 2007
> @@ -97,17 +97,22 @@
>      <simple-method method-name="calculateAcctgTransTrialBalance" short-description="Calculate Trial Balance for a AcctgTrans">
>          <check-permission permission="ACCOUNTING" action="_ATX_CREATE"><fail-message message="Security Error: to run
calculateAcctgTransTrialBalance you must have the ACCOUNTING_ATX_CREATE or ACCOUNTING_ADMIN permission"/></check-permission>

>          <check-errors/>
> -
> +
> +        <property-to-field resource="arithmetic" property="ledger.decimals" field-name="ledgerDecimals"/>
> +        <property-to-field resource="arithmetic" property="ledger.rounding" field-name="ledgerRounding"/>
> +
> +        <log level="info" message="Using ledger decimals [${ledgerDecimals}] and rounding [${ledgerRounding}]"/>
> +
>          <!-- get all AcctgTransEntry for this trans, for each if debit add to debits total if credit add to credits total -->
>          <entity-condition entity-name="AcctgTransEntry" list-name="acctgTransEntryList">
>              <condition-expr field-name="acctgTransId" env-name="parameters.acctgTransId"/>
>              <order-by field-name="acctgTransEntrySeqId"/>
>          </entity-condition>
> -        <calculate field-name="debitTotal" type="Double"><number value="0"/></calculate>
> -        <calculate field-name="creditTotal" type="Double"><number value="0"/></calculate>
> +        <calculate field-name="debitTotal" type="BigDecimal"><number value="0"/></calculate>
> +        <calculate field-name="creditTotal" type="BigDecimal"><number value="0"/></calculate>
>          <iterate entry-name="acctgTransEntry" list-name="acctgTransEntryList">
>              <if-compare field-name="debitCreditFlag" map-name="acctgTransEntry" operator="equals" value="D">
> -               <calculate field-name="debitTotal" type="Double">
> +               <calculate field-name="debitTotal" type="BigDecimal" decimal-scale="${ledgerDecimals}"
rounding-mode="${ledgerRounding}">
>                          <calcop operator="add">
>                              <calcop operator="get" field-name="debitTotal"/>
>                              <calcop operator="get" field-name="acctgTransEntry.amount"/>
> @@ -115,7 +120,7 @@
>                 </calculate>
>              <else>
>                  <if-compare field-name="debitCreditFlag" map-name="acctgTransEntry" operator="equals" value="C">
> -                    <calculate field-name="creditTotal" type="Double">
> +                    <calculate field-name="creditTotal" type="BigDecimal" decimal-scale="${ledgerDecimals}"
rounding-mode="${ledgerRounding}">
>                          <calcop operator="add">
>                              <calcop operator="get" field-name="creditTotal"/>
>                              <calcop operator="get" field-name="acctgTransEntry.amount"/>
> @@ -134,10 +139,10 @@
>          <check-errors/>
>
>          <!-- should now have the debitTotal and creditTotal, calculate the debitCreditDifference -->
> -        <calculate field-name="debitCreditDifference">
> +        <calculate field-name="debitCreditDifference" type="BigDecimal"  decimal-scale="${ledgerDecimals}"
rounding-mode="${ledgerRounding}">

>              <calcop operator="add">
> -                <calcop operator="get" field-name="debitTotal"/>
> -                <calcop operator="negative" field-name="creditTotal"/>
> +                <calcop operator="get" field-name="debitTotal" type="BigDecimal"/>
> +                <calcop operator="negative" field-name="creditTotal" type="BigDecimal"/>
>              </calcop>
>          </calculate>
>
>
> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
> URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml?rev=570894&r1=570893&r2=570894&view=diff

> ==============================================================================
> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml (original)
> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml Wed Aug 29 11:39:40 2007
> @@ -297,8 +297,14 @@
>
>      <!-- ========== GL Posting Services ========== -->
>      <simple-method method-name="createAcctgTransAndEntries" short-description="Verifies and posts a set of AcctgTransEntries">
> +        <!-- retrieve ledger rounding properties -->
> +        <property-to-field resource="arithmetic" property="ledger.decimals" field-name="ledgerDecimals"/>
> +        <property-to-field resource="arithmetic" property="ledger.rounding" field-name="ledgerRounding"/>
> +        <log level="info" message="Using ledger decimals [${ledgerDecimals}] and rounding [${ledgerRounding}]"/>
> +
>          <!-- first loop through and make sure all the entries are valid  -->
>          <iterate list-name="parameters.acctgTransEntries" entry-name="acctgTransEntry">
> +            <log level="info" message="${acctgTransEntry}"/>
>              <!-- the organization party must be an internal organization -->
>              <entity-one entity-name="PartyRole" value-name="partyRole" use-cache="true" auto-field-map="false">
>                  <field-map field-name="partyId" env-name="acctgTransEntry.organizationPartyId"/>
> @@ -310,23 +316,23 @@
>              </if-empty>
>              <!-- add up debits and credits -->
>              <if-compare field-name="acctgTransEntry.debitCreditFlag" operator="equals" value="D">
> -                <calculate field-name="debitTotal">
> +                <calculate field-name="debitTotal" decimal-scale="${ledgerDecimals}" rounding-mode="${ledgerRounding}">
>                      <calcop operator="get" field-name="acctgTransEntry.amount"/>
>                      <calcop operator="get" field-name="debitTotal"/>
>                  </calculate>
>              </if-compare>
>              <if-compare field-name="acctgTransEntry.debitCreditFlag" operator="equals" value="C">
> -                <calculate field-name="creditTotal">
> +                <calculate field-name="creditTotal" decimal-scale="${ledgerDecimals}" rounding-mode="${ledgerRounding}">
>                      <calcop operator="get" field-name="acctgTransEntry.amount"/>
>                      <calcop operator="get" field-name="creditTotal"/>
>                  </calculate>
>              </if-compare>
>          </iterate>
> -        <calculate field-name="debitCreditDifference">
> +        <calculate field-name="debitCreditDifference" decimal-scale="${ledgerDecimals}" rounding-mode="${ledgerRounding}">
>              <calcop operator="get" field-name="debitTotal"/>
>              <calcop operator="negative" field-name="creditTotal"/>
>          </calculate>
> -
> +        <!-- <log level="info" message="In createAcctgTransAndEntries: debitTotal = [${debitTotal}] creditTotal=[${creditTotal}]
debitCreditDifference=[${debitCreditDifference}]"/> -->
>          <!-- if the debit and credit totals do not balance, return an error -->
>          <if-compare field-name="debitCreditDifference" operator="greater-equals" value="0.000001" type="Double">
>              <add-error><fail-property resource="AccountingUiLabels" property="AccountingDebitCreditMustEqual"/></add-error>
>
> Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml
> URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=570894&r1=570893&r2=570894&view=diff

> ==============================================================================
> --- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original)
> +++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Wed Aug 29 11:39:40 2007
> @@ -263,9 +263,9 @@
>              location="org/ofbiz/accounting/ledger/AcctgTransServices.xml" invoke="calculateAcctgTransTrialBalance" auth="true">
>          <description>Calculate Trial Balance for a AcctgTrans</description>
>          <auto-attributes include="pk" mode="IN" optional="false"/>
> -        <attribute name="debitTotal" type="Double" mode="OUT" optional="false"/>
> -        <attribute name="creditTotal" type="Double" mode="OUT" optional="false"/>
> -        <attribute name="debitCreditDifference" type="Double" mode="OUT" optional="false"/>
> +        <attribute name="debitTotal" type="BigDecimal" mode="OUT" optional="false"/>
> +        <attribute name="creditTotal" type="BigDecimal" mode="OUT" optional="false"/>
> +        <attribute name="debitCreditDifference" type="BigDecimal" mode="OUT" optional="false"/>
>      </service>
>      <service name="postAcctgTrans" default-entity-name="AcctgTrans" engine="simple"
>              location="org/ofbiz/accounting/ledger/AcctgTransServices.xml" invoke="postAcctgTrans" auth="true"
>