Skip to content

Commit

Permalink
Improved: Added checks to only allowed improting cycle count in Draft…
Browse files Browse the repository at this point in the history
… or Assigned status (#20).
  • Loading branch information
ravilodhi committed Sep 20, 2024
1 parent b1fbc7a commit a07a680
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions service/co/hotwax/cycleCount/InventoryCountServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,24 +388,34 @@
<parameter name="idValue"/>
</in-parameters>
<actions>

<!--Processing cycle count items in Draft and Assigned status only-->
<set field="allowedStatusIds" value="['INV_COUNT_CREATED', 'INV_COUNT_ASSIGNED']"/>
<if condition="statusId != null &amp;&amp; !allowedStatusIds.contains(statusId)">
<return/>
</if>

<if condition="!facilityId &amp;&amp; externalFacilityId">
<entity-find entity-name="org.apache.ofbiz.product.facility.Facility" list="facilities">
<econdition field-name="externalId" from="externalFacilityId"/>
</entity-find>
<set field="facilityId" from="facilities?.first?.facilityId"/>
</if>

<if condition="statusId != null">
<set field="allowedStatusIds" from="statusId"/>
</if>
<entity-find entity-name="co.hotwax.warehouse.InventoryCountImport" list="inventoryCountImports">
<econdition field-name="countImportName"/>
<econdition field-name="facilityId" or-null="true"/>
<!--Allowing addition of items in the existing cycle count in draft or assigned status only-->
<econdition field-name="statusId" operator="in" value="INV_COUNT_CREATED,INV_COUNT_ASSIGNED"/>
<econdition field-name="statusId" operator="in" from="allowedStatusIds"/>
</entity-find>
<set field="inventoryCountImportId" from="inventoryCountImports?.first?.inventoryCountImportId"/>

<if condition="!inventoryCountImportId">
<service-call name="co.hotwax.cycleCount.InventoryCountServices.create#InventoryCountImport"
in-map="context + [statusId: 'INV_COUNT_CREATED']"
in-map="context + [statusId: statusId ? statusId : 'INV_COUNT_CREATED']"
out-map="result"/>
<set field="inventoryCountImportId" from="result.inventoryCountImportId"/>
</if>
Expand Down

0 comments on commit a07a680

Please sign in to comment.