Author: jacopoc
Date: Sun Feb 14 12:49:55 2010
New Revision: 910004
URL: http://svn.apache.org/viewvc?rev=910004&view=rev
Log:
Added two new automated tests for production runs; fixed a bug (header costs
not considered by the getProductionRunCost service) and adjusted automated test
accordingly.
Modified:
ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/test/ProductionRunTests.xml
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
Modified:
ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/test/ProductionRunTests.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/test/ProductionRunTests.xml?rev=910004&r1=910003&r2=910004&view=diff
==============================================================================
---
ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/test/ProductionRunTests.xml
(original)
+++
ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/test/ProductionRunTests.xml
Sun Feb 14 12:49:55 2010
@@ -566,7 +566,7 @@
<result-to-field result-name="totalCost"/>
</call-service>
<assert>
- <if-compare field="totalCost" operator="equals" value="135.67"
type="BigDecimal"/>
+ <if-compare field="totalCost" operator="equals" value="142.4535"
type="BigDecimal"/>
</assert>
<set field="postedTotalAmount" value="0.0" type="BigDecimal"/>
@@ -719,4 +719,115 @@
<check-errors/>
</simple-method>
+ <simple-method method-name="testQuickRunProductionRun"
short-description="Test the quick execution of a production run"
login-required="false">
+ <set field="productId" value="PROD_MANUF"/>
+ <set field="facilityId" value="WebStoreWarehouse"/>
+ <set field="quantity" value="1.0" type="BigDecimal"/>
+ <now-timestamp field="nowTimestamp"/>
+ <set-calendar field="productionRunStartDate" from-field="nowTimestamp"
days="1"/>
+
+ <entity-one entity-name="UserLogin" value-field="userLogin">
+ <field-map field-name="userLoginId" value="admin"/>
+ </entity-one>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productId" from-field="productId"/>
+ <set field="serviceCtx.pRQuantity" from-field="quantity"/>
+ <set field="serviceCtx.startDate" from-field="productionRunStartDate"/>
+ <set field="serviceCtx.facilityId" from-field="facilityId"/>
+
+ <!-- production run -->
+ <call-service service-name="createProductionRun"
in-map-name="serviceCtx">
+ <result-to-field result-name="productionRunId"/>
+ </call-service>
+ <clear-field field="serviceCtx"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productionRunId" from-field="productionRunId"/>
+ <set field="serviceCtx.statusId" value="PRUN_DOC_PRINTED"/>
+ <call-service service-name="quickChangeProductionRunStatus"
in-map-name="serviceCtx"/>
+ <clear-field field="serviceCtx"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productionRunId" from-field="productionRunId"/>
+ <call-service service-name="quickRunAllProductionRunTasks"
in-map-name="serviceCtx"/>
+ <clear-field field="serviceCtx"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.workEffortId" from-field="productionRunId"/>
+ <call-service service-name="getProductionRunCost"
in-map-name="serviceCtx">
+ <result-to-field result-name="totalCost"/>
+ </call-service>
+ <assert>
+ <if-compare field="totalCost" operator="equals" value="84.00"
type="BigDecimal"/>
+ </assert>
+
+ <entity-one entity-name="WorkEffort" value-field="productionRunHeader">
+ <field-map field-name="workEffortId" from-field="productionRunId"/>
+ </entity-one>
+ <entity-and list="productionRunTasks" entity-name="WorkEffort">
+ <field-map field-name="workEffortParentId"
from-field="productionRunId"/>
+ </entity-and>
+ <first-from-list entry="productionRunTask" list="productionRunTasks"/>
+
+ <assert>
+ <if-compare field="productionRunHeader.currentStatusId"
operator="equals" value="PRUN_COMPLETED"/>
+ <if-compare field="productionRunTask.currentStatusId"
operator="equals" value="PRUN_COMPLETED"/>
+ </assert>
+ <check-errors/>
+ </simple-method>
+
+ <simple-method method-name="testQuickCloseProductionRun"
short-description="Test the quick finalization of a production run"
login-required="false">
+ <set field="productId" value="PROD_MANUF"/>
+ <set field="facilityId" value="WebStoreWarehouse"/>
+ <set field="quantity" value="1.0" type="BigDecimal"/>
+ <now-timestamp field="nowTimestamp"/>
+ <set-calendar field="productionRunStartDate" from-field="nowTimestamp"
days="1"/>
+
+ <entity-one entity-name="UserLogin" value-field="userLogin">
+ <field-map field-name="userLoginId" value="admin"/>
+ </entity-one>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productId" from-field="productId"/>
+ <set field="serviceCtx.pRQuantity" from-field="quantity"/>
+ <set field="serviceCtx.startDate" from-field="productionRunStartDate"/>
+ <set field="serviceCtx.facilityId" from-field="facilityId"/>
+
+ <!-- production run -->
+ <call-service service-name="createProductionRun"
in-map-name="serviceCtx">
+ <result-to-field result-name="productionRunId"/>
+ </call-service>
+ <clear-field field="serviceCtx"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productionRunId" from-field="productionRunId"/>
+ <set field="serviceCtx.statusId" value="PRUN_DOC_PRINTED"/>
+ <call-service service-name="quickChangeProductionRunStatus"
in-map-name="serviceCtx"/>
+ <clear-field field="serviceCtx"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productionRunId" from-field="productionRunId"/>
+ <set field="serviceCtx.statusId" value="PRUN_CLOSED"/>
+ <call-service service-name="quickChangeProductionRunStatus"
in-map-name="serviceCtx"/>
+ <clear-field field="serviceCtx"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.workEffortId" from-field="productionRunId"/>
+ <call-service service-name="getProductionRunCost"
in-map-name="serviceCtx">
+ <result-to-field result-name="totalCost"/>
+ </call-service>
+ <assert>
+ <if-compare field="totalCost" operator="equals" value="84.00"
type="BigDecimal"/>
+ </assert>
+
+ <entity-one entity-name="WorkEffort" value-field="productionRunHeader">
+ <field-map field-name="workEffortId" from-field="productionRunId"/>
+ </entity-one>
+ <entity-and list="productionRunTasks" entity-name="WorkEffort">
+ <field-map field-name="workEffortParentId"
from-field="productionRunId"/>
+ </entity-and>
+ <first-from-list entry="productionRunTask" list="productionRunTasks"/>
+
+ <assert>
+ <if-compare field="productionRunHeader.currentStatusId"
operator="equals" value="PRUN_CLOSED"/>
+ <if-compare-field field="productionRunHeader.quantityProduced"
operator="equals" to-field="quantity"/>
+ <if-compare field="productionRunTask.currentStatusId"
operator="equals" value="PRUN_CLOSED"/>
+ <if-compare-field field="productionRunTask.quantityProduced"
operator="equals" to-field="quantity"/>
+ </assert>
+
+ <check-errors/>
+ </simple-method>
</simple-methods>
\ No newline at end of file
Modified:
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=910004&r1=910003&r2=910004&view=diff
==============================================================================
---
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
(original)
+++
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
Sun Feb 14 12:49:55 2010
@@ -986,9 +986,12 @@
List tasks = delegator.findByAnd("WorkEffort",
UtilMisc.toMap("workEffortParentId", workEffortId),
UtilMisc.toList("workEffortId"));
Iterator tasksIt = tasks.iterator();
BigDecimal totalCost = ZERO;
+ Map outputMap = dispatcher.runSync("getWorkEffortCosts",
UtilMisc.<String, Object>toMap("userLogin", userLogin, "workEffortId",
workEffortId));
+ BigDecimal productionRunHeaderCost =
(BigDecimal)outputMap.get("totalCost");
+ totalCost = totalCost.add(productionRunHeaderCost);
while (tasksIt.hasNext()) {
GenericValue task = (GenericValue)tasksIt.next();
- Map outputMap = dispatcher.runSync("getWorkEffortCosts",
UtilMisc.<String, Object>toMap("userLogin", userLogin, "workEffortId",
task.getString("workEffortId")));
+ outputMap = dispatcher.runSync("getWorkEffortCosts",
UtilMisc.<String, Object>toMap("userLogin", userLogin, "workEffortId",
task.getString("workEffortId")));
BigDecimal taskCost = (BigDecimal)outputMap.get("totalCost");
totalCost = totalCost.add(taskCost);
}