Skip to content

Commit

Permalink
Merge pull request #22 from hotwax/#20_bulk_upload_cycle_count_apis
Browse files Browse the repository at this point in the history
Fixed: Bulk Inventory count import miscellaneous issues
  • Loading branch information
dixitdeepak authored Oct 3, 2024
2 parents a7ce580 + 8c0b6d5 commit 53029da
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions service/co/hotwax/cycleCount/InventoryCountServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<set field="itemDetail" from="invCountImpItem?.getMap()"/>
<set field="qtyOnHand" from="0.0"/>
<entity-find-one entity-name="co.hotwax.warehouse.InvCountImportVariance" value-field="countImportVariance">
<field-map field-name="inventoryCountImportId"/>
<field-map field-name="inventoryCountImportId" from="invCountImpItem.inventoryCountImportId"/>
<field-map field-name="invCountImportItemSeqId" from="invCountImpItem.importItemSeqId"/>
</entity-find-one>
<if condition="countImportVariance">
Expand Down Expand Up @@ -170,6 +170,8 @@
<set field="item.productId" from="item.idValue"/>
<set field="item.inventoryCountImportId" from="context.inventoryCountImportId"/>
<!-- Not checking if idValue is already added. One can just reject duplicate records if added multiple times. -->
<set field="item.createdDate" from="ec.user.nowTimestamp"/>
<set field="item.createdByUserLoginId" from="ec.user.getUsername()"/>
<service-call name="create#co.hotwax.warehouse.InventoryCountImportItem" in-map="item"/>
</if>
</iterate>
Expand Down Expand Up @@ -342,6 +344,7 @@
</entity-find-one>

<set field="fileName" from="uploadedFile.getName()"/>
<set field="fileName" from="fileName.substring(0, fileName.lastIndexOf('.csv'))"/>
<set field="csvFilePath" from="ec.resource.expand(systemMessageType.receivePath, null,
[contentRoot: ec.user.getPreference('mantle.content.root') ?: 'dbresource://datamanager', dateTime:ec.l10n.format(nowDate, 'yyyy-MM-dd-HH-mm-ss-SSS'), fileName: fileName], false)"/>
<set field="fileReference" from="ec.resource.getLocationReference(csvFilePath)"/>
Expand Down Expand Up @@ -387,21 +390,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" 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 53029da

Please sign in to comment.