Skip to content

Commit

Permalink
Merge pull request #22 from hotwax/20-conditional-brokering-based-on-…
Browse files Browse the repository at this point in the history
…product-store-configuration

Used product store enable brokering setting while order lookup, if brokering is disabled for product store no order will be brokered for the specific product store
  • Loading branch information
dixitdeepak authored Jun 14, 2024
2 parents bc9c6a7 + d03bbdb commit ab75e1e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions screen/OrderRoutingGroup/OrderRoutingGroupDetail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
<field name="sequenceNum"><default-field><text-line size="60"/></default-field></field>
<field name="productStoreId">
<default-field>
<drop-down allow-empty="false" allow-multiple="false">
<drop-down>
<entity-options key="${productStoreId}"
text="${storeName}">
text="${storeName} [${productStoreId}]">
<entity-find entity-name="org.apache.ofbiz.product.store.ProductStore" distinct="true" cache="true">
<select-field field-name="productStoreId"/><order-by field-name="storeName"/></entity-find>
</entity-options>
Expand Down
11 changes: 11 additions & 0 deletions service/co/hotwax/order/routing/OrderRoutingServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
validate the routing group and product store association
-->
<entity-find-one entity-name="co.hotwax.order.routing.OrderRoutingGroup" value-field="orderRoutingGroup"/>

<if condition="!orderRoutingGroup">
<return error="true" message="Order routing not found for ${routingGroupId}"/>
</if>
Expand All @@ -87,6 +88,16 @@
<if condition="orderRoutingGroup.productStoreId != productStoreId">
<return error="true" message="Order routing group ${orderRoutingGroup.groupName} [${routingGroupId}] is not associated with productStoreId [${productStoreId}]."/>
</if>
<entity-find-one entity-name="org.apache.ofbiz.product.store.ProductStore" value-field="productStore">
<field-map field-name="productStoreId" from="orderRoutingGroup.productStoreId"/>
</entity-find-one>
<if condition="!productStore">
<return error="true" message="ProductStore ${orderRoutingGroup.productStoreId} not found."/>
</if>
<if condition="productStore.enableBrokering == 'N'">
<return error="true" message="Routing is disabled for productStore ${productStore.storeName} [${orderRoutingGroup.productStoreId}]. "/>
</if>

<entity-find entity-name="co.hotwax.order.routing.OrderRoutingRun" list="routingRuns">
<econditions>
<econdition field-name="productStoreId" from="orderRoutingGroup.productStoreId"/>
Expand Down
3 changes: 3 additions & 0 deletions sql/EligibleOrdersQuery.sql.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ from
OIS.SHIP_GROUP_SEQ_ID'shipGroupSeqId',
OI.ORDER_ITEM_SEQ_ID,
OH.PRODUCT_STORE_ID,
PS.ENABLE_BROKERING,
OH.STATUS_ID,
OH.ORDER_TYPE_ID,
OI.STATUS_ID AS ITEM_STATUS_ID,
Expand All @@ -27,6 +28,7 @@ from
CSM.DELIVERY_DAYS AS deliveryDays
FROM
ORDER_HEADER OH
INNER JOIN PRODUCT_STORE PS ON OH.PRODUCT_STORE_ID = PS.PRODUCT_STORE_ID
INNER JOIN ORDER_ITEM_SHIP_GROUP OIS ON OH.ORDER_ID = OIS.ORDER_ID
INNER JOIN ORDER_ITEM OI ON OIS.ORDER_ID = OI.ORDER_ID AND OIS.SHIP_GROUP_SEQ_ID = OI.SHIP_GROUP_SEQ_ID
<#if productCategoryCondition?has_content>INNER JOIN PRODUCT_CATEGORY_MEMBER PCM ON PCM.PRODUCT_ID=OI.PRODUCT_ID AND <@buildSqlCondition 'PCM.PRODUCT_CATEGORY_ID' productCategoryCondition/></#if>
Expand All @@ -37,6 +39,7 @@ from
WHERE
(
PRODUCT_STORE_ID = '${productStoreId!''}'
AND (ENABLE_BROKERING is null OR ENABLE_BROKERING = 'Y')
AND STATUS_ID = '${orderStatusId!''}'
AND ORDER_TYPE_ID = '${orderTypeId!''}'
AND ITEM_STATUS_ID = '${itemStatusId!''}'
Expand Down

0 comments on commit ab75e1e

Please sign in to comment.