Merged from trunk up to r927237 in prep for merging into trunk
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/branches/multitenant20100310@927238 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/applications/accounting/data/AccountingTypeData.xml b/applications/accounting/data/AccountingTypeData.xml
index cfec3bb..b0d3439 100644
--- a/applications/accounting/data/AccountingTypeData.xml
+++ b/applications/accounting/data/AccountingTypeData.xml
@@ -955,6 +955,7 @@
<Enumeration description="LIFO" enumCode="LIFO" enumId="COGS_LIFO" sequenceId="01" enumTypeId="COGS_METHODS"/>
<Enumeration description="FIFO" enumCode="FIFO" enumId="COGS_FIFO" sequenceId="02" enumTypeId="COGS_METHODS"/>
<Enumeration description="Average Cost" enumCode="AVG_COST" enumId="COGS_AVG_COST" sequenceId="03" enumTypeId="COGS_METHODS"/>
+ <Enumeration description="Inventory Item Cost" enumCode="INV_COST" enumId="COGS_INV_COST" sequenceId="04" enumTypeId="COGS_METHODS"/>
<!-- inventory sequencing mode for accounting preferences -->
<EnumerationType description="Invoice Sequence Mode" enumTypeId="INVOICE_SEQMD" hasTable="N" parentTypeId=""/>
diff --git a/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml b/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
index 24568cc..c8c2dfa 100644
--- a/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
+++ b/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
@@ -1097,71 +1097,35 @@
<field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
</entity-and>
<first-from-list list="billToCustomers" entry="billToCustomer"/>
- <!-- TODO: handle serialized inventory -->
- <!--
- <set field="getProdAvgCostMap.inventoryItem" from-field="inventoryItem"/>
- <call-service service-name="getProductAverageCost" in-map-name="getProdAvgCostMap">
- <result-to-field result-name="unitCost"/>
- </call-service>
- <calculate field="origAmount" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}">
- <calcop operator="multiply">
- <calcop operator="get" field="itemIssuance.quantity"/>
- <calcop operator="get" field="unitCost"/>
- </calcop>
- </calculate>
- -->
<!-- prepare the double posting (D/C) entries (AcctgTransEntry) -->
<!-- Credit -->
+ <!-- TODO: handle serialized inventory -->
<set field="partyAccountingPreferencesCallMap.organizationPartyId" from-field="inventoryItem.ownerPartyId"/>
<call-service service-name="getPartyAccountingPreferences" in-map-name="partyAccountingPreferencesCallMap">
<result-to-field result-name="partyAccountingPreference" field="partyAcctgPreference"/>
</call-service>
- <if-compare field="partyAcctgPreference.cogsMethodId" operator="equals" value="COGS_FIFO" type="String">
- <set value="+datetimeReceived" field="orderByString"/>
- </if-compare>
- <if-compare field="partyAcctgPreference.cogsMethodId" operator="equals" value="COGS_LIFO" type="String">
- <set value="-datetimeReceived" field="orderByString"/>
- </if-compare>
- <if-empty field="orderByString">
- <add-error><fail-message message="COGS costing method is not supported: ${partyAcctgPreference.cogsMethodId}"/></add-error>
- <check-errors/>
- </if-empty>
- <entity-condition entity-name="InventoryItem" list="costInventoryItems">
- <condition-list combine="and">
- <condition-expr field-name="ownerPartyId" operator="equals" from-field="inventoryItem.ownerPartyId"/>
- <condition-expr field-name="facilityId" operator="equals" from-field="inventoryItem.facilityId"/>
- <condition-expr field-name="productId" operator="equals" from-field="inventoryItem.productId"/>
- <condition-expr field-name="accountingQuantityTotal" operator="greater" value="0.0"/>
- </condition-list>
- <order-by field-name="${orderByString}"/>
- </entity-condition>
- <set field="remainingQuantity" from-field="itemIssuance.quantity"/>
<set field="totalAmount" value="0.0" type="BigDecimal"/>
- <iterate list="costInventoryItems" entry="costInventoryItem">
- <if-compare field="remainingQuantity" operator="greater" value="0.0" type="BigDecimal">
- <if-compare-field field="remainingQuantity" operator="less-equals" to-field="costInventoryItem.accountingQuantityTotal" type="BigDecimal">
- <set field="costInventoryItemQuantity" from-field="remainingQuantity"/>
- <set field="remainingQuantity" value="0.0" type="BigDecimal"/>
+ <if>
+ <condition>
+ <or>
+ <if-compare field="partyAcctgPreference.cogsMethodId" operator="equals" value="COGS_INV_COST" type="String"/>
+ <if-compare field="partyAcctgPreference.cogsMethodId" operator="equals" value="COGS_AVG_COST" type="String"/>
+ </or>
+ </condition>
+ <then>
+ <if-compare field="partyAcctgPreference.cogsMethodId" operator="equals" value="COGS_AVG_COST" type="String">
+ <set field="getProdAvgCostMap.inventoryItem" from-field="inventoryItem"/>
+ <call-service service-name="getProductAverageCost" in-map-name="getProdAvgCostMap">
+ <result-to-field result-name="unitCost"/>
+ </call-service>
<else>
- <set field="costInventoryItemQuantity" from-field="costInventoryItem.accountingQuantityTotal"/>
- <set field="remainingQuantity" value="${remainingQuantity - costInventoryItem.accountingQuantityTotal}" type="BigDecimal"/>
+ <set field="unitCost" from-field="inventoryItem.unitCost"/>
</else>
- </if-compare-field>
- <!-- An inventory item detail record is created to keep track of the units (value) that we are going to add to the inventory account -->
- <set from-field="costInventoryItem.inventoryItemId" field="createDetailMap.inventoryItemId"/>
- <set value="${-1 * costInventoryItemQuantity}" field="createDetailMap.accountingQuantityDiff" type="BigDecimal"/>
- <call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
-
- <calculate field="costInventoryItemAmount" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}">
- <calcop operator="multiply">
- <calcop operator="get" field="costInventoryItemQuantity"/>
- <calcop operator="get" field="costInventoryItem.unitCost"/>
- </calcop>
- </calculate>
+ </if-compare>
<calculate field="totalAmount" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}">
- <calcop operator="sum">
- <calcop operator="get" field="costInventoryItemAmount"/>
- <calcop operator="get" field="totalAmount"/>
+ <calcop operator="multiply">
+ <calcop operator="get" field="itemIssuance.quantity"/>
+ <calcop operator="get" field="unitCost"/>
</calcop>
</calculate>
<make-value entity-name="AcctgTransEntry" value-field="creditEntry"/>
@@ -1169,21 +1133,85 @@
<set field="creditEntry.glAccountTypeId" value="INVENTORY_ACCOUNT"/>
<set field="creditEntry.organizationPartyId" from-field="inventoryItem.ownerPartyId"/>
<set field="creditEntry.productId" from-field="inventoryItem.productId"/>
- <set field="creditEntry.inventoryItemId" from-field="costInventoryItem.inventoryItemId"/>
- <set field="creditEntry.origAmount" from-field="costInventoryItemAmount"/>
+ <set field="creditEntry.inventoryItemId" from-field="inventoryItem.inventoryItemId"/>
+ <set field="creditEntry.origAmount" from-field="totalAmount"/>
<set field="creditEntry.origCurrencyUomId" from-field="inventoryItem.currencyUomId"/>
<if-not-empty field="billToCustomer">
<set field="creditEntry.partyId" from-field="billToCustomer.partyId"/>
<set field="creditEntry.roleTypeId" from-field="billToCustomer.roleTypeId"/>
</if-not-empty>
<set field="acctgTransEntries[]" from-field="creditEntry" type="Object"/>
- <clear-field field="creditEntry"/>
- </if-compare>
- </iterate>
- <if-compare field="remainingQuantity" operator="greater" value="0.0" type="BigDecimal">
- <add-error><fail-message message="Could not find enough accounting inventory for product [${inventoryItem.productId}]; remaining quantity: ${remainingQuantity}"/></add-error>
- <check-errors/>
- </if-compare>
+ </then>
+ <else>
+ <if-compare field="partyAcctgPreference.cogsMethodId" operator="equals" value="COGS_FIFO" type="String">
+ <set value="+datetimeReceived" field="orderByString"/>
+ </if-compare>
+ <if-compare field="partyAcctgPreference.cogsMethodId" operator="equals" value="COGS_LIFO" type="String">
+ <set value="-datetimeReceived" field="orderByString"/>
+ </if-compare>
+ <if-empty field="orderByString">
+ <add-error><fail-message message="COGS costing method is not supported: ${partyAcctgPreference.cogsMethodId}"/></add-error>
+ <check-errors/>
+ </if-empty>
+ <entity-condition entity-name="InventoryItem" list="costInventoryItems">
+ <condition-list combine="and">
+ <condition-expr field-name="ownerPartyId" operator="equals" from-field="inventoryItem.ownerPartyId"/>
+ <condition-expr field-name="facilityId" operator="equals" from-field="inventoryItem.facilityId"/>
+ <condition-expr field-name="productId" operator="equals" from-field="inventoryItem.productId"/>
+ <condition-expr field-name="accountingQuantityTotal" operator="greater" value="0.0"/>
+ </condition-list>
+ <order-by field-name="${orderByString}"/>
+ </entity-condition>
+ <set field="remainingQuantity" from-field="itemIssuance.quantity"/>
+ <iterate list="costInventoryItems" entry="costInventoryItem">
+ <if-compare field="remainingQuantity" operator="greater" value="0.0" type="BigDecimal">
+ <if-compare-field field="remainingQuantity" operator="less-equals" to-field="costInventoryItem.accountingQuantityTotal" type="BigDecimal">
+ <set field="costInventoryItemQuantity" from-field="remainingQuantity"/>
+ <set field="remainingQuantity" value="0.0" type="BigDecimal"/>
+ <else>
+ <set field="costInventoryItemQuantity" from-field="costInventoryItem.accountingQuantityTotal"/>
+ <set field="remainingQuantity" value="${remainingQuantity - costInventoryItem.accountingQuantityTotal}" type="BigDecimal"/>
+ </else>
+ </if-compare-field>
+ <!-- An inventory item detail record is created to keep track of the units (value) that we are going to add to the inventory account -->
+ <set from-field="costInventoryItem.inventoryItemId" field="createDetailMap.inventoryItemId"/>
+ <set value="${-1 * costInventoryItemQuantity}" field="createDetailMap.accountingQuantityDiff" type="BigDecimal"/>
+ <call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
+
+ <calculate field="costInventoryItemAmount" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}">
+ <calcop operator="multiply">
+ <calcop operator="get" field="costInventoryItemQuantity"/>
+ <calcop operator="get" field="costInventoryItem.unitCost"/>
+ </calcop>
+ </calculate>
+ <calculate field="totalAmount" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}">
+ <calcop operator="add">
+ <calcop operator="get" field="costInventoryItemAmount"/>
+ <calcop operator="get" field="totalAmount"/>
+ </calcop>
+ </calculate>
+ <make-value entity-name="AcctgTransEntry" value-field="creditEntry"/>
+ <set field="creditEntry.debitCreditFlag" value="C"/>
+ <set field="creditEntry.glAccountTypeId" value="INVENTORY_ACCOUNT"/>
+ <set field="creditEntry.organizationPartyId" from-field="inventoryItem.ownerPartyId"/>
+ <set field="creditEntry.productId" from-field="inventoryItem.productId"/>
+ <set field="creditEntry.inventoryItemId" from-field="costInventoryItem.inventoryItemId"/>
+ <set field="creditEntry.origAmount" from-field="costInventoryItemAmount"/>
+ <set field="creditEntry.origCurrencyUomId" from-field="inventoryItem.currencyUomId"/>
+ <if-not-empty field="billToCustomer">
+ <set field="creditEntry.partyId" from-field="billToCustomer.partyId"/>
+ <set field="creditEntry.roleTypeId" from-field="billToCustomer.roleTypeId"/>
+ </if-not-empty>
+ <set field="acctgTransEntries[]" from-field="creditEntry" type="Object"/>
+ <clear-field field="creditEntry"/>
+ </if-compare>
+ </iterate>
+ <if-compare field="remainingQuantity" operator="greater" value="0.0" type="BigDecimal">
+ <add-error><fail-message message="Could not find enough accounting inventory for product [${inventoryItem.productId}]; remaining quantity: ${remainingQuantity}"/></add-error>
+ <check-errors/>
+ </if-compare>
+ </else>
+ </if>
<!-- Debit -->
<make-value entity-name="AcctgTransEntry" value-field="debitEntry"/>
<set field="debitEntry.debitCreditFlag" value="D"/>
@@ -1284,11 +1312,34 @@
</else>
</if-not-empty>
<!-- TODO: handle serialized inventory -->
+ <set field="partyAccountingPreferencesCallMap.organizationPartyId" from-field="inventoryItem.ownerPartyId"/>
+ <call-service service-name="getPartyAccountingPreferences" in-map-name="partyAccountingPreferencesCallMap">
+ <result-to-field result-name="partyAccountingPreference" field="partyAcctgPreference"/>
+ </call-service>
<if-not-empty field="shipmentReceipt.returnId">
- <set field="getProdAvgCostMap.inventoryItem" from-field="inventoryItem"/>
- <call-service service-name="getProductAverageCost" in-map-name="getProdAvgCostMap">
- <result-to-field result-name="unitCost"/>
- </call-service>
+ <if>
+ <condition>
+ <or>
+ <if-compare field="partyAcctgPreference.cogsMethodId" operator="equals" value="COGS_INV_COST" type="String"/>
+ <if-compare field="partyAcctgPreference.cogsMethodId" operator="equals" value="COGS_AVG_COST" type="String"/>
+ </or>
+ </condition>
+ <then>
+ <if-compare field="partyAcctgPreference.cogsMethodId" operator="equals" value="COGS_AVG_COST" type="String">
+ <set field="getProdAvgCostMap.inventoryItem" from-field="inventoryItem"/>
+ <call-service service-name="getProductAverageCost" in-map-name="getProdAvgCostMap">
+ <result-to-field result-name="unitCost"/>
+ </call-service>
+ <else>
+ <set field="unitCost" from-field="inventoryItem.unitCost"/>
+ </else>
+ </if-compare>
+ </then>
+ <else>
+ <!-- LIFO and FIFO-->
+ <set field="unitCost" from-field="inventoryItem.unitCost"/>
+ </else>
+ </if>
<else>
<set field="unitCost" from-field="inventoryItem.unitCost"/>
</else>
diff --git a/applications/accounting/webapp/accounting/reports/InventoryValuationReport.fo.ftl b/applications/accounting/webapp/accounting/reports/InventoryValuationReport.fo.ftl
deleted file mode 100644
index e8a0a22..0000000
--- a/applications/accounting/webapp/accounting/reports/InventoryValuationReport.fo.ftl
+++ /dev/null
@@ -1,108 +0,0 @@
-<#--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<#escape x as x?xml>
- <fo:block font-size="14pt" font-weight="bold" text-align="center">${uiLabelMap.AccountingInventoryValuation}</fo:block>
- <fo:block font-size="10pt" text-align="left" font-weight="bold">
- <#if parameters.organizationPartyId?has_content>${uiLabelMap.Party} : ${parameters.organizationPartyId?if_exists}</#if>
- </fo:block>
- <fo:block font-size="10pt" text-align="left" font-weight="bold">
- <#if parameters.facilityId?has_content>
- <#assign facility = (delegator.findOne("Facility", {"facilityId" : parameters.facilityId}, false))?if_exists>
- <#if facility.facilityName?has_content>${uiLabelMap.Facility} : ${facility.facilityName?if_exists}</#if>
- </#if>
- </fo:block>
- <fo:block font-size="10pt" text-align="left" font-weight="bold">
- <#if parameters.productCategoryId?has_content>
- <#assign productCategory = (delegator.findOne("ProductCategory", {"productCategoryId" : parameters.productCategoryId}, false))?if_exists>
- <#if productCategory.categoryName?has_content>${uiLabelMap.ProductProductCategory} : ${productCategory.categoryName?if_exists}</#if>
- </#if>
- </fo:block>
- <fo:block font-size="10pt" text-align="left" font-weight="bold">
- <#if parameters.fromDate?has_content>
- ${uiLabelMap.CommonFromDate} : ${parameters.fromDate?if_exists}
- </#if>
- </fo:block>
- <fo:block font-size="10pt" text-align="left" font-weight="bold">
- <#if parameters.thruDate?has_content>
- ${uiLabelMap.CommonThruDate} : ${parameters.thruDate?if_exists}
- </#if>
- </fo:block>
- <#if inventoryValuationList?has_content>
- <fo:block><fo:leader/></fo:block>
- <fo:block space-after.optimum="10pt" font-size="10pt">
- <fo:table>
- <fo:table-column column-width="130pt"/>
- <fo:table-column column-width="130pt"/>
- <fo:table-column column-width="130pt"/>
- <fo:table-column column-width="130pt"/>
- <fo:table-header>
- <fo:table-row font-weight="bold">
- <fo:table-cell padding="2pt" background-color="#D4D0C8" border="1pt solid" border-width=".1mm">
- <fo:block text-align="center">${uiLabelMap.ProductProduct}</fo:block>
- </fo:table-cell>
- <fo:table-cell padding="2pt" background-color="#D4D0C8" border="1pt solid" border-width=".1mm">
- <fo:block text-align="center">${uiLabelMap.AccountingTotalQuantityOnHand}</fo:block>
- </fo:table-cell>
- <fo:table-cell padding="2pt" background-color="#D4D0C8" border="1pt solid" border-width=".1mm">
- <fo:block text-align="center">${uiLabelMap.FormFieldTitle_unitCost}</fo:block>
- </fo:table-cell>
- <fo:table-cell padding="2pt" background-color="#D4D0C8" border="1pt solid" border-width=".1mm">
- <fo:block text-align="center">${uiLabelMap.CommonTotalValue}</fo:block>
- </fo:table-cell>
- </fo:table-row>
- </fo:table-header>
- <fo:table-body>
- <#list inventoryValuationList as inventoryValuation>
- <#assign currencyUomId = inventoryValuation.currencyUomId?if_exists>
- <fo:table-row>
- <fo:table-cell padding="2pt" border="1pt solid" border-width=".1mm">
- <fo:block text-align="center">${inventoryValuation.productId?if_exists}</fo:block>
- </fo:table-cell>
- <fo:table-cell padding="2pt" border="1pt solid" border-width=".1mm">
- <fo:block text-align="center">${inventoryValuation.totalQuantityOnHand?if_exists}</fo:block>
- </fo:table-cell>
- <fo:table-cell padding="2pt" border="1pt solid" border-width=".1mm">
- <fo:block text-align="center">
- <#if currencyUomId != null>
- <@ofbizCurrency amount = inventoryValuation.productAverageCost?if_exists isoCode = currencyUomId/>
- </#if>
- </fo:block>
- </fo:table-cell>
- <fo:table-cell padding="2pt" border="1pt solid" border-width=".1mm">
- <fo:block text-align="center">
- <#if currencyUomId != null>
- <@ofbizCurrency amount = inventoryValuation.totalInventoryCost?if_exists isoCode = currencyUomId/>
- </#if>
- </fo:block>
- </fo:table-cell>
- </fo:table-row>
- </#list>
- </fo:table-body>
- </fo:table>
- </fo:block>
- <#else>
- <fo:table-row>
- <fo:table-cell number-columns-spanned="2"/>
- <fo:table-cell padding="2pt">
- <fo:block>${uiLabelMap.AccountingNoRecordFound}</fo:block>
- </fo:table-cell>
- <fo:table-cell number-columns-spanned="2"/>
- </fo:table-row>
- </#if>
-</#escape>
diff --git a/applications/accounting/widget/ReportFinancialSummaryForms.xml b/applications/accounting/widget/ReportFinancialSummaryForms.xml
index ff5cdce..fb1c588 100644
--- a/applications/accounting/widget/ReportFinancialSummaryForms.xml
+++ b/applications/accounting/widget/ReportFinancialSummaryForms.xml
@@ -496,41 +496,34 @@
<entity-order-by field-name="facilityId"/>
</entity-options>
</drop-down>
- </field>
- <field name="cogsMethodId" position="2">
- <drop-down allow-empty="false">
- <!--TODO for now Average Cost is being calculated-->
- <!--<entity-options entity-name="Enumeration" description="${description}" key-field-name="enumId">
- <entity-constraint name="enumTypeId" operator="equals" value="COGS_METHODS"/>
- <entity-order-by field-name="description"/>
- </entity-options>-->
- <option key="COGS_AVG_COST" description="${uiLabelMap.ProductAverageCost}"/>
- </drop-down>
</field>
- <field name="productId" position="1"><lookup target-form-name="LookupProduct"/></field>
- <field name="productCategoryId" position="2"><lookup target-form-name="LookupProductCategory"/></field>
- <field name="fromDate" position="1"><date-time/></field>
- <field name="thruDate" position="2"><date-time/></field>
+ <field name="productId"><lookup target-form-name="LookupProduct"/></field>
+ <field name="thruDate"><date-time default-value="${nowTimestamp}"/></field>
<field name="organizationPartyId"><hidden/></field>
<field name="showSearchResults"><hidden value="Y"/><!-- if this isn't there then with all fields empty no query will be done --></field>
<field name="submitButton" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
- <form name="InventoryValuationList" extends="ListInventoryAverageCosts" extends-resource="component://product/widget/facility/FacilityForms.xml"
- odd-row-style="alternate-row" default-table-style="basic-table hover-bar" list-name="inventoryValuationList" paginate-target="InventoryValuation">
- <field name="productAverageCost" use-when="currencyUomId!=null"><display type="currency" currency="${currencyUomId}"/></field>
- <field name="productAverageCost" use-when="currencyUomId==null" title="${uiLabelMap.FormFieldTitle_unitCost}"><display description="${uiLabelMap.ProductDifferentCurrencies}"/></field>
- <field name="totalInventoryCost" use-when="currencyUomId!=null" title="${uiLabelMap.CommonTotalValue}"><display type="currency" currency="${currencyUomId}"/></field>
- <field name="totalInventoryCost" use-when="currencyUomId==null" title="${uiLabelMap.CommonTotalValue}"><display description="${uiLabelMap.ProductDifferentCurrencies}"/></field>
- </form>
-
- <form name="InventoryValuationCsv" type="list" list-name="inventoryValuationList" view-size="99999">
- <field name="productId" title="${uiLabelMap.AccountingProductId}"><display/></field>
- <field name="totalQuantityOnHand" title="${uiLabelMap.AccountingTotalQuantityOnHand}"><display/></field>
- <field name="productAverageCost" use-when="currencyUomId!=null" title="${uiLabelMap.FormFieldTitle_unitCost}" ><display type="currency" currency="${currencyUomId}"/></field>
- <field name="productAverageCost" use-when="currencyUomId==null" title="${uiLabelMap.FormFieldTitle_unitCost}" ><display description="${uiLabelMap.ProductDifferentCurrencies}"/></field>
- <field name="totalInventoryCost" use-when="currencyUomId!=null" title="${uiLabelMap.CommonTotalValue}" ><display type="currency" currency="${currencyUomId}"/></field>
- <field name="totalInventoryCost" use-when="currencyUomId==null" title="${uiLabelMap.CommonTotalValue}"><display description="${uiLabelMap.ProductDifferentCurrencies}"/></field>
+ <form name="InventoryValuationList" type="list" list-name="inventoryValuationList" odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
+ <actions>
+ <entity-condition entity-name="InventoryItemDetailForSum" list="inventoryValuationList" use-cache="false">
+ <condition-list>
+ <condition-expr field-name="ownerPartyId" operator="equals" from-field="parameters.organizationPartyId"/>
+ <condition-expr field-name="accountingQuantityDiff" operator="not-equals" value="0.0"/>
+ <condition-expr field-name="effectiveDate" operator="less-equals" from-field="parameters.thruDate"/>
+ <condition-expr field-name="facilityId" operator="equals" from-field="parameters.facilityId" ignore-if-empty="true"/>
+ <condition-expr field-name="productId" operator="equals" from-field="parameters.productId" ignore-if-empty="true"/>
+ </condition-list>
+ <select-field field-name="productId"/>
+ <select-field field-name="unitCost"/>
+ <select-field field-name="currencyUomId"/>
+ <select-field field-name="accountingQuantitySum"/>
+ </entity-condition>
+ </actions>
+ <field name="productId"><display/></field>
+ <field name="unitCost" widget-style="tabletextright"><display currency="${currencyUomId}" type="currency"/></field>
+ <field name="accountingQuantitySum" widget-style="tabletextright"><display/></field>
+ <field name="value" widget-style="tabletextright"><display description="${accountingQuantitySum * unitCost}" currency="${currencyUomId}" type="currency"/></field>
</form>
<form name="TrialBalanceFinancialTimePeriodSelection" type="single" header-row-style="header-row" target="TrialBalance" default-table-style="basic-table">
diff --git a/applications/accounting/widget/ReportFinancialSummaryScreens.xml b/applications/accounting/widget/ReportFinancialSummaryScreens.xml
index 3abb69d..bf88eb7 100644
--- a/applications/accounting/widget/ReportFinancialSummaryScreens.xml
+++ b/applications/accounting/widget/ReportFinancialSummaryScreens.xml
@@ -1367,42 +1367,22 @@
<condition>
<if-compare field="parameters.showSearchResults" operator="equals" value="Y"/>
</condition>
- <actions>
- <service service-name="getInventoryValuationList" result-map="inventoryValuation"/>
- <set field="inventoryValuationList" from-field="inventoryValuation.inventoryValuationList" type="List"/>
- </actions>
<widgets>
- <section>
- <condition>
- <not><if-empty field="inventoryValuationList"/></not>
- </condition>
- <widgets>
- <link text="${uiLabelMap.AccountingExportAsPdf}" style="button" target="InventoryValuation.pdf">
- <parameter param-name="organizationPartyId" from-field="parameters.organizationPartyId"/>
- <parameter param-name="facilityId" from-field="parameters.facilityId"/>
- <parameter param-name="productId" from-field="parameters.productId"/>
- <parameter param-name="productCategoryId" from-field="parameters.productCategoryId"/>
- <parameter param-name="fromDate" from-field="parameters.fromDate"/>
- <parameter param-name="thruDate" from-field="parameters.thruDate"/>
- <parameter param-name="cogsMethodId" from-field="parameters.cogsMethodId"/>
- </link>
- <link text="${uiLabelMap.AccountingExportAsCsv}" style="button" target="InventoryValuation.csv">
- <parameter param-name="organizationPartyId" from-field="parameters.organizationPartyId"/>
- <parameter param-name="facilityId" from-field="parameters.facilityId"/>
- <parameter param-name="productId" from-field="parameters.productId"/>
- <parameter param-name="productCategoryId" from-field="parameters.productCategoryId"/>
- <parameter param-name="fromDate" from-field="parameters.fromDate"/>
- <parameter param-name="thruDate" from-field="parameters.thruDate"/>
- <parameter param-name="cogsMethodId" from-field="parameters.cogsMethodId"/>
- </link>
- <screenlet title="${uiLabelMap.AccountingInventoryValuationList}">
- <include-form name="InventoryValuationList" location="component://accounting/widget/ReportFinancialSummaryForms.xml"/>
- </screenlet>
- </widgets>
- <fail-widgets>
- <label style="h3">${uiLabelMap.AccountingNoRecordFound}</label>
- </fail-widgets>
- </section>
+ <link text="${uiLabelMap.AccountingExportAsPdf}" style="button" target="InventoryValuation.pdf">
+ <parameter param-name="organizationPartyId" from-field="parameters.organizationPartyId"/>
+ <parameter param-name="facilityId" from-field="parameters.facilityId"/>
+ <parameter param-name="productId" from-field="parameters.productId"/>
+ <parameter param-name="thruDate" from-field="parameters.thruDate"/>
+ </link>
+ <link text="${uiLabelMap.AccountingExportAsCsv}" style="button" target="InventoryValuation.csv">
+ <parameter param-name="organizationPartyId" from-field="parameters.organizationPartyId"/>
+ <parameter param-name="facilityId" from-field="parameters.facilityId"/>
+ <parameter param-name="productId" from-field="parameters.productId"/>
+ <parameter param-name="thruDate" from-field="parameters.thruDate"/>
+ </link>
+ <screenlet title="${uiLabelMap.AccountingInventoryValuationList}">
+ <include-form name="InventoryValuationList" location="component://accounting/widget/ReportFinancialSummaryForms.xml"/>
+ </screenlet>
</widgets>
</section>
</decorator-section>
@@ -1418,18 +1398,15 @@
<property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
<property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/>
<property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/>
- <set field="organizationPartyId" from-field="parameters.organizationPartyId"/>
- <service service-name="getInventoryValuationList" result-map="inventoryValuation"/>
- <set field="inventoryValuationList" from-field="inventoryValuation.inventoryValuationList" type="List"/>
+ <set field="viewSize" value="99999"/>
</actions>
<widgets>
<decorator-screen name="SimpleDecorator" location="component://common/widget/CommonScreens.xml">
<decorator-section name="body">
- <platform-specific>
- <xsl-fo>
- <html-template location="component://accounting/webapp/accounting/reports/InventoryValuationReport.fo.ftl"/>
- </xsl-fo>
- </platform-specific>
+ <container>
+ <label style="h1" text="${uiLabelMap.AccountingInventoryValuation}"/>
+ <include-form name="InventoryValuationList" location="component://accounting/widget/ReportFinancialSummaryForms.xml"/>
+ </container>
</decorator-section>
</decorator-screen>
</widgets>
@@ -1441,13 +1418,11 @@
<property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
<property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/>
<property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/>
- <set field="organizationPartyId" from-field="parameters.organizationPartyId"/>
- <service service-name="getInventoryValuationList" result-map="inventoryValuation"/>
- <set field="inventoryValuationList" from-field="inventoryValuation.inventoryValuationList" type="List"/>
+ <set field="viewSize" value="99999"/>
</actions>
<widgets>
<container>
- <include-form name="InventoryValuationCsv" location="component://accounting/widget/ReportFinancialSummaryForms.xml"/>
+ <include-form name="InventoryValuationList" location="component://accounting/widget/ReportFinancialSummaryForms.xml"/>
</container>
</widgets>
</section>
diff --git a/applications/content/script/org/ofbiz/content/survey/SurveyServices.xml b/applications/content/script/org/ofbiz/content/survey/SurveyServices.xml
index 4148ddb..120bcec 100644
--- a/applications/content/script/org/ofbiz/content/survey/SurveyServices.xml
+++ b/applications/content/script/org/ofbiz/content/survey/SurveyServices.xml
@@ -433,8 +433,10 @@
<field-map field-name="surveyId" from-field="survey.surveyId"/>
</entity-and>
<if-not-empty field="existingResponses">
- <add-error><fail-message message="You have already responded to this survey; multiple responses are not allowed"/></add-error>
- <check-errors/>
+ <if-compare field="survey.allowUpdate" operator="not-equals" value="Y">
+ <add-error><fail-message message="You have already responded to this survey; multiple responses are not allowed"/></add-error>
+ <check-errors/>
+ </if-compare>
</if-not-empty>
</if-not-empty>
</if-compare>
@@ -475,7 +477,7 @@
<!-- create/update the response -->
<if-compare field="survey.allowUpdate" operator="equals" value="Y">
<if-not-empty field="parameters.surveyResponseId">
- <entity-one entity-name="SurveyResponse" value-field="lookupRespMap"/>
+ <entity-one entity-name="SurveyResponse" value-field="surveyResponse"/>
</if-not-empty>
</if-compare>
diff --git a/applications/product/entitydef/entitymodel.xml b/applications/product/entitydef/entitymodel.xml
index 64e1d6f..a43688b 100644
--- a/applications/product/entitydef/entitymodel.xml
+++ b/applications/product/entitydef/entitymodel.xml
@@ -2050,9 +2050,13 @@
<alias entity-alias="II" name="inventoryItemTypeId" group-by="true"></alias>
<alias entity-alias="II" name="facilityId" group-by="true"></alias>
<alias entity-alias="II" name="productId" group-by="true"></alias>
+ <alias entity-alias="II" name="unitCost" group-by="true"></alias>
+ <alias entity-alias="II" name="currencyUomId" group-by="true"></alias>
<alias entity-alias="IID" name="effectiveDate"><description>For query only, not in fields to select.</description></alias>
<alias entity-alias="IID" name="orderId"><description>For query only, not in fields to select.</description></alias>
+ <alias entity-alias="II" name="ownerPartyId"><description>For query only, not in fields to select.</description></alias>
<alias entity-alias="IID" name="quantityOnHandDiff"><description>For query only, not in fields to select.</description></alias>
+ <alias entity-alias="IID" name="accountingQuantityDiff"><description>For query only, not in fields to select.</description></alias>
<view-link entity-alias="II" rel-entity-alias="IID">
<key-map field-name="inventoryItemId"/>
</view-link>
diff --git a/applications/product/widget/facility/InventoryForms.xml b/applications/product/widget/facility/InventoryForms.xml
index 044fdf1..5e50883 100644
--- a/applications/product/widget/facility/InventoryForms.xml
+++ b/applications/product/widget/facility/InventoryForms.xml
@@ -109,8 +109,11 @@
</field>
<field name="unitCost"><text/></field>
+ <field name="accountingQuantityTotal">
+ <display/>
+ </field>
<field name="totals" title="${uiLabelMap.ProductAvailablePromiseQuantityHand}">
- <display description="${inventoryItem.availableToPromiseTotal} / ${inventoryItem.quantityOnHandTotal}"/>
+ <display description="${inventoryItem.availableToPromiseTotal} / ${inventoryItem.quantityOnHandTotal}"/>
</field>
<field use-when="inventoryItem!=null" name="submit" title="${uiLabelMap.CommonUpdate}">
diff --git a/framework/base/src/org/ofbiz/base/util/GroovyUtil.java b/framework/base/src/org/ofbiz/base/util/GroovyUtil.java
index 76726c7..cf01ca2 100644
--- a/framework/base/src/org/ofbiz/base/util/GroovyUtil.java
+++ b/framework/base/src/org/ofbiz/base/util/GroovyUtil.java
@@ -28,6 +28,8 @@
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyShell;
+import javolution.util.FastMap;
+
import org.codehaus.groovy.control.CompilationFailedException;
import org.codehaus.groovy.runtime.InvokerHelper;
import org.ofbiz.base.location.FlexibleLocation;
@@ -60,19 +62,25 @@
return new GroovyClassLoader().parseClass(UtilIO.readString(in), location);
}
+ /** Returns a <code>Binding</code> instance initialized with the
+ * variables contained in <code>context</code>. If <code>context</code>
+ * is <code>null</code>, an empty <code>Binding</code> is returned.
+ * <p>The <code>context Map</code> is added to the <code>Binding</code>
+ * as a variable called "context" so that variables can be passed
+ * back to the caller. Any variables that are created in the script
+ * are lost when the script ends unless they are copied to the
+ * "context" <code>Map</code>.</p>
+ *
+ * @param context A <code>Map</code> containing initial variables
+ * @return A <code>Binding</code> instance
+ */
public static Binding getBinding(Map<String, ? extends Object> context) {
- Binding binding = new Binding();
+ Map<String, Object> vars = FastMap.newInstance();
if (context != null) {
- Set<String> keySet = context.keySet();
- for (Object key : keySet) {
- binding.setVariable((String) key, context.get(key));
- }
-
- // include the context itself in for easier access in the scripts
- binding.setVariable("context", context);
+ vars.putAll(context);
+ vars.put("context", context);
}
-
- return binding;
+ return new Binding(vars);
}
/**
diff --git a/framework/birt/src/org/ofbiz/birt/container/BirtContainer.java b/framework/birt/src/org/ofbiz/birt/container/BirtContainer.java
index 61b515e..60e39de 100644
--- a/framework/birt/src/org/ofbiz/birt/container/BirtContainer.java
+++ b/framework/birt/src/org/ofbiz/birt/container/BirtContainer.java
@@ -19,7 +19,6 @@
package org.ofbiz.birt.container;
import java.io.File;
-import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
@@ -42,7 +41,6 @@
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.DelegatorFactory;
-import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.service.GenericDispatcher;
import org.ofbiz.service.LocalDispatcher;
@@ -163,7 +161,7 @@
return "birt-container";
}
- public static IReportEngine getReportEngine() throws GenericEntityException, SQLException {
+ public static IReportEngine getReportEngine() {
return engine;
}
diff --git a/framework/birt/src/org/ofbiz/birt/report/context/BirtViewerAttributeBean.java b/framework/birt/src/org/ofbiz/birt/report/context/BirtViewerAttributeBean.java
index f4b498f..b43425d 100644
--- a/framework/birt/src/org/ofbiz/birt/report/context/BirtViewerAttributeBean.java
+++ b/framework/birt/src/org/ofbiz/birt/report/context/BirtViewerAttributeBean.java
@@ -37,6 +37,7 @@
super(request);
}
+ @Override
protected void __init( HttpServletRequest request ) throws Exception
{
String reportParam = DataUtil.trimString( ParameterAccessor.getParameter( request, ParameterAccessor.PARAM_REPORT ));
diff --git a/framework/birt/src/org/ofbiz/birt/report/context/OFBizBirtContext.java b/framework/birt/src/org/ofbiz/birt/report/context/OFBizBirtContext.java
index 9d5f05f..ec5c7d6 100644
--- a/framework/birt/src/org/ofbiz/birt/report/context/OFBizBirtContext.java
+++ b/framework/birt/src/org/ofbiz/birt/report/context/OFBizBirtContext.java
@@ -34,6 +34,7 @@
super(request, response);
}
+ @Override
protected void __init() {
this.bean = (ViewerAttributeBean) request
.getAttribute( IBirtConstants.ATTRIBUTE_BEAN );
diff --git a/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java b/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java
index eee75e3..7ea9923 100644
--- a/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java
+++ b/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java
@@ -63,40 +63,38 @@
super(servletContext);
}
- public String runReport(IViewerReportDesignHandle design,
- String outputDocName, InputOptions runOptions, Map parameters,
+ @Override
+ public String runReport(IViewerReportDesignHandle design, String outputDocName, InputOptions runOptions, Map parameters,
Map displayTexts, List<Exception> errorList) throws ReportServiceException {
- if ( design == null || design.getDesignObject( ) == null )
- throw new ReportServiceException( BirtResources.getMessage( ResourceConstants.GENERAL_EXCEPTION_NO_REPORT_DESIGN ) );
+ if (design == null || design.getDesignObject( ) == null) {
+ throw new ReportServiceException(BirtResources.getMessage(ResourceConstants.GENERAL_EXCEPTION_NO_REPORT_DESIGN));
+ }
IReportRunnable runnable;
- HttpServletRequest request = (HttpServletRequest) runOptions.getOption( InputOptions.OPT_REQUEST );
- Locale locale = (Locale) runOptions.getOption( InputOptions.OPT_LOCALE );
- TimeZone timeZone = (TimeZone) runOptions.getOption( InputOptions.OPT_TIMEZONE );
+ HttpServletRequest request = (HttpServletRequest) runOptions.getOption(InputOptions.OPT_REQUEST);
+ Locale locale = (Locale) runOptions.getOption(InputOptions.OPT_LOCALE);
+ TimeZone timeZone = (TimeZone) runOptions.getOption(InputOptions.OPT_TIMEZONE);
- ViewerAttributeBean attrBean = (ViewerAttributeBean) request.getAttribute( IBirtConstants.ATTRIBUTE_BEAN );
+ ViewerAttributeBean attrBean = (ViewerAttributeBean) request.getAttribute(IBirtConstants.ATTRIBUTE_BEAN);
// Set parameters
- Map parsedParams = attrBean.getParameters( );
- if ( parameters != null )
- {
- parsedParams.putAll( parameters );
+ Map parsedParams = attrBean.getParameters();
+ if (parameters != null) {
+ parsedParams.putAll(parameters);
}
// Set display Text of select parameters
- Map displayTextMap = attrBean.getDisplayTexts( );
- if ( displayTexts != null )
- {
- displayTextMap.putAll( displayTexts );
+ Map displayTextMap = attrBean.getDisplayTexts();
+ if (displayTexts != null) {
+ displayTextMap.putAll(displayTexts);
}
- runnable = (IReportRunnable) design.getDesignObject( );
- try
- {
+ runnable = (IReportRunnable) design.getDesignObject();
+ try {
// get maxRows
Integer maxRows = null;
- if ( ParameterAccessor.isReportParameterExist( request,
- ParameterAccessor.PARAM_MAXROWS ) )
- maxRows = Integer.valueOf( ParameterAccessor.getMaxRows( request ) );
+ if (ParameterAccessor.isReportParameterExist(request, ParameterAccessor.PARAM_MAXROWS)) {
+ maxRows = Integer.valueOf(ParameterAccessor.getMaxRows(request));
+ }
try {
// put all app context from Birt Container to Report Engine Service
@@ -110,29 +108,15 @@
} catch (Exception e) {
Debug.logError(e, module);
}
- List<Exception> errors = this.runReport( request,
- runnable,
- outputDocName,
- locale,
- timeZone,
- parsedParams,
- displayTextMap,
- maxRows );
- if ( errors != null && !errors.isEmpty( ) )
- {
- errorList.addAll( errors );
+ List<Exception> errors = this.runReport(request, runnable, outputDocName, locale, timeZone, parsedParams, displayTextMap, maxRows);
+ if (errors != null && !errors.isEmpty()) {
+ errorList.addAll(errors);
}
- }
- catch ( RemoteException e )
- {
- if ( e.getCause( ) instanceof ReportServiceException )
- {
- throw (ReportServiceException) e.getCause( );
- }
- else
- {
- throw new ReportServiceException( e.getLocalizedMessage( ),
- e.getCause( ) );
+ } catch ( RemoteException e ) {
+ if (e.getCause() instanceof ReportServiceException) {
+ throw (ReportServiceException) e.getCause();
+ } else {
+ throw new ReportServiceException(e.getLocalizedMessage(), e.getCause());
}
}
return outputDocName;
@@ -153,83 +137,75 @@
* @return list of exceptions which occured during the run or null
* @throws RemoteException
*/
- public List<Exception> runReport( HttpServletRequest request,
+ public List<Exception> runReport(HttpServletRequest request,
IReportRunnable runnable, String documentName, Locale locale,
- TimeZone timeZone, Map parameters, Map displayTexts, Integer maxRows )
- throws RemoteException
- {
+ TimeZone timeZone, Map parameters, Map displayTexts, Integer maxRows)
+ throws RemoteException {
assert runnable != null;
- // Preapre the run report task.
+ // Prepare the run report task.
IRunTask runTask = null;
try {
- runTask = BirtContainer.getReportEngine().createRunTask( runnable );
+ runTask = BirtContainer.getReportEngine().createRunTask(runnable);
} catch (Exception e) {
throwDummyException(e);
}
- runTask.setLocale( locale );
+ runTask.setLocale(locale);
- com.ibm.icu.util.TimeZone tz = BirtUtility.toICUTimeZone( timeZone );
- if ( tz != null )
- {
- runTask.setTimeZone( tz );
+ com.ibm.icu.util.TimeZone tz = BirtUtility.toICUTimeZone(timeZone);
+ if (tz != null) {
+ runTask.setTimeZone(tz);
}
- runTask.setParameterValues( parameters );
+ runTask.setParameterValues(parameters);
// set MaxRows settings
- if ( maxRows != null )
- runTask.setMaxRowsPerQuery( maxRows.intValue( ) );
+ if (maxRows != null) {
+ runTask.setMaxRowsPerQuery(maxRows.intValue());
+ }
// add task into session
- BirtUtility.addTask( request, runTask );
+ BirtUtility.addTask(request, runTask);
// Set display Text for select parameters
- if ( displayTexts != null )
+ if (displayTexts != null)
{
- Iterator keys = displayTexts.keySet( ).iterator( );
- while ( keys.hasNext( ) )
- {
- String paramName = DataUtil.getString( keys.next( ) );
- String displayText = DataUtil.getString( displayTexts
- .get( paramName ) );
- runTask.setParameterDisplayText( paramName, displayText );
+ Iterator keys = displayTexts.keySet().iterator();
+ while (keys.hasNext()) {
+ String paramName = DataUtil.getString(keys.next());
+ String displayText = DataUtil.getString(displayTexts.get(paramName));
+ runTask.setParameterDisplayText(paramName, displayText);
}
}
// set app context
- Map context = BirtUtility.getAppContext( request );
- runTask.setAppContext( context );
+ Map context = BirtUtility.getAppContext(request);
+ runTask.setAppContext(context);
// Run report.
- try
- {
- runTask.run( documentName );
- }
- catch ( BirtException e )
- {
+ try {
+ runTask.run(documentName);
+ } catch (BirtException e) {
// clear document file
- File doc = new File( documentName );
- if ( doc != null )
- doc.delete( );
-
- throwDummyException( e );
- }
- finally
- {
+ File doc = new File(documentName);
+ if (doc != null) {
+ doc.delete();
+ }
+ throwDummyException(e);
+ } finally {
// Remove task from http session
- BirtUtility.removeTask( request );
+ BirtUtility.removeTask(request);
// Append errors
- if ( ParameterAccessor.isDesigner( ) )
- BirtUtility.error( request, runTask.getErrors( ) );
+ if (ParameterAccessor.isDesigner()) {
+ BirtUtility.error(request, runTask.getErrors());
+ }
- runTask.close( );
+ runTask.close();
// check for non-fatal errors
- List<Exception> errors = UtilGenerics.cast(runTask.getErrors( ));
- if ( !errors.isEmpty( ) )
- {
+ List<Exception> errors = UtilGenerics.cast(runTask.getErrors());
+ if (!errors.isEmpty()) {
return errors;
}
}
@@ -241,32 +217,31 @@
* java.lang.String, org.eclipse.birt.report.service.api.InputOptions,
* java.util.Map, java.io.OutputStream, java.util.List, java.util.Map)
*/
- public void runAndRenderReport( IViewerReportDesignHandle design,
+ @Override
+ public void runAndRenderReport(IViewerReportDesignHandle design,
String outputDocName, InputOptions options, Map parameters,
- OutputStream out, List activeIds, Map displayTexts )
- throws ReportServiceException
- {
- if ( design == null || design.getDesignObject( ) == null )
- throw new ReportServiceException( BirtResources.getMessage( ResourceConstants.GENERAL_EXCEPTION_NO_REPORT_DESIGN ) );
+ OutputStream out, List activeIds, Map displayTexts) throws ReportServiceException {
- HttpServletRequest request = (HttpServletRequest) options.getOption( InputOptions.OPT_REQUEST );
+ if (design == null || design.getDesignObject() == null) {
+ throw new ReportServiceException(BirtResources.getMessage(ResourceConstants.GENERAL_EXCEPTION_NO_REPORT_DESIGN));
+ }
- try
- {
- ViewerAttributeBean attrBean = (ViewerAttributeBean) request.getAttribute( IBirtConstants.ATTRIBUTE_BEAN );
- String reportTitle = ParameterAccessor.htmlDecode( attrBean.getReportTitle( ) );
- IReportRunnable runnable = (IReportRunnable) design.getDesignObject( );
+ HttpServletRequest request = (HttpServletRequest) options.getOption(InputOptions.OPT_REQUEST);
+
+ try {
+ ViewerAttributeBean attrBean = (ViewerAttributeBean) request.getAttribute(IBirtConstants.ATTRIBUTE_BEAN);
+ String reportTitle = ParameterAccessor.htmlDecode(attrBean.getReportTitle());
+ IReportRunnable runnable = (IReportRunnable) design.getDesignObject();
// get maxRows
Integer maxRows = null;
- if ( ParameterAccessor.isReportParameterExist( request,
- ParameterAccessor.PARAM_MAXROWS ) )
- maxRows = Integer.valueOf( ParameterAccessor.getMaxRows( request ) );
+ if (ParameterAccessor.isReportParameterExist(request, ParameterAccessor.PARAM_MAXROWS)) {
+ maxRows = Integer.valueOf(ParameterAccessor.getMaxRows(request));
+ }
try {
// put all app context from Birt Container to Report Engine Service
- ReportEngineService.getInstance().getEngineConfig().getAppContext().putAll(
- BirtContainer.getReportEngine().getConfig().getAppContext());
+ ReportEngineService.getInstance().getEngineConfig().getAppContext().putAll(BirtContainer.getReportEngine().getConfig().getAppContext());
/*
--- DISABLE JDBC FEATURE
Connection connection = getConnection();
@@ -275,57 +250,21 @@
} catch (Exception e) {
Debug.logError(e, module);
}
- ReportEngineService.getInstance( ).runAndRenderReport( runnable,
- out,
- options,
- parameters,
- null,
- null,
- null,
- displayTexts,
- reportTitle,
- maxRows );
+ ReportEngineService.getInstance().runAndRenderReport(runnable, out, options, parameters, null, null, null, displayTexts, reportTitle, maxRows);
+ } catch (RemoteException e) {
+ throwReportServiceException(e);
}
- catch ( RemoteException e )
- {
- throwReportServiceException( e );
- }
- }
-
- /**
- * get connection
- */
- private Connection getConnection() {
- Connection connection = null;
- try {
- String delegatorGroupHelperName = BirtContainer.getDelegatorGroupHelperName();
- Delegator delegator = BirtContainer.getDelegator();
- Debug.logInfo("Get the JDBC connection from group helper's name:" + delegatorGroupHelperName, module);
- String helperName = delegator.getGroupHelperName(delegatorGroupHelperName); // gets the helper (localderby, localmysql, localpostgres, etc.) for your entity group org.ofbiz
- connection = ConnectionFactory.getConnection(helperName);
- } catch (GenericEntityException e) {
- Debug.logError(e, module);
- } catch (SQLException e) {
- Debug.logError(e, module);
- }
- return connection;
}
/**
* @param e
* @throws DummyRemoteException
*/
- private void throwDummyException( Exception e )
- throws DummyRemoteException
- {
- if ( e instanceof ReportServiceException )
- {
+ private void throwDummyException(Exception e) throws DummyRemoteException {
+ if (e instanceof ReportServiceException) {
throw new DummyRemoteException(e);
- }
- else
- {
- throw new DummyRemoteException( new ReportServiceException( e
- .getLocalizedMessage( ), e ) );
+ } else {
+ throw new DummyRemoteException(new ReportServiceException(e.getLocalizedMessage(), e));
}
}
@@ -333,26 +272,17 @@
* Temporary method for extracting the exception from the
* DummyRemoteException and throwing it.
*/
- private void throwReportServiceException( RemoteException e )
- throws ReportServiceException
- {
+ private void throwReportServiceException(RemoteException e) throws ReportServiceException {
Throwable wrappedException = e;
- if ( e instanceof ReportEngineService.DummyRemoteException )
- {
- wrappedException = e.getCause( );
+ if (e instanceof ReportEngineService.DummyRemoteException) {
+ wrappedException = e.getCause();
}
- if ( wrappedException instanceof ReportServiceException )
- {
+ if (wrappedException instanceof ReportServiceException) {
throw (ReportServiceException) wrappedException;
- }
- else if ( wrappedException != null )
- {
- throw new ReportServiceException( wrappedException.getLocalizedMessage( ),
- wrappedException );
- }
- else
- {
- throw new ReportServiceException( e.getLocalizedMessage( ), e );
+ } else if (wrappedException != null) {
+ throw new ReportServiceException(wrappedException.getLocalizedMessage(), wrappedException);
+ } else {
+ throw new ReportServiceException(e.getLocalizedMessage(), e);
}
}
}
diff --git a/framework/birt/src/org/ofbiz/birt/report/servlet/BirtEngineServlet.java b/framework/birt/src/org/ofbiz/birt/report/servlet/BirtEngineServlet.java
index b2736b9..8821172 100644
--- a/framework/birt/src/org/ofbiz/birt/report/servlet/BirtEngineServlet.java
+++ b/framework/birt/src/org/ofbiz/birt/report/servlet/BirtEngineServlet.java
@@ -35,6 +35,7 @@
public final static String module = BirtEngineServlet.class.getName();
+ @Override
protected void __init( ServletConfig config )
{
BirtReportServiceFactory.init( new OFBizBirtViewerReportService( config
@@ -47,6 +48,7 @@
requester.setJSPRootPath( "/webcontent/birt" );
}
+ @Override
protected IContext __getContext( HttpServletRequest request,
HttpServletResponse response ) throws BirtException
{
diff --git a/framework/birt/src/org/ofbiz/birt/report/servlet/BirtViewerServlet.java b/framework/birt/src/org/ofbiz/birt/report/servlet/BirtViewerServlet.java
index a914773..b8bc56c 100644
--- a/framework/birt/src/org/ofbiz/birt/report/servlet/BirtViewerServlet.java
+++ b/framework/birt/src/org/ofbiz/birt/report/servlet/BirtViewerServlet.java
@@ -36,6 +36,7 @@
public final static String module = BirtViewerServlet.class.getName();
+ @Override
protected void __init(ServletConfig config) {
BirtReportServiceFactory.init( new OFBizBirtViewerReportService( config
.getServletContext( ) ) );
@@ -51,6 +52,7 @@
run.setJSPRootPath( "/webcontent/birt" );
}
+ @Override
protected IContext __getContext( HttpServletRequest request,
HttpServletResponse response ) throws BirtException
{
diff --git a/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java b/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java
index 9e5bb57..2566cdf 100644
--- a/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java
+++ b/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java
@@ -18,14 +18,16 @@
*******************************************************************************/
package org.ofbiz.service.engine;
+import static org.ofbiz.base.util.UtilGenerics.cast;
+import groovy.lang.Script;
+
import java.util.Map;
+import javolution.util.FastMap;
+
import org.codehaus.groovy.runtime.InvokerHelper;
-import groovy.lang.Binding;
-import groovy.lang.Script;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.GroovyUtil;
-import static org.ofbiz.base.util.UtilGenerics.cast;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.ModelService;
@@ -63,9 +65,14 @@
if (UtilValidate.isEmpty(modelService.location)) {
throw new GenericServiceException("Cannot run Groovy service with empty location");
}
+ Map<String, Object> params = FastMap.newInstance();
+ params.putAll(context);
+ context.put("parameters", params);
context.put("dctx", dispatcher.getLocalContext(localName));
+ context.put("dispatcher", dispatcher);
+ context.put("delegator", dispatcher.getDelegator());
try {
- Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(this.getLocation(modelService)), new Binding(context));
+ Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(this.getLocation(modelService)), GroovyUtil.getBinding(context));
Object resultObj = null;
if (UtilValidate.isEmpty(modelService.invoke)) {
resultObj = script.run();
diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java b/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
index 58e27fa..d2dd920 100644
--- a/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
+++ b/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
@@ -31,8 +31,6 @@
import javolution.util.FastList;
import javolution.util.FastMap;
-import groovy.lang.Binding;
-
import org.codehaus.groovy.runtime.InvokerHelper;
import org.ofbiz.base.util.BshUtil;
import org.ofbiz.base.util.Debug;
@@ -294,7 +292,7 @@
}
} else if (location.endsWith(".groovy")) {
try {
- groovy.lang.Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(location), new Binding(context));
+ groovy.lang.Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(location), GroovyUtil.getBinding(context));
if (UtilValidate.isEmpty(method)) {
script.run();
} else {
diff --git a/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java b/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java
index 3d73bfa..90b0f0a 100644
--- a/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java
+++ b/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java
@@ -31,7 +31,6 @@
import javolution.util.FastList;
import javolution.util.FastMap;
-import groovy.lang.Binding;
import org.codehaus.groovy.runtime.InvokerHelper;
import org.ofbiz.base.util.BshUtil;
@@ -351,7 +350,7 @@
}
} else if (location.endsWith(".groovy")) {
try {
- groovy.lang.Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(location), new Binding(context));
+ groovy.lang.Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(location), GroovyUtil.getBinding(context));
if (UtilValidate.isEmpty(method)) {
script.run();
} else {
diff --git a/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java b/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java
index 01a2493..a312a79 100644
--- a/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java
+++ b/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java
@@ -33,7 +33,6 @@
import javolution.util.FastList;
import javolution.util.FastMap;
-import groovy.lang.Binding;
import org.codehaus.groovy.runtime.InvokerHelper;
import org.ofbiz.base.util.BshUtil;
@@ -417,7 +416,7 @@
}
} else if (location.endsWith(".groovy")) {
try {
- groovy.lang.Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(location), new Binding(context));
+ groovy.lang.Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(location), GroovyUtil.getBinding(context));
if (UtilValidate.isEmpty(method)) {
script.run();
} else {