Author: sichen
Date: Tue Jan 30 16:07:13 2007
New Revision: 501644
URL: http://svn.apache.org/viewvc?view=rev&rev=501644
Log:
More requirements stuff: Add a summary showing the quantity of products to be
ordered and the distinct product count. Required changing the in-form service
call to bsh script called externally.
Added:
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh
Modified:
ofbiz/trunk/applications/order/servicedef/services_requirement.xml
ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
ofbiz/trunk/applications/order/webapp/ordermgr/requirement/RequirementForms.xml
ofbiz/trunk/applications/order/widget/ordermgr/RequirementScreens.xml
Modified: ofbiz/trunk/applications/order/servicedef/services_requirement.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services_requirement.xml?view=diff&rev=501644&r1=501643&r2=501644
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services_requirement.xml
(original)
+++ ofbiz/trunk/applications/order/servicedef/services_requirement.xml Tue Jan
30 16:07:13 2007
@@ -100,6 +100,8 @@
<attribute mode="IN" name="unassignedRequirements" type="String"
optional="true"/>
<attribute mode="IN" name="currencyUomId" type="String"
optional="true"/>
<attribute mode="OUT" name="requirementsForSupplier"
type="java.util.List" optional="true"/>
+ <attribute mode="OUT" name="distinctProductCount" type="Integer"
optional="true"/>
+ <attribute mode="OUT" name="quantityTotal" type="Double"
optional="true"/>
</service>
<service name="createOrderRequirementCommitment" engine="simple"
auth="true"
location="org/ofbiz/order/order/OrderServices.xml"
invoke="createOrderRequirementCommitment">
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java?view=diff&rev=501644&r1=501643&r2=501644
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
Tue Jan 30 16:07:13 2007
@@ -73,19 +73,23 @@
}
List requirementAndRoles =
delegator.findByAnd("RequirementAndRole", conditions, orderBy);
- // maps to cache the associated suppliers and products data
+ // maps to cache the associated suppliers and products data, so we
don't do redundant DB and service requests
Map suppliers = FastMap.newInstance();
Map gids = FastMap.newInstance();
Map inventories = FastMap.newInstance();
+ // to count quantity and distinct products in list
+ double quantity = 0.0;
+ Set products = new HashSet();
+
// join in fields with extra data about the suppliers and products
List requirements = FastList.newInstance();
for (Iterator iter = requirementAndRoles.iterator();
iter.hasNext(); ) {
+ Map union = FastMap.newInstance();
GenericValue requirement = (GenericValue) iter.next();
String productId = requirement.getString("productId");
partyId = requirement.getString("partyId");
String facilityId = requirement.getString("facilityId");
- Map union = FastMap.newInstance();
// get an available supplier product
String supplierKey = partyId + "^" + productId;
@@ -126,6 +130,10 @@
}
}
+ // keep a running total of distinct products and quantity to
order
+ quantity += requirement.getDouble("quantity").doubleValue();
+ products.add(productId);
+
// add all the requirement fields last, to overwrite any
conflicting fields
union.putAll(requirement.getAllFields());
requirements.add(union);
@@ -133,6 +141,8 @@
Map results = ServiceUtil.returnSuccess();
results.put("requirementsForSupplier", requirements);
+ results.put("distinctProductCount", new Integer(products.size()));
+ results.put("quantityTotal", new Double(quantity));
return results;
} catch (GenericServiceException e) {
Debug.logError(e, module);
Added:
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh?view=auto&rev=501644
==============================================================================
---
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh
(added)
+++
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh
Tue Jan 30 16:07:13 2007
@@ -0,0 +1,24 @@
+/*
+ *
+ * Copyright 2001-2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import org.ofbiz.base.util.UtilMisc;
+
+dispatcher = request.getAttribute("dispatcher");
+prepare = dispatcher.runSync("prepareFind", UtilMisc.toMap("inputFields",
requestParameters, "entityName", "Requirement"));
+results = dispatcher.runSync("getRequirementsForSupplier",
UtilMisc.toMap("requirementConditions", prepare.get("entityConditionList"),
"partyId", requestParameters.get("partyId")));
+context.put("requirementsForSupplier", results.get("requirementsForSupplier"));
+context.put("quantityReport", UtilMisc.toMap("distinctProductCount",
results.get("distinctProductCount"), "quantityTotal",
results.get("quantityTotal")));
Modified:
ofbiz/trunk/applications/order/webapp/ordermgr/requirement/RequirementForms.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/requirement/RequirementForms.xml?view=diff&rev=501644&r1=501643&r2=501644
==============================================================================
---
ofbiz/trunk/applications/order/webapp/ordermgr/requirement/RequirementForms.xml
(original)
+++
ofbiz/trunk/applications/order/webapp/ordermgr/requirement/RequirementForms.xml
Tue Jan 30 16:07:13 2007
@@ -292,17 +292,6 @@
</form>
<form name="ApprovedProductRequirements" type="multi"
use-row-submit="true" target="quickPurchaseOrderEntry" title=""
list-name="requirementsForSupplier"
paginate-target="RequirementsForSupplier"
default-title-style="tableheadtext" default-widget-style="tabletext"
default-tooltip-style="tabletext">
- <actions>
- <service service-name="prepareFind"
result-map-name="resultConditions">
- <field-map field-name="inputFields"
env-name="requestParameters"/>
- <field-map field-name="entityName" value="Requirement"/>
- </service>
- <service service-name="getRequirementsForSupplier"
result-map-name="result" result-map-list-name="requirementsForSupplier">
- <!--<field-map field-name="orderByList"
env-name="resultConditions.orderByList"/>-->
- <field-map field-name="requirementConditions"
env-name="resultConditions.entityConditionList"/>
- <field-map field-name="partyId" env-name="parameters.partyId"/>
- </service>
- </actions>
<field name="billToCustomerPartyId"><hidden
value="${parameters.billToCustomerPartyId}"/></field>
<field name="supplierPartyId"><hidden
value="${parameters.partyId}"/></field>
<field name="requirementId" widget-style="buttontext">
@@ -326,6 +315,11 @@
<field name="comments"><display/></field>
<field name="_rowSubmit"
title="${uiLabelMap.CommonSelect}"><check/></field>
<field name="submitButton"
title="${uiLabelMap.OrderInputQuickPurchaseOrder}"
widget-style="smallSubmit"><submit/></field>
+ </form>
+ <form name="ApprovedProductRequirementsSummary" type="single"
default-map-name="quantityReport"
+ default-title-style="tableheadtext" default-widget-style="tabletext"
default-tooltip-style="tabletext">
+ <field name="distinctProductCount"><display/></field>
+ <field name="quantityTotal"><display/></field>
</form>
<form name="ApprovedProductRequirementsByVendor" type="list"
list-name="requirements"
default-title-style="tableheadtext" default-widget-style="tabletext"
default-tooltip-style="tabletext"
Modified: ofbiz/trunk/applications/order/widget/ordermgr/RequirementScreens.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/RequirementScreens.xml?view=diff&rev=501644&r1=501643&r2=501644
==============================================================================
--- ofbiz/trunk/applications/order/widget/ordermgr/RequirementScreens.xml
(original)
+++ ofbiz/trunk/applications/order/widget/ordermgr/RequirementScreens.xml Tue
Jan 30 16:07:13 2007
@@ -134,6 +134,7 @@
<set field="viewIndex" from-field="parameters.VIEW_INDEX"
type="Integer"/>
<set field="viewSize" from-field="parameters.VIEW_SIZE"
type="Integer" default-value="50"/>
<set field="_rowSubmit" value="Y"/>
+ <script
location="component://order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh"/>
</actions>
<widgets>
<decorator-screen name="CommonRequirementsDecorator">
@@ -160,6 +161,7 @@
<label style="head2" text="Requirement
List"/>
</container>
<include-form
name="ApprovedProductRequirements"
location="component://order/webapp/ordermgr/requirement/RequirementForms.xml"/>
+ <include-form
name="ApprovedProductRequirementsSummary"
location="component://order/webapp/ordermgr/requirement/RequirementForms.xml"/>
</widgets>
<fail-widgets>
<include-form
name="ApprovedProductRequirementsList"
location="component://order/webapp/ordermgr/requirement/RequirementForms.xml"/>