svn commit: r1858270 [1/3] - in /ofbiz/ofbiz-framework/trunk/applications: datamodel/data/demo/ datamodel/data/seed/ datamodel/entitydef/ order/config/ order/data/ order/entitydef/ order/groovyScripts/allocationplan/ order/servicedef/ order/src/main/ja...

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

svn commit: r1858270 [1/3] - in /ofbiz/ofbiz-framework/trunk/applications: datamodel/data/demo/ datamodel/data/seed/ datamodel/entitydef/ order/config/ order/data/ order/entitydef/ order/groovyScripts/allocationplan/ order/servicedef/ order/src/main/ja...

surajk
Author: surajk
Date: Sat Apr 27 13:05:30 2019
New Revision: 1858270

URL: http://svn.apache.org/viewvc?rev=1858270&view=rev
Log:
Improved: Added support for Inventory (Supply) Allocation Planning.
(OFBIZ-10518)
Thanks Deepak Nigam for initiating this feature and providng the patches, Arun Patidar for review and Swapnil Shah for design discussions.

Added:
    ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/
    ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/CreateAllocationPlan.groovy   (with props)
    ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ListAllocationPlan.groovy   (with props)
    ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ViewAllocationPlan.groovy   (with props)
    ofbiz/ofbiz-framework/trunk/applications/order/template/order/CreateAllocationPlan.ftl   (with props)
    ofbiz/ofbiz-framework/trunk/applications/order/template/order/ViewAllocationPlan.ftl   (with props)
    ofbiz/ofbiz-framework/trunk/applications/order/widget/ordermgr/AllocationPlanForms.xml   (with props)
    ofbiz/ofbiz-framework/trunk/applications/order/widget/ordermgr/AllocationPlanScreens.xml   (with props)
Modified:
    ofbiz/ofbiz-framework/trunk/applications/datamodel/data/demo/OrderDemoData.xml
    ofbiz/ofbiz-framework/trunk/applications/datamodel/data/seed/OrderSeedData.xml
    ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/order-entitymodel.xml
    ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/product-entitymodel.xml
    ofbiz/ofbiz-framework/trunk/applications/order/config/OrderErrorUiLabels.xml
    ofbiz/ofbiz-framework/trunk/applications/order/config/OrderUiLabels.xml
    ofbiz/ofbiz-framework/trunk/applications/order/data/OrderSecurityPermissionSeedData.xml
    ofbiz/ofbiz-framework/trunk/applications/order/entitydef/entitymodel_view.xml
    ofbiz/ofbiz-framework/trunk/applications/order/servicedef/secas.xml
    ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services.xml
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
    ofbiz/ofbiz-framework/trunk/applications/order/template/entry/cart/ShowCart.ftl
    ofbiz/ofbiz-framework/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    ofbiz/ofbiz-framework/trunk/applications/order/widget/ordermgr/OrderMenus.xml
    ofbiz/ofbiz-framework/trunk/applications/product/minilang/product/inventory/InventoryServices.xml
    ofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_facility.xml

Modified: ofbiz/ofbiz-framework/trunk/applications/datamodel/data/demo/OrderDemoData.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/datamodel/data/demo/OrderDemoData.xml?rev=1858270&r1=1858269&r2=1858270&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/datamodel/data/demo/OrderDemoData.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/datamodel/data/demo/OrderDemoData.xml Sat Apr 27 13:05:30 2019
@@ -123,6 +123,12 @@ under the License.
     <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="ORDERENTRY_ALL" permissionId="OFBTOOLS_VIEW"/>
     <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="ORDERENTRY_ALL" permissionId="ORDERMGR_CRQ_CREATE"/>
 
+    <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="FULLADMIN" permissionId="ALLOCPLAN_CREATE"/>
+    <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="FULLADMIN" permissionId="ALLOCPLAN_UPDATE"/>
+    <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="FULLADMIN" permissionId="ALLOCPLAN_APPROVE"/>
+    <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="FULLADMIN" permissionId="ALLOCPLAN_CANCEL"/>
+    <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="FULLADMIN" permissionId="ALLOCPLAN_VIEW"/>
+
     <!-- Order Demo User Data -->
     <UserLogin userLoginId="DemoBuyer" currentPassword="{SHA}47b56994cbc2b6d10aa1be30f70165adb305a41a"/>
     <UserLogin userLoginId="DemoRepAll" currentPassword="{SHA}47b56994cbc2b6d10aa1be30f70165adb305a41a"/>

Modified: ofbiz/ofbiz-framework/trunk/applications/datamodel/data/seed/OrderSeedData.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/datamodel/data/seed/OrderSeedData.xml?rev=1858270&r1=1858269&r2=1858270&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/datamodel/data/seed/OrderSeedData.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/datamodel/data/seed/OrderSeedData.xml Sat Apr 27 13:05:30 2019
@@ -377,4 +377,29 @@ under the License.
     <WorkReqFulfType description="Tests" workReqFulfTypeId="WRF_TESTS"/>
     <WorkReqFulfType description="Delivers" workReqFulfTypeId="WRF_DELIVERS"/>
 
+    <!--Sales Allocation Planning -->
+    <AllocationPlanType description="Sales Order Allocation Plan" hasTable="N" planTypeId="SALES_ORD_ALLOCATION"/>
+    <StatusType description="Allocation Plan Status" hasTable="N" statusTypeId="ALLOC_PLAN_STATUS"/>
+    <StatusType description="Allocation Plan Item Status" hasTable="N" parentTypeId="ALLOC_PLAN_STATUS" statusTypeId="ALLOC_PLAN_ITEM_STTS"/>
+    <EnumerationType description="Allocation Plan Method" enumTypeId="ALLOC_PLAN_METHOD" hasTable="N"/>
+    <StatusItem description="Created" sequenceId="01" statusCode="CREATED" statusId="ALLOC_PLAN_CREATED" statusTypeId="ALLOC_PLAN_STATUS"/>
+    <StatusItem description="Approved" sequenceId="02" statusCode="APPROVED" statusId="ALLOC_PLAN_APPROVED" statusTypeId="ALLOC_PLAN_STATUS"/>
+    <StatusItem description="Completed" sequenceId="03" statusCode="COMPLETED" statusId="ALLOC_PLAN_COMPLETED" statusTypeId="ALLOC_PLAN_STATUS"/>
+    <StatusItem description="Cancelled" sequenceId="04" statusCode="CANCELLED" statusId="ALLOC_PLAN_CANCELLED" statusTypeId="ALLOC_PLAN_STATUS"/>
+    <StatusItem description="Created" sequenceId="01" statusCode="CREATED" statusId="ALLOC_PLAN_ITEM_CRTD" statusTypeId="ALLOC_PLAN_ITEM_STTS"/>
+    <StatusItem description="Approved" sequenceId="02" statusCode="APPROVED" statusId="ALLOC_PLAN_ITEM_APRV" statusTypeId="ALLOC_PLAN_ITEM_STTS"/>
+    <StatusItem description="Completed" sequenceId="03" statusCode="COMPLETED" statusId="ALLOC_PLAN_ITEM_CMPL" statusTypeId="ALLOC_PLAN_ITEM_STTS"/>
+    <StatusItem description="Cancelled" sequenceId="04" statusCode="CANCELLED" statusId="ALLOC_PLAN_ITEM_CNCL" statusTypeId="ALLOC_PLAN_ITEM_STTS"/>
+    <Enumeration description="Auto" enumCode="AUTO" enumId="AUTO" enumTypeId="ALLOC_PLAN_METHOD" sequenceId="01"/>
+    <Enumeration description="Manual" enumCode="MANUAL" enumId="MANUAL" enumTypeId="ALLOC_PLAN_METHOD" sequenceId="02"/>
+    <StatusValidChange statusId='ALLOC_PLAN_CREATED' statusIdTo='ALLOC_PLAN_APPROVED' transitionName='Approve'/>
+    <StatusValidChange statusId='ALLOC_PLAN_CREATED' statusIdTo='ALLOC_PLAN_CANCELLED' transitionName='Cancel'/>
+    <StatusValidChange statusId='ALLOC_PLAN_APPROVED' statusIdTo='ALLOC_PLAN_CREATED' transitionName='Create'/>
+    <StatusValidChange statusId='ALLOC_PLAN_APPROVED' statusIdTo='ALLOC_PLAN_COMPLETED' transitionName='Complete'/>
+    <StatusValidChange statusId='ALLOC_PLAN_APPROVED' statusIdTo='ALLOC_PLAN_CANCELLED' transitionName='Cancel'/>
+    <StatusValidChange statusId='ALLOC_PLAN_ITEM_CRTD' statusIdTo='ALLOC_PLAN_ITEM_APRV' transitionName='Approve'/>
+    <StatusValidChange statusId='ALLOC_PLAN_ITEM_CRTD' statusIdTo='ALLOC_PLAN_ITEM_CNCL' transitionName='Cancel'/>
+    <StatusValidChange statusId='ALLOC_PLAN_ITEM_APRV' statusIdTo='ALLOC_PLAN_ITEM_CRTD' transitionName='Create'/>
+    <StatusValidChange statusId='ALLOC_PLAN_ITEM_APRV' statusIdTo='ALLOC_PLAN_ITEM_CMPL' transitionName='Complete'/>
+    <StatusValidChange statusId='ALLOC_PLAN_ITEM_APRV' statusIdTo='ALLOC_PLAN_ITEM_CNCL' transitionName='Cancel'/>
 </entity-engine-xml>
\ No newline at end of file

Modified: ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/order-entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/order-entitymodel.xml?rev=1858270&r1=1858269&r2=1858270&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/order-entitymodel.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/order-entitymodel.xml Sat Apr 27 13:05:30 2019
@@ -2974,5 +2974,106 @@ under the License.
             <key-map field-name="workEffortId"/>
         </relation>
     </entity>
- </entitymodel>
-
+    <entity entity-name="AllocationPlanType"
+            package-name="org.apache.ofbiz.order.allocationplan"
+            title="Allocation Plan Type Entity">
+        <field name="planTypeId" type="id"/>
+        <field name="description" type="description"/>
+        <field name="hasTable" type="indicator"/>
+        <prim-key field="planTypeId"/>
+    </entity>
+    <entity entity-name="AllocationPlanHeader"
+            package-name="org.apache.ofbiz.order.allocationplan"
+            title="Allocation Plan Header Entity">
+        <field name="planId" type="id"/>
+        <field name="productId" type="id"/>
+        <field name="planTypeId" type="id"/>
+        <field name="planName" type="name"/>
+        <field name="statusId" type="id"/>
+        <field name="createdByUserLogin" type="id-vlong"/>
+        <field name="lastModifiedByUserLogin" type="id-vlong"/>
+        <prim-key field="planId"/>
+        <prim-key field="productId"/>
+        <relation type="many" fk-name="ALC_PLN_HDR_PRO" title="Product Id" rel-entity-name="Product">
+            <key-map field-name="productId"/>
+        </relation>
+        <relation type="one" fk-name="ALC_PLN_HDR_TYP" title="Plan Type Id" rel-entity-name="AllocationPlanType">
+            <key-map field-name="planTypeId"/>
+        </relation>
+        <relation type="one" fk-name="ALC_PLN_HDR_STS" title="Status Id" rel-entity-name="StatusItem">
+            <key-map field-name="statusId" rel-field-name="statusId"/>
+        </relation>
+        <relation type="one" fk-name="ALC_PLN_HDR_CBUL" title="Created By" rel-entity-name="UserLogin">
+            <key-map field-name="createdByUserLogin" rel-field-name="userLoginId"/>
+        </relation>
+        <relation type="one" fk-name="ALC_PLN_HDR_LMUL" title="Last Modified By" rel-entity-name="UserLogin">
+            <key-map field-name="lastModifiedByUserLogin" rel-field-name="userLoginId"/>
+        </relation>
+    </entity>
+    <entity entity-name="AllocationPlanItem"
+            package-name="org.apache.ofbiz.order.allocationplan"
+            title="Allocation Plan Item Entity">
+        <field name="planId" type="id"/>
+        <field name="planItemSeqId" type="id"/>
+        <field name="statusId" type="id"/>
+        <field name="planMethodEnumId" type="id"/>
+        <field name="orderId" type="id"/>
+        <field name="orderItemSeqId" type="id"/>
+        <field name="productId" type="id"/>
+        <field name="allocatedQuantity" type="fixed-point"/>
+        <field name="prioritySeqId" type="id"/>
+        <field name="createdByUserLogin" type="id-vlong"/>
+        <field name="lastModifiedByUserLogin" type="id-vlong"/>
+        <prim-key field="planId"/>
+        <prim-key field="planItemSeqId"/>
+        <prim-key field="productId"/>
+        <relation type="one" fk-name="ALC_PLN_ITM_HDR" title="Plan Id" rel-entity-name="AllocationPlanHeader">
+            <key-map field-name="planId"/>
+            <key-map field-name="productId"/>
+        </relation>
+        <relation type="one" fk-name="ALC_PLN_ITM_ODRHDR" title="Order Id" rel-entity-name="OrderHeader">
+            <key-map field-name="orderId"/>
+        </relation>
+        <relation type="one" fk-name="ALC_PLN_ITM_ODRITM" title="Order Item" rel-entity-name="OrderItem">
+            <key-map field-name="orderId"/>
+            <key-map field-name="orderItemSeqId"/>
+        </relation>
+        <relation type="many" fk-name="ALC_PLN_ITM_PRO" title="Product Id" rel-entity-name="Product">
+            <key-map field-name="productId"/>
+        </relation>
+        <relation type="one" fk-name="ALC_PLN_ITM_STS" title="Plan Item Status Id" rel-entity-name="StatusItem">
+            <key-map field-name="statusId" rel-field-name="statusId"/>
+        </relation>
+        <relation type="one" fk-name="ALC_PLN_ITM_ENUM" title="Plan Method Enum Id" rel-entity-name="Enumeration">
+            <key-map field-name="planMethodEnumId" rel-field-name="enumId"/>
+        </relation>
+        <relation type="one" fk-name="ALC_PLN_ITM_CBUL" title="Created By User Login" rel-entity-name="UserLogin">
+            <key-map field-name="createdByUserLogin" rel-field-name="userLoginId"/>
+        </relation>
+        <relation type="one" fk-name="ALC_PLN_ITM_LMUL" title="Last Modified By User Login" rel-entity-name="UserLogin">
+            <key-map field-name="lastModifiedByUserLogin" rel-field-name="userLoginId"/>
+        </relation>
+    </entity>
+    <view-entity entity-name="AllocationPlanAndItem"
+                 package-name="org.apache.ofbiz.order.allocationplan"
+                 title="Allocation Plan And Allocation Plan Item View">
+        <member-entity entity-alias="APH" entity-name="AllocationPlanHeader"/>
+        <member-entity entity-alias="API" entity-name="AllocationPlanItem"/>
+        <alias entity-alias="APH" name="planId"/>
+        <alias entity-alias="APH" name="planName"/>
+        <alias entity-alias="APH" name="statusId"/>
+        <alias entity-alias="APH" name="planTypeId"/>
+        <alias entity-alias="APH" name="productId"/>
+        <alias entity-alias="API" name="planItemSeqId"/>
+        <alias entity-alias="API" name="planItemStatusId" field="statusId"/>
+        <alias entity-alias="API" name="orderId"/>
+        <alias entity-alias="API" name="orderItemSeqId"/>
+        <alias entity-alias="API" name="planMethodEnumId"/>
+        <alias entity-alias="API" name="allocatedQuantity"/>
+        <alias entity-alias="API" name="prioritySeqId"/>
+        <view-link entity-alias="APH" rel-entity-alias="API">
+          <key-map field-name="planId"/>
+          <key-map field-name="productId"/>
+        </view-link>
+    </view-entity>
+</entitymodel>
\ No newline at end of file

Modified: ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/product-entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/product-entitymodel.xml?rev=1858270&r1=1858269&r2=1858270&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/product-entitymodel.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/product-entitymodel.xml Sat Apr 27 13:05:30 2019
@@ -3900,6 +3900,7 @@ under the License.
       <field name="showOutOfStockProducts" type="indicator"><description>Default Y. If N then out of stock products will not be displayed on site</description></field>
       <field name="orderDecimalQuantity" type="indicator"><description>use to indicate if decimal quantity can be ordered for this producStore. Default value is Y</description></field>
       <field name="allowComment" type="indicator"><description>Allow comments for order line items per store</description></field>
+      <field name="allocateInventory" type="indicator"><description>Default N. If Y then allocation plans for the product will be created.</description></field>
       <prim-key field="productStoreId"/>
       <relation type="one" fk-name="PROD_STR_PRSTRGP" title="Primary" rel-entity-name="ProductStoreGroup">
         <key-map field-name="primaryStoreGroupId" rel-field-name="productStoreGroupId"/>

Modified: ofbiz/ofbiz-framework/trunk/applications/order/config/OrderErrorUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/config/OrderErrorUiLabels.xml?rev=1858270&r1=1858269&r2=1858270&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/config/OrderErrorUiLabels.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/config/OrderErrorUiLabels.xml Sat Apr 27 13:05:30 2019
@@ -893,6 +893,21 @@
         <value xml:lang="zh">错误:无法存储状态修改: </value>
         <value xml:lang="zh-TW">錯誤:無法存儲狀態修改: </value>
     </property>
+    <property key="OrderErrorAllocationPlanIsNotAvailable">
+        <value xml:lang="en">ERROR : Allocation plan is not available.</value>
+    </property>
+    <property key="OrderErrorCouldNotChangeAllocationPlanItemStatus">
+        <value xml:lang="en">ERROR : Could not change allocation plan item status.</value>
+    </property>
+    <property key="OrderErrorCouldNotChangeAllocationPlanItemStatusStatusIsNotAValidChange">
+        <value xml:lang="en">ERROR : Could not change allocation plan item status; status is not a valid change. </value>
+    </property>
+    <property key="OrderErrorCouldNotChangeAllocationPlanStatus">
+        <value xml:lang="en">ERROR : Could not change allocation plan status.</value>
+    </property>
+    <property key="OrderErrorCouldNotChangeAllocationPlanStatusStatusIsNotAValidChange">
+        <value xml:lang="en">ERROR : Could not change allocation plan status; status is not a valid change. </value>
+    </property>
     <property key="OrderErrorCouldNotChangeItemStatus">
         <value xml:lang="ar">خطأ: لا يمكن تغيير حالة البند</value>
         <value xml:lang="de">FEHLER: Positionsstatus konnte nicht geändert werden : </value>

Modified: ofbiz/ofbiz-framework/trunk/applications/order/config/OrderUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/config/OrderUiLabels.xml?rev=1858270&r1=1858269&r2=1858270&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/config/OrderUiLabels.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/config/OrderUiLabels.xml Sat Apr 27 13:05:30 2019
@@ -2075,6 +2075,27 @@
         <value xml:lang="zh">订单代理人</value>
         <value xml:lang="zh-TW">訂單代理人</value>
     </property>
+    <property key="OrderAllocated">
+        <value xml:lang="en">Allocated</value>
+    </property>
+    <property key="OrderAllocatedUnits">
+        <value xml:lang="en">Allocated Units</value>
+    </property>
+    <property key="OrderAllocatedValue">
+        <value xml:lang="en">Allocated Value</value>
+    </property>
+    <property key="OrderAllocation">
+        <value xml:lang="en">Allocation</value>
+    </property>
+    <property key="OrderAllocationPlan">
+        <value xml:lang="en">Allocation Plan</value>
+    </property>
+    <property key="OrderAllocationPlanNotFound">
+        <value xml:lang="en">Allocation Plan Not Found.</value>
+    </property>
+    <property key="OrderAllocationPlanViewPermissionError">
+        <value xml:lang="en">You do not have the permission to view the allocation plan.</value>
+    </property>
     <property key="OrderAllowSolicitation">
         <value xml:lang="ar">السماح بالإستدعاءات</value>
         <value xml:lang="de">(Werbung gestatten?)</value>
@@ -2246,6 +2267,9 @@
         <value xml:lang="en">Approve Item</value>
         <value xml:lang="nl">Bevestig item</value>
     </property>
+    <property key="OrderApprovePlan">
+        <value xml:lang="en">Approve Plan</value>
+    </property>
     <property key="OrderApproveOrder">
         <value xml:lang="ar">الموافقة على أمر البيع\الشراء</value>
         <value xml:lang="de">Auftrag bestätigen</value>
@@ -2393,6 +2417,9 @@
         <value xml:lang="zh-CN">自动建立调整</value>
         <value xml:lang="zh-TW">自動新建調整</value>
     </property>
+    <property key="OrderAutoReserve">
+        <value xml:lang="en">Auto Reserve</value>
+    </property>
     <property key="OrderAverageRating">
         <value xml:lang="ar">متوسط التقييم</value>
         <value xml:lang="cs">Průměrné hodnocení</value>
@@ -2643,6 +2670,9 @@
         <value xml:lang="zh-CN">取消所有项目</value>
         <value xml:lang="zh-TW">取消全部細項</value>
     </property>
+    <property key="OrderCancelEdit">
+        <value xml:lang="en">Cancel Edit</value>
+    </property>
     <property key="OrderCancelledItemToOrder">
         <value xml:lang="ar">البند الملغى لأمر البيع\الشراء</value>
         <value xml:lang="de">Anullierter Artikel der Bestellung:</value>
@@ -2654,6 +2684,9 @@
         <value xml:lang="zh">已取消明细到订单</value>
         <value xml:lang="zh-TW">已取消細項到訂單:</value>
     </property>
+    <property key="OrderCancelPlan">
+        <value xml:lang="en">Cancel Plan</value>
+    </property>
     <property key="OrderCancelOrder">
         <value xml:lang="ar">إلغاء أمر البيع\الشراء</value>
         <value xml:lang="de">Auftrag stornieren</value>
@@ -3291,6 +3324,9 @@
         <value xml:lang="zh-CN">复制询价</value>
         <value xml:lang="zh-TW">複製報價</value>
     </property>
+    <property key="OrderCreatePlan">
+      <value xml:lang="en">Create Plan</value>
+    </property>
     <property key="OrderCreateTestSalesOrderSingleError">
         <value xml:lang="ar">لا يوجد سلع موجودة في الفئة ${productCategoryId}; لن يتم خلق أمر بيع/شراء</value>
         <value xml:lang="de">Keine Produkte in Kategorie ${productCategoryId} gefunden; Bestellungen werden nicht erstellt</value>
@@ -4501,6 +4537,9 @@
         <value xml:lang="zh">免除金额</value>
         <value xml:lang="zh-TW">免除金額</value>
     </property>
+    <property key="OrderExtValue">
+        <value xml:lang="en">Ext. Value</value>
+    </property>
     <property key="OrderExternalId">
         <value xml:lang="ar">دليل خارجي</value>
         <value xml:lang="de">Externe ID</value>
@@ -6156,6 +6195,9 @@
         <value xml:lang="zh">税前净价</value>
         <value xml:lang="zh-TW">稅前淨價</value>
     </property>
+    <property key="OrderNewAllocationPlan">
+        <value xml:lang="en">New Allocation Plan</value>
+    </property>
     <property key="OrderNewDropShipmentForShipGroup">
         <value xml:lang="de">Neue Direktlieferung für Versandgruppe</value>
         <value xml:lang="en">New Drop Shipment For Ship Group</value>
@@ -7314,6 +7356,9 @@
         <value xml:lang="zh-CN">订单</value>
         <value xml:lang="zh-TW">訂單</value>
     </property>
+    <property key="OrderOrderingChannel">
+        <value xml:lang="en">Ordering Channel</value>
+    </property>
     <property key="OrderOrderBillFromParty">
         <value xml:lang="ar">فوترة من طرف</value>
         <value xml:lang="de">Rechnung von Akteur</value>
@@ -9334,6 +9379,12 @@
         <value xml:lang="zh-CN">订购的</value>
         <value xml:lang="zh-TW">已訂購的</value>
     </property>
+    <property key="OrderOrderedUnits">
+        <value xml:lang="en">Ordered Units</value>
+    </property>
+    <property key="OrderOrderedValue">
+        <value xml:lang="en">Ordered Value</value>
+    </property>
     <property key="OrderOrders">
         <value xml:lang="ar">أوامر البيع/الشراء</value>
         <value xml:lang="de">Aufträge</value>
@@ -9946,6 +9997,15 @@
         <value xml:lang="zh">个</value>
         <value xml:lang="zh-TW">個</value>
     </property>
+    <property key="OrderPlanHeader">
+        <value xml:lang="en">Plan Header</value>
+    </property>
+    <property key="OrderPlanItems">
+        <value xml:lang="en">Plan Items</value>
+    </property>
+    <property key="OrderPlanName">
+        <value xml:lang="en">Plan Name</value>
+    </property>
     <property key="OrderPlannedInReceive">
         <value xml:lang="ar">الكمية المستلمة</value>
         <value xml:lang="de">Erhaltene Menge</value>
@@ -15478,6 +15538,9 @@
         <value xml:lang="zh">由供货商批准的产品需求</value>
         <value xml:lang="zh-TW">由供應商核准的產品需求</value>
     </property>
+    <property key="PageTitleCreateAllocationPlan">
+        <value xml:lang="en">Create Allocation Plan</value>
+    </property>
     <property key="PageTitleCreateQuoteForCustRequest">
         <value xml:lang="ar">خلق عرض سعر جديد وبند عرض السعر لطلب العميل</value>
         <value xml:lang="de">Neues Angebot und Angebotspositionen für Kundenanfrage erstellen</value>
@@ -15509,6 +15572,9 @@
         <value xml:lang="zh">编辑订单头</value>
         <value xml:lang="zh-TW">編輯訂單頭</value>
     </property>
+    <property key="PageTitleEditAllocationPlan">
+        <value xml:lang="en">Edit Allocation Plan</value>
+    </property>
     <property key="PageTitleEditQuoteItemForCustRequest">
         <value xml:lang="ar">تعديل بند عرض السعر لطلب العميل</value>
         <value xml:lang="de">Angebotsposition für Kundenanfrage bearbeiten</value>
@@ -15619,6 +15685,9 @@
         <value xml:lang="zh">编辑需求角色</value>
         <value xml:lang="zh-TW">修改需求角色</value>
     </property>
+    <property key="PageTitleFindAllocationPlan">
+        <value xml:lang="en">Find Allocation Plan</value>
+    </property>
     <property key="PageTitleFindApprovedProductRequirements">
         <value xml:lang="ar">إيجاد متطلبات سلعة موافق عليها</value>
         <value xml:lang="de">Genehmigten Bedarf suchen</value>

Modified: ofbiz/ofbiz-framework/trunk/applications/order/data/OrderSecurityPermissionSeedData.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/data/OrderSecurityPermissionSeedData.xml?rev=1858270&r1=1858269&r2=1858270&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/data/OrderSecurityPermissionSeedData.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/data/OrderSecurityPermissionSeedData.xml Sat Apr 27 13:05:30 2019
@@ -46,7 +46,18 @@ under the License.
     <SecurityPermission description="Create sales forecasts in the Order Manager." permissionId="ORDERMGR_4C_CREATE"/>
     <SecurityPermission description="Update sales forecasts in the Order Manager." permissionId="ORDERMGR_4C_UPDATE"/>
 
+    <SecurityPermission description="Create Allocation Plan" permissionId="ALLOCPLAN_CREATE"/>
+    <SecurityPermission description="Update Allocation Plan" permissionId="ALLOCPLAN_UPDATE"/>
+    <SecurityPermission description="Approve Allocation Plan" permissionId="ALLOCPLAN_APPROVE"/>
+    <SecurityPermission description="Cancel Allocation Plan" permissionId="ALLOCPLAN_CANCEL"/>
+    <SecurityPermission description="View Allocation Plan" permissionId="ALLOCPLAN_VIEW"/>
+
     <!-- add admin to SUPER permission group -->
     <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPER" permissionId="ORDERMGR_ADMIN"/>
     <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPER" permissionId="ORDERMGR_CRQ_ADMIN"/>
+    <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPER" permissionId="ALLOCPLAN_CREATE"/>
+    <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPER" permissionId="ALLOCPLAN_UPDATE"/>
+    <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPER" permissionId="ALLOCPLAN_APPROVE"/>
+    <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPER" permissionId="ALLOCPLAN_CANCEL"/>
+    <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPER" permissionId="ALLOCPLAN_VIEW"/>
 </entity-engine-xml>

Modified: ofbiz/ofbiz-framework/trunk/applications/order/entitydef/entitymodel_view.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/entitydef/entitymodel_view.xml?rev=1858270&r1=1858269&r2=1858270&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/entitydef/entitymodel_view.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/entitydef/entitymodel_view.xml Sat Apr 27 13:05:30 2019
@@ -51,6 +51,7 @@ under the License.
       <member-entity entity-alias="OH" entity-name="OrderHeader"/>
       <member-entity entity-alias="OI" entity-name="OrderItem"/>
       <alias entity-alias="OH" name="orderId"/>
+      <alias entity-alias="OH" name="salesChannelEnumId"/>
       <alias entity-alias="OH" name="orderDate"/>
       <alias entity-alias="OH" name="orderStatusId" field="statusId"/>
       <alias entity-alias="OH" name="grandTotal"/>

Added: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/CreateAllocationPlan.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/CreateAllocationPlan.groovy?rev=1858270&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/CreateAllocationPlan.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/CreateAllocationPlan.groovy Sat Apr 27 13:05:30 2019
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+import org.apache.ofbiz.entity.condition.EntityOperator
+import org.apache.ofbiz.entity.condition.EntityCondition
+import org.apache.ofbiz.order.order.OrderReadHelper
+import org.apache.ofbiz.party.party.PartyHelper
+
+allocationPlanInfo = [:]
+itemList = []
+isPlanAlreadyExists = false
+productId = parameters.productId
+planName = parameters.planName
+
+if (productId) {
+    orderedQuantityTotal = 0.0
+    orderedValueTotal = 0.0
+    reservedQuantityTotal = 0.0
+
+    ecl = EntityCondition.makeCondition([
+                            EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId),
+                            EntityCondition.makeCondition("statusId", EntityOperator.IN, ["ALLOC_PLAN_CREATED", "ALLOC_PLAN_APPROVED"]),
+                            EntityCondition.makeCondition("planTypeId", EntityOperator.EQUALS, "SALES_ORD_ALLOCATION")],
+                        EntityOperator.AND)
+    allocationPlanHeader = from("AllocationPlanHeader").where(ecl).queryFirst()
+    if (allocationPlanHeader == null) {
+        ecl = EntityCondition.makeCondition([
+                                EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId),
+                                EntityCondition.makeCondition("orderStatusId", EntityOperator.EQUALS, "ORDER_APPROVED"),
+                                EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER")],
+                            EntityOperator.AND)
+        orderAndItemList = from("OrderHeaderAndItems").where(ecl).queryList()
+        orderAndItemList.each { orderAndItem ->
+            itemMap = [:]
+            salesChannelEnumId = orderAndItem.salesChannelEnumId
+            itemMap.salesChannelEnumId = salesChannelEnumId
+            salesChannel = from("Enumeration").where("enumId", salesChannelEnumId).queryOne()
+            if (salesChannel) {
+                itemMap.salesChannel = salesChannel.description
+            }
+
+            orh = new OrderReadHelper(delegator, orderAndItem.orderId)
+            placingParty = orh.getPlacingParty()
+            if (placingParty != null) {
+                itemMap.partyId = placingParty.partyId
+                itemMap.partyName = PartyHelper.getPartyName(placingParty)
+            }
+
+            itemMap.orderId = orderAndItem.orderId
+            itemMap.orderItemSeqId = orderAndItem.orderItemSeqId
+            itemMap.estimatedShipDate = orderAndItem.estimatedShipDate
+
+            unitPrice = orderAndItem.unitPrice
+            cancelQuantity = orderAndItem.cancelQuantity
+            quantity = orderAndItem.quantity
+            if (cancelQuantity != null) {
+                orderedQuantity = quantity.subtract(cancelQuantity)
+            } else {
+                orderedQuantity = quantity
+            }
+            orderedValue = orderedQuantity.multiply(unitPrice)
+            orderedQuantityTotal = orderedQuantityTotal.add(orderedQuantity)
+            orderedValueTotal = orderedValueTotal.add(orderedValue)
+            itemMap.orderedQuantity = orderedQuantity
+            itemMap.orderedValue = orderedValue
+
+            // Reserved quantity
+            reservedQuantity = 0.0
+            reservations = from("OrderItemShipGrpInvRes").where("orderId", orderAndItem.orderId, "orderItemSeqId", orderAndItem.orderItemSeqId).queryList()
+            reservations.each { reservation ->
+                if (reservation.quantity) {
+                    reservedQuantity += reservation.quantity
+                }
+            }
+            reservedQuantityTotal = reservedQuantityTotal.add(reservedQuantity)
+            itemMap.reservedQuantity = reservedQuantity
+            itemList.add(itemMap)
+        }
+    } else {
+        isPlanAlreadyExists = true
+    }
+    allocationPlanInfo.orderedQuantityTotal = orderedQuantityTotal
+    allocationPlanInfo.orderedValueTotal = orderedValueTotal
+    allocationPlanInfo.reservedQuantityTotal = reservedQuantityTotal
+}
+allocationPlanInfo.isPlanAlreadyExists = isPlanAlreadyExists
+allocationPlanInfo.itemList = itemList
+context.allocationPlanInfo = allocationPlanInfo
\ No newline at end of file

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/CreateAllocationPlan.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/CreateAllocationPlan.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/CreateAllocationPlan.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ListAllocationPlan.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ListAllocationPlan.groovy?rev=1858270&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ListAllocationPlan.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ListAllocationPlan.groovy Sat Apr 27 13:05:30 2019
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+import org.apache.ofbiz.entity.condition.EntityOperator
+import org.apache.ofbiz.entity.condition.EntityCondition
+planId = parameters.planId
+planName = parameters.planName
+planTypeId = parameters.planTypeId
+statusId = parameters.statusId
+productId = parameters.productId
+orderId = parameters.orderId
+sortField = parameters.sortField
+
+List exprs = []
+if (planId) {
+    exprs.add(EntityCondition.makeCondition("planId", EntityOperator.EQUALS, planId))
+}
+if (planName) {
+    exprs.add(EntityCondition.makeCondition("planName", EntityOperator.LIKE, planName))
+}
+if (planTypeId) {
+    exprs.add(EntityCondition.makeCondition("planTypeId", EntityOperator.EQUALS, planTypeId))
+}
+if (statusId) {
+    if (statusId instanceof String) {
+        exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, statusId))
+    } else {
+        exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.IN, statusId))
+    }
+}
+if (productId) {
+    exprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId))
+}
+if (orderId) {
+    exprs.add(EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderId))
+}
+ecl = EntityCondition.makeCondition(exprs, EntityOperator.OR)
+
+if (sortField) {
+    allocationPlanItems = from("AllocationPlanAndItem").where(ecl).orderBy(sortField).queryList()
+} else {
+    allocationPlanItems = from("AllocationPlanAndItem").where(ecl).queryList()
+}
+
+allocationPlans = []
+allocationPlanItems.each { allocationPlanItem ->
+    allocationPlanMap = [:]
+    allocationPlanMap.planId = allocationPlanItem.planId
+    allocationPlanMap.planItemSeqId = allocationPlanItem.planItemSeqId
+    allocationPlanMap.planName = allocationPlanItem.planName
+    allocationPlanMap.statusId = allocationPlanItem.statusId
+    allocationPlanMap.planTypeId = allocationPlanItem.planTypeId
+    allocationPlanMap.productId = allocationPlanItem.productId
+    allocationPlanMap.orderId = allocationPlanItem.orderId
+    allocationPlanMap.orderItemSeqId = allocationPlanItem.orderItemSeqId
+    allocationPlanMap.planMethodEnumId = allocationPlanItem.planMethodEnumId
+    allocationPlanMap.allocatedQuantity = allocationPlanItem.allocatedQuantity
+    allocationPlans.add(allocationPlanMap)
+}
+context.allocationPlans = allocationPlans
\ No newline at end of file

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ListAllocationPlan.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ListAllocationPlan.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ListAllocationPlan.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ViewAllocationPlan.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ViewAllocationPlan.groovy?rev=1858270&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ViewAllocationPlan.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ViewAllocationPlan.groovy Sat Apr 27 13:05:30 2019
@@ -0,0 +1,192 @@
+/*
+ * 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.
+ */
+import java.math.RoundingMode
+
+import org.apache.ofbiz.entity.condition.EntityOperator
+import org.apache.ofbiz.entity.condition.EntityCondition
+import org.apache.ofbiz.order.order.OrderReadHelper
+import org.apache.ofbiz.party.party.PartyHelper
+
+planId = parameters.planId
+allocationPlanInfo = [:]
+allocationPlanHeader = from("AllocationPlanHeader").where("planId", planId).queryFirst()
+if (allocationPlanHeader) {
+    allocationPlanInfo.planId = planId
+    allocationPlanInfo.planName = allocationPlanHeader.planName
+    allocationPlanInfo.statusId = allocationPlanHeader.statusId
+    allocationPlanInfo.productId = allocationPlanHeader.productId
+    allocationPlanInfo.createdBy = allocationPlanHeader.createdByUserLogin
+    allocationPlanInfo.createdDate = allocationPlanHeader.createdStamp
+
+    //Get product information
+    product = from("Product").where("productId", allocationPlanHeader.productId).queryOne()
+    if (product) {
+        allocationPlanInfo.productName = product.internalName
+    }
+
+    // Inventory quantity summary by facility: For every warehouse the product's ATP and QOH
+    // are obtained (calling the "getInventoryAvailableByFacility" service)
+    totalATP = 0
+    totalQOH = 0
+    facilityList = from("ProductFacility").where("productId", allocationPlanHeader.productId).queryList()
+    facilityIterator = facilityList.iterator()
+    while (facilityIterator) {
+        facility = facilityIterator.next()
+        result = runService('getInventoryAvailableByFacility', [productId : allocationPlanHeader.productId, facilityId : facility.facilityId])
+        totalATP = totalATP + result.availableToPromiseTotal
+        totalQOH = totalQOH + result.quantityOnHandTotal
+    }
+    allocationPlanInfo.totalATP = totalATP
+    allocationPlanInfo.totalQOH = totalQOH
+
+    summaryMap = [:]
+    itemList = []
+    orderedQuantityTotal = 0.0
+    orderedValueTotal = 0.0
+    reservedQuantityTotal = 0.0
+    allocatedQuantityTotal = 0.0
+    allocatedValueTotal = 0.0
+
+    allocationPlanItems = from("AllocationPlanAndItem").where("planId", planId, "productId", allocationPlanInfo.productId).orderBy("prioritySeqId").queryList()
+    allocationPlanItems.each { allocationPlanItem ->
+        newSummaryMap = [:]
+        itemMap = [:]
+        orderId = allocationPlanItem.orderId
+        orderItemSeqId = allocationPlanItem.orderItemSeqId
+        itemMap.orderId = allocationPlanItem.orderId
+        itemMap.orderItemSeqId = allocationPlanItem.orderItemSeqId
+        itemMap.planId = allocationPlanItem.planId
+        itemMap.planItemSeqId = allocationPlanItem.planItemSeqId
+        itemMap.productId = allocationPlanItem.productId
+        itemMap.statusId = allocationPlanItem.planItemStatusId
+
+        orderHeader = from("OrderHeader").where("orderId", orderId).queryOne()
+        if (orderHeader) {
+            salesChannelEnumId = orderHeader.salesChannelEnumId
+            salesChannel = from("Enumeration").where("enumId", salesChannelEnumId).queryOne()
+            if (salesChannel) {
+                itemMap.salesChannel = salesChannel.description
+                newSummaryMap.salesChannel = salesChannel.description
+            }
+            orh = new OrderReadHelper(delegator, orderId)
+            placingParty = orh.getPlacingParty()
+            if (placingParty != null) {
+                itemMap.partyId = placingParty.partyId
+                itemMap.partyName = PartyHelper.getPartyName(placingParty)
+            }
+
+            orderItem = from("OrderItem").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryOne()
+            unitPrice = 0
+            orderedQuantity = 0
+            if (orderItem) {
+                unitPrice = orderItem.unitPrice
+                cancelQuantity = orderItem.cancelQuantity
+                quantity = orderItem.quantity
+                if (cancelQuantity != null) {
+                    orderedQuantity = quantity.subtract(cancelQuantity)
+                } else {
+                    orderedQuantity = quantity
+                }
+                orderedValue = orderedQuantity.multiply(unitPrice);
+                orderedQuantityTotal = orderedQuantityTotal.add(orderedQuantity)
+                orderedValueTotal = orderedValueTotal.add(orderedValue)
+                itemMap.orderedQuantity = orderedQuantity
+                itemMap.orderedValue = orderedValue
+                newSummaryMap.orderedQuantity = orderedQuantity
+                newSummaryMap.orderedValue = orderedValue
+
+                // Reserved quantity
+                reservedQuantity = 0
+                reservations = orderItem.getRelated("OrderItemShipGrpInvRes", null, null, false)
+                reservations.each { reservation ->
+                    quantityAvailable = reservation.quantity?reservation.quantity:0.0
+                    quantityNotAvailable = reservation.quantityNotAvailable?reservation.quantityNotAvailable:0.0
+                    reservedQuantity += (quantityAvailable - quantityNotAvailable)
+                }
+                reservedQuantityTotal = reservedQuantityTotal.add(reservedQuantity)
+                itemMap.reservedQuantity = reservedQuantity
+
+                //TODO: Estimated Ship Date, need to check the right way to get it
+                itemMap.estimatedShipDate = orderItem.estimatedShipDate
+            }
+            allocatedQuantity = allocationPlanItem.allocatedQuantity
+            if (allocatedQuantity) {
+                allocatedValue = allocatedQuantity.multiply(unitPrice);
+                allocatedQuantityTotal = allocatedQuantityTotal.add(allocatedQuantity)
+                allocatedValueTotal = allocatedValueTotal.add(allocatedValue)
+                itemMap.allocatedQuantity = allocatedQuantity
+                itemMap.allocatedValue = allocatedValue
+                newSummaryMap.allocatedQuantity = allocatedQuantity
+                newSummaryMap.allocatedValue = allocatedValue
+            }
+
+            allocationPercentage = 0.0
+            if (allocatedQuantity && allocatedQuantity != 0 && orderedQuantity != 0) {
+                allocationPercentage = (allocatedQuantity.divide(orderedQuantity, 2, RoundingMode.HALF_UP)).multiply(100)
+            }
+            itemMap.allocationPercentage = allocationPercentage
+            newSummaryMap.allocationPercentage = allocationPercentage
+
+            if (summaryMap.containsKey(salesChannelEnumId)) {
+                existingSummaryMap = summaryMap.get(salesChannelEnumId)
+                existingSummaryMap.orderedQuantity += newSummaryMap.orderedQuantity
+                existingSummaryMap.orderedValue += newSummaryMap.orderedValue
+                if (existingSummaryMap.allocatedQuantity) {
+                    if (!newSummaryMap.allocatedQuantity) {
+                        newSummaryMap.allocatedQuantity = 0
+                    }
+                    existingSummaryMap.allocatedQuantity += newSummaryMap.allocatedQuantity
+                } else {
+                    existingSummaryMap.allocatedQuantity = newSummaryMap.allocatedQuantity
+                }
+                if (existingSummaryMap.allocatedValue) {
+                    if (!newSummaryMap.allocatedValue) {
+                        newSummaryMap.allocatedValue = 0
+                    }
+                    existingSummaryMap.allocatedValue += newSummaryMap.allocatedValue
+                } else {
+                    existingSummaryMap.allocatedValue = newSummaryMap.allocatedValue
+                }
+                allocationPercentage = 0.0
+                if (existingSummaryMap.orderedQuantity && existingSummaryMap.orderedQuantity != 0 && existingSummaryMap.allocatedQuantity && existingSummaryMap.allocatedQuantity != 0) {
+                    allocationPercentage = (existingSummaryMap.allocatedQuantity.divide(existingSummaryMap.orderedQuantity, 2, RoundingMode.HALF_UP)).multiply(100)
+                }
+                existingSummaryMap.allocationPercentage = allocationPercentage
+                summaryMap.put(salesChannelEnumId, existingSummaryMap)
+            } else {
+                summaryMap.put(salesChannelEnumId, newSummaryMap)
+            }
+        }
+        itemList.add(itemMap)
+    }
+    allocationPercentageTotal = 0.0
+    if (orderedQuantityTotal != 0.0 && allocatedQuantityTotal != 0.0) {
+        allocationPercentageTotal = (allocatedQuantityTotal.divide(orderedQuantityTotal, 2, RoundingMode.HALF_UP)).multiply(100)
+    }
+    allocationPlanInfo.orderedQuantityTotal = orderedQuantityTotal
+    allocationPlanInfo.orderedValueTotal = orderedValueTotal
+    allocationPlanInfo.reservedQuantityTotal = reservedQuantityTotal
+    allocationPlanInfo.allocatedQuantityTotal = allocatedQuantityTotal
+    allocationPlanInfo.allocatedValueTotal = allocatedValueTotal
+    allocationPlanInfo.allocationPercentageTotal = allocationPercentageTotal
+    allocationPlanInfo.summaryMap = summaryMap
+    allocationPlanInfo.itemList = itemList
+}
+allocationPlanInfo.allocationPlanHeader = allocationPlanHeader
+context.allocationPlanInfo = allocationPlanInfo

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ViewAllocationPlan.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ViewAllocationPlan.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/allocationplan/ViewAllocationPlan.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/ofbiz-framework/trunk/applications/order/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/servicedef/secas.xml?rev=1858270&r1=1858269&r2=1858270&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/servicedef/secas.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/servicedef/secas.xml Sat Apr 27 13:05:30 2019
@@ -471,4 +471,28 @@ under the License.
     <eca service="updateShipGroupShipInfo" event="commit">
         <action service="resetGrandTotal" mode="sync"/>
     </eca>
+    <eca service="storeOrder" event="return">
+        <condition field-name="orderTypeId" operator="equals" value="SALES_ORDER"/>
+        <condition-service service-name="isInventoryAllocationRequired"/>
+        <action service="associateOrderWithAllocationPlans" mode="sync"/>
+    </eca>
+    <eca service="changeOrderItemStatus" event="commit">
+        <condition field-name="statusId" operator="equals" value="ITEM_COMPLETED"/>
+        <action service="completeAllocationPlanItemByOrderItem" mode="sync"/>
+    </eca>
+    <eca service="changeOrderItemStatus" event="commit">
+        <condition field-name="statusId" operator="equals" value="ITEM_CANCELLED"/>
+        <action service="cancelAllocationPlanItemByOrderItem" mode="sync"/>
+    </eca>
+    <eca service="updateOrderItems" event="commit">
+        <action service="updateAllocatedQuantityOnOrderItemChange" mode="sync"/>
+    </eca>
+    <eca service="changeAllocationPlanStatus" event="commit">
+        <condition field-name="statusId" operator="equals" value="ALLOC_PLAN_APPROVED"/>
+        <action service="approveAllocationPlanItems" mode="sync"/>
+    </eca>
+    <eca service="changeAllocationPlanStatus" event="commit">
+        <condition field-name="statusId" operator="equals" value="ALLOC_PLAN_CANCELLED"/>
+        <action service="cancelAllocationPlanItems" mode="sync"/>
+    </eca>
 </service-eca>

Modified: ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services.xml?rev=1858270&r1=1858269&r2=1858270&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services.xml Sat Apr 27 13:05:30 2019
@@ -1237,4 +1237,121 @@ under the License.
         <description>Delete a ProductOrderItem</description>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
+
+    <!-- Allocation Plan services -->
+    <service name="createAllocationPlanHeader" engine="entity-auto" default-entity-name="AllocationPlanHeader" invoke="create" auth="true">
+        <description>Create Allocation Plan Header</description>
+        <auto-attributes include="pk" mode="IN"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <override name="planId" mode="INOUT"/>
+        <override name="planTypeId" optional="false"/>
+    </service>
+    <service name="updateAllocationPlanHeader" engine="entity-auto" default-entity-name="AllocationPlanHeader" invoke="update" auth="true">
+        <description>Update Allocation Plan Header</description>
+        <auto-attributes include="pk" mode="IN"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+    </service>
+    <service name="deleteAllocationPlanHeader" engine="entity-auto" default-entity-name="AllocationPlanHeader" invoke="delete" auth="true">
+        <description>Delete Allocation Plan Header</description>
+        <auto-attributes include="pk" mode="IN"/>
+    </service>
+    <service name="createAllocationPlanItem" engine="entity-auto" default-entity-name="AllocationPlanItem" invoke="create" auth="true">
+        <description>Create Allocation Plan Item</description>
+        <auto-attributes include="pk" mode="IN"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <override name="planItemSeqId" mode="OUT"/>
+        <override name="planMethodEnumId" optional="false"/>
+        <override name="productId" optional="false"/>
+        <override name="orderId" optional="false"/>
+        <override name="orderItemSeqId" optional="false"/>
+    </service>
+    <service name="updateAllocationPlanItem" engine="entity-auto" default-entity-name="AllocationPlanItem" invoke="update" auth="true">
+        <description>Update Allocation Plan Item</description>
+        <auto-attributes include="pk" mode="INOUT"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+    </service>
+    <service name="deleteAllocationPlanItem" engine="entity-auto" default-entity-name="AllocationPlanItem" invoke="delete" auth="true">
+        <description>Delete Allocation Plan Item</description>
+        <auto-attributes include="pk" mode="IN"/>
+    </service>
+    <service name="associateOrderWithAllocationPlans" engine="java" auth="true"
+            location="org.apache.ofbiz.order.order.OrderServices" invoke="associateOrderWithAllocationPlans">
+        <description>Associate order with the allocation plans of inline products</description>
+        <attribute name="orderId" type="String" mode="IN"/>
+        <attribute name="productPlanMap" mode="OUT" type="Map" optional="true"/>
+    </service>
+    <service name="approveAllocationPlanItems" engine="java" auth="true"
+            location="org.apache.ofbiz.order.order.OrderServices" invoke="approveAllocationPlanItems">
+        <description>Mark all the items of an allocation plan as approve</description>
+        <attribute name="planId" type="String" mode="IN"/>
+    </service>
+    <service name="cancelAllocationPlanItems" engine="java" auth="true"
+            location="org.apache.ofbiz.order.order.OrderServices" invoke="cancelAllocationPlanItems">
+        <description>Mark all the items of an allocation plan as cancel</description>
+        <attribute name="planId" type="String" mode="IN"/>
+    </service>
+    <service name="changeAllocationPlanStatus" engine="java" auth="true"
+            location="org.apache.ofbiz.order.order.OrderServices" invoke="changeAllocationPlanStatus">
+        <description>Change Allocation Plan Status</description>
+        <attribute name="planId" type="String" mode="INOUT"/>
+        <attribute name="statusId" type="String" mode="IN"/>
+        <attribute name="oldStatusId" type="String" mode="OUT"/>
+    </service>
+    <service name="changeAllocationPlanItemStatus" engine="java" auth="true"
+            location="org.apache.ofbiz.order.order.OrderServices" invoke="changeAllocationPlanItemStatus">
+        <description>Change Allocation Plan Item Status</description>
+        <attribute name="planId" type="String" mode="IN"/>
+        <attribute name="planItemSeqId" type="String" mode="IN"/>
+        <attribute name="statusId" type="String" mode="IN"/>
+        <attribute name="oldStatusId" type="String" mode="OUT"/>
+    </service>
+    <service name="completeAllocationPlanItemByOrderItem" engine="java" auth="true"
+            location="org.apache.ofbiz.order.order.OrderServices" invoke="completeAllocationPlanItemByOrderItem">
+        <description>Complete Allocation Plan Item By Providing Order Id and Item Seq Id</description>
+        <attribute name="orderId" type="String" mode="IN"/>
+        <attribute name="orderItemSeqId" type="String" mode="IN" optional="true"/>
+    </service>
+    <service name="cancelAllocationPlanItemByOrderItem" engine="java" auth="true"
+            location="org.apache.ofbiz.order.order.OrderServices" invoke="cancelAllocationPlanItemByOrderItem">
+        <description>Cancel Allocation Plan Item By Providing Order Id and Item Seq Id</description>
+        <attribute name="orderId" type="String" mode="IN"/>
+        <attribute name="orderItemSeqId" type="String" mode="IN" optional="true"/>
+    </service>
+    <service name="updateAllocatedQuantityOnOrderItemChange" engine="java" auth="true"
+            location="org.apache.ofbiz.order.order.OrderServices" invoke="updateAllocatedQuantityOnOrderItemChange">
+        <description>Update Allocated Quantity On Order Item Change</description>
+        <attribute name="orderId" type="String" mode="IN"/>
+        <attribute name="orderItemSeqId" type="String" mode="IN" optional="true"/>
+    </service>
+    <service name="createAllocationPlanAndItems" engine="java" auth="true"
+             location="org.apache.ofbiz.order.order.OrderServices" invoke="createAllocationPlanAndItems">
+        <description>Create Allocation Plan And Items</description>
+        <attribute name="productId" type="String" mode="IN"/>
+        <attribute name="planName" type="String" mode="IN" optional="true"/>
+        <attribute name="itemListSize" type="Integer" mode="IN"/>
+        <attribute name="itemOrderIdMap" type="Map" mode="IN" string-map-prefix="ioim_"/>
+        <attribute name="itemOrderItemSeqIdMap" type="Map" mode="IN" string-map-prefix="ioisim_"/>
+        <attribute name="itemAllocatedQuantityMap" type="Map" mode="IN" string-map-prefix="iaqm_"/>
+        <attribute name="planId" type="String" mode="OUT"/>
+    </service>
+
+    <service name="isInventoryAllocationRequired" engine="java" auth="true"
+             location="org.apache.ofbiz.order.order.OrderServices" invoke="isInventoryAllocationRequired">
+        <description>Check whether the inventory allocation is enabled or not at product store.</description>
+        <attribute name="serviceContext" type="Map" mode="IN"/>
+        <attribute name="serviceName" type="String" mode="IN"/>
+        <attribute name="conditionReply" type="Boolean" mode="OUT"/>
+    </service>
+
+    <service name="updateAllocationPlanItems" engine="java" auth="true"
+             location="org.apache.ofbiz.order.order.OrderServices" invoke="updateAllocationPlanItems">
+        <description>Update Allocation Plan Items</description>
+        <attribute name="planId" type="String" mode="IN"/>
+        <attribute name="orderIdMap" type="Map" mode="IN" string-map-prefix="oim_"/>
+        <attribute name="orderItemSeqIdMap" type="Map" mode="IN" string-map-prefix="oisim_"/>
+        <attribute name="productIdMap" type="Map" mode="IN" string-map-prefix="pim_"/>
+        <attribute name="prioritySeqIdMap" type="Map" mode="IN" string-map-prefix="psim_"/>
+        <attribute name="allocatedQuantityMap" type="Map" mode="IN" string-map-prefix="aqm_"/>
+        <attribute name="rowSubmitMap" type="Map" mode="IN" string-map-prefix="rsm_"/>
+    </service>
 </services>