Added report for open order items. Basically allows one to see what orders have unshipped items.

git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@450266 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Si Chen
2006-09-27 00:26:12 +00:00
parent 0f7be6efdf
commit 3aeda4a8a3
6 changed files with 188 additions and 0 deletions
@@ -335,6 +335,7 @@ OrderRemaining = Remaining
OrderRemainingSubTotal = Remaining SubTotal
OrderRemoveSelected=Remove Selected
OrderReports=Order Reports
OrderReportOpenOrderItems=Open Order Items Report
OrderReportPurchasesByOrganization=Purchases by Organization Report
OrderReportPurchasesByPaymentMethod=Purchases by Payment Method Report
OrderReportPurchasesByProduct=Purchases by Product Report
@@ -0,0 +1,116 @@
/*
*
* 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.
*/
/*
* Script to build the open order item report.
*
* The idea is to fetch the OrderHeaders of the search criteria,
* then show the open quantities of the related OrderItems that
* have not been completed, cancelled or rejected.
*
* @author Leon Torres (leon@opensourcestrategies.com)
*/
import javolution.util.FastList;
import javolution.util.FastMap;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.condition.*;
productStoreId = parameters.get("productStoreId");
orderTypeId = parameters.get("orderTypeId");
orderStatusId = parameters.get("orderStatusId");
// search by orderTypeId is mandatory
conditions = UtilMisc.toList(new EntityExpr("orderTypeId", EntityOperator.EQUALS, orderTypeId));
if (productStoreId != null && productStoreId.length() > 0) {
conditions.add(new EntityExpr("productStoreId", EntityOperator.EQUALS, productStoreId));
// for generating a title (given product store)
context.put("productStore", delegator.findByPrimaryKeyCache("ProductStore", UtilMisc.toMap("productStoreId", productStoreId)));
} else {
// for generating a title (all stores) TODO: use UtilProperties to internationalize
context.put("productStore", UtilMisc.toMap("storeName", "All Stores"));
}
if (orderStatusId != null && orderStatusId.length() > 0) {
conditions.add(new EntityExpr("statusId", EntityOperator.EQUALS, orderStatusId));
} else {
// search all orders that are not completed, cancelled or rejected
conditions.add(
new EntityConditionList( UtilMisc.toList(
new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"),
new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED"),
new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED")
), EntityOperator.AND)
);
}
// First get all orders given the conditions
orderConditions = new EntityConditionList(conditions, EntityOperator.AND);
orders = delegator.findByCondition("OrderHeader", orderConditions, null, null);
orderMap = FastMap.newInstance();
for (iter = orders.iterator(); iter.hasNext(); ) {
order = iter.next();
orderMap.put(order.get("orderId"), order);
}
if (orderMap.size() == 0) return;
// get all related order items
itemConditions = new EntityConditionList( UtilMisc.toList(
new EntityExpr("orderId", EntityOperator.IN, orderMap.keySet()),
new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ITEM_COMPLETED"),
new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED"),
new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED")
), EntityOperator.AND);
orderItems = delegator.findByCondition("OrderItem", itemConditions, null, null);
// build a list of orderItem maps for reporting that is a union of OrderItem, OrderHeader, and other info
reportData = FastList.newInstance();
for (iter = orderItems.iterator(); iter.hasNext(); ) {
orderItem = iter.next();
// add order item fields
data = FastMap.newInstance();
data.putAll( orderItem.getAllFields() );
// add order header fields
order = orderMap.get(orderItem.get("orderId"));
data.put("productStoreId", order.get("productStoreId"));
data.put("orderDate", order.get("orderDate"));
// compute quantity
quantity = orderItem.getDouble("quantity");
cancelQuantity = orderItem.getDouble("cancelQuantity");
quantityNet = 0;
if (quantity != null) quantityNet += quantity.doubleValue();
if (cancelQuantity != null) quantityNet -= cancelQuantity.doubleValue();
data.put("quantityNet", new Double(quantityNet));
// compute issued
issuances = orderItem.getRelated("ItemIssuance", UtilMisc.toList("quantity"));
double quantityIssued = 0;
for (subiter = issuances.iterator(); subiter.hasNext(); ) {
quantityIssued += subiter.next().getDouble("quantity").doubleValue();
}
data.put("quantityIssued", new Double(quantityIssued));
// compute open
data.put("quantityOpen", new Double(quantityNet - quantityIssued));
reportData.add(data);
}
context.put("orderItems", reportData);
@@ -943,6 +943,9 @@
<request-map uri="SalesByStoreReport.pdf"><security https="true" auth="true"/>
<response name="success" type="view" value="SalesByStoreReport"/>
</request-map>
<request-map uri="OpenOrderItemsReport"><security https="true" auth="true"/>
<response name="success" type="view" value="OpenOrderItemsReport"/>
</request-map>
<request-map uri="PurchasesByOrganizationReport.pdf"><security https="true" auth="true"/>
<response name="success" type="view" value="PurchasesByOrganizationReport"/>
</request-map>
@@ -1436,6 +1439,7 @@
<view-map name="OrderPurchaseReportPayment" type="screenfop" page="component://order/widget/ordermgr/ReportScreens.xml#OrderPurchaseReportPayment" content-type="application/pdf" encoding="none"/>
<view-map name="OrderPurchaseReportProduct" type="screenfop" page="component://order/widget/ordermgr/ReportScreens.xml#OrderPurchaseReportProduct" content-type="application/pdf" encoding="none"/>
<view-map name="SalesByStoreReport" type="screenfop" page="component://order/widget/ordermgr/ReportScreens.xml#SalesByStoreReport" content-type="application/pdf" encoding="none"/>
<view-map name="OpenOrderItemsReport" type="screen" page="component://order/widget/ordermgr/ReportScreens.xml#OpenOrderItemsReport"/>
<view-map name="PurchasesByOrganizationReport" type="screenfop" page="component://order/widget/ordermgr/ReportScreens.xml#PurchasesByOrganizationReport" content-type="application/pdf" encoding="none"/>
<view-map name="FindRequirements" type="screen" page="component://order/widget/ordermgr/RequirementScreens.xml#FindRequirements"/>
@@ -99,6 +99,49 @@ under the License.
<field name="submitButton" title="${uiLabelMap.CommonRun}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
<!-- form for generating a report of open order items -->
<form name="OpenOrderItemsReport" type="single" target="OpenOrderItemsReport" title=""
default-title-style="tableheadtext" default-widget-style="inputBox" default-tooltip-style="tabletext">
<field name="productStoreId">
<drop-down allow-empty="false">
<option key="" description="- ${uiLabelMap.CommonSelectAny} -"/>
<entity-options entity-name="ProductStore" description="${storeName} [${productStoreId}]">
<entity-order-by field-name="storeName"/>
</entity-options>
</drop-down>
</field>
<field name="orderTypeId">
<drop-down allow-empty="false">
<option key="SALES_ORDER" description="${uiLabelMap.OrderSalesOrder}"/>
<option key="PURCHASE_ORDER" description="${uiLabelMap.OrderPurchaseOrder}"/>
</drop-down>
</field>
<field name="orderStatusId">
<drop-down allow-empty="false">
<option key="" description="- ${uiLabelMap.CommonSelectAny} -"/>
<entity-options entity-name="StatusItem" description="${description}" key-field-name="statusId">
<entity-constraint name="statusTypeId" operator="equals" value="ORDER_STATUS"/>
</entity-options>
</drop-down>
</field>
<field name="submitButton" title="${uiLabelMap.CommonRun}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
<!-- list open order items -->
<form name="OpenOrderItemsList" type="list" list-name="orderItems"
default-title-style="tableheadtext" default-widget-style="tabletext" default-tooltip-style="tabletext">
<field name="orderId" title="${uiLabelMap.OrderOrderId}" widget-style="buttontext">
<hyperlink target="orderview?$orderId=${orderId}" description="${orderId}"/>
</field>
<field name="productId" title="${uiLabelMap.ProductProduct}"><display/></field>
<field name="quantityNet" title="${uiLabelMap.ProductQuantity}"><display/></field>
<field name="quantityIssued" title="${uiLabelMap.OrderQtyShipped}"><display/></field>
<field name="quantityOpen" title="${uiLabelMap.ProductOpenQuantity}"><display/></field>
<field name="shipAfterDate" title="${uiLabelMap.OrderShipAfterDate}"><display/></field>
<field name="shipBeforeDate" title="${uiLabelMap.OrderShipBeforeDate}"><display/></field>
<field name="comments" title="${uiLabelMap.CommonComments}"><display/></field>
</form>
<!-- form for generating a report of total product purchases (quantity and value) -->
<form name="PurchasesByOrganizationReport" type="single" target="PurchasesByOrganizationReport.pdf" title=""
default-title-style="tableheadtext" default-widget-style="inputBox" default-tooltip-style="tabletext">
@@ -35,6 +35,10 @@ under the License.
<label style="head2" text="${uiLabelMap.OrderReportSalesByStore}"/>
<include-form name="SalesByStoreReport" location="component://order/widget/ordermgr/ReportForms.xml"/>
</container>
<container>
<label style="head2" text="${uiLabelMap.OrderReportOpenOrderItems}"/>
<include-form name="OpenOrderItemsReport" location="component://order/widget/ordermgr/ReportForms.xml"/>
</container>
<container>
<label style="head2" text="${uiLabelMap.OrderReportPurchasesByOrganization}"/>
<include-form name="PurchasesByOrganizationReport" location="component://order/widget/ordermgr/ReportForms.xml"/>
@@ -175,6 +179,25 @@ under the License.
</section>
</screen>
<!-- generates report of open order items -->
<screen name="OpenOrderItemsReport">
<section>
<actions>
<set field="titleProperty" value="OrderReportOpenOrderItems"/>
<set field="headerItem" value="reports"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh"/>
</actions>
<widgets>
<decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
<decorator-section name="body">
<label style="head2" text="${uiLabelMap.OrderReportOpenOrderItems} - ${productStore.storeName}"/>
<include-form name="OpenOrderItemsList" location="component://order/widget/ordermgr/ReportForms.xml"/>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<!-- generates the pdf for report of purchases by organization, grouped by product -->
<screen name="PurchasesByOrganizationReport">
<section>
@@ -846,6 +846,7 @@ ProductOemPartyName=Product OEM Name
ProductOemProductId=ID at the manufacturer
ProductOneInventoryFacility=One Inventory Facility
ProductOnlyAppliesWithinSpan=only applies if within span
ProductOpenQuantity=Open
ProductOptional=Optional
ProductOptionalCreateNew=optional will create new if empty
ProductOptionalExpirationDate=Optional Expiration Date