Skip to content

Commit

Permalink
Merge pull request #321 from ymaheshwari1/#319
Browse files Browse the repository at this point in the history
Fixed: issue in receiving shipment when adding a new item due to missing locationSeqId for that item(#319)
  • Loading branch information
ymaheshwari1 authored Feb 21, 2024
2 parents ea80bbd + f820bff commit 07e960f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ export default defineComponent({
if (this.loader) {
this.loader.dismiss();
this.loader = null as any;
} else {
// Added this else case as there are some scenarios in which the loader is not created and before that the dismissLoader gets called, resulting in the loader not getting dismissed
// So checking that when the loader is not found then try dismissing the loader again after 3 secs.
// The above case appears when directly hitting the shipment detail page and then the receive shipment api throws error
// TODO: need to find a more better approach to dismiss the loader in such case
setTimeout(() => {
if (this.loader) {
this.dismissLoader();
}
}, 3000)
}
},
async unauthorized() {
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"External ID": "External ID",
"Facility": "Facility",
"Location": "Location",
"Failed to receive shipment": "Failed to receive shipment",
"Failed to receive some of the items": "Failed to receive some of the items",
"Failed to scan:": "Failed to scan: {itemName}",
"Failed to update product identifier preference": "Failed to update product identifier preference",
Expand Down
5 changes: 5 additions & 0 deletions src/store/modules/shipment/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ const actions: ActionTree<ShipmentState, RootState> = {
},
receiveShipmentItem ({ commit }, payload) {

Check warning on line 97 in src/store/modules/shipment/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'commit' is defined but never used

Check warning on line 97 in src/store/modules/shipment/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / build_and_deploy

'commit' is defined but never used

Check warning on line 97 in src/store/modules/shipment/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'commit' is defined but never used
return Promise.all(payload.items.map(async (item: any) => {
if(!item.locationSeqId) {
return Promise.reject("Missing locationSeqId on item")
}

const params = {
shipmentId: payload.shipmentId,
facilityId: this.state.user.currentFacility.facilityId,
Expand Down Expand Up @@ -128,6 +132,7 @@ const actions: ActionTree<ShipmentState, RootState> = {
emitter.emit("dismissLoader");
return resp;
}).catch(err => {
emitter.emit("dismissLoader");
console.error(err)
return err;
});
Expand Down
5 changes: 4 additions & 1 deletion src/views/AddProductModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export default defineComponent({
products: 'product/getProducts',
isScrollable: 'product/isScrollable',
isProductAvailableInShipment: 'product/isProductAvailableInShipment',
productIdentificationPref: 'user/getProductIdentificationPref'
productIdentificationPref: 'user/getProductIdentificationPref',
currentFacility: 'user/getCurrentFacility',
facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId'
})
},
methods: {
Expand Down Expand Up @@ -115,6 +117,7 @@ export default defineComponent({
})
},
async addtoShipment (product: any) {
product.locationSeqId = this.facilityLocationsByFacilityId(this.currentFacility.facilityId) ? this.facilityLocationsByFacilityId(this.currentFacility.facilityId)[0]?.locationSeqId : ''
this.store.dispatch('shipment/addShipmentItem', product)
},
closeModal() {
Expand Down
5 changes: 4 additions & 1 deletion src/views/AddProductToPOModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export default defineComponent({
products: 'product/getProducts',
isScrollable: 'product/isScrollable',
isProductAvailableInOrder: 'order/isProductAvailableInOrder',
productIdentificationPref: 'user/getProductIdentificationPref'
productIdentificationPref: 'user/getProductIdentificationPref',
currentFacility: 'user/getCurrentFacility',
facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId'
})
},
methods: {
Expand Down Expand Up @@ -115,6 +117,7 @@ export default defineComponent({
})
},
async addtoOrder (product: any) {
product.locationSeqId = this.facilityLocationsByFacilityId(this.currentFacility.facilityId) ? this.facilityLocationsByFacilityId(this.currentFacility.facilityId)[0]?.locationSeqId : ''
this.store.dispatch('order/addOrderItem', product)
},
closeModal() {
Expand Down
4 changes: 3 additions & 1 deletion src/views/ShipmentDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ import { useRouter } from 'vue-router';
import Scanner from "@/components/Scanner.vue";
import LocationPopover from '@/components/LocationPopover.vue'
import ImageModal from '@/components/ImageModal.vue';
import { hasError, productHelpers } from '@/utils'
import { hasError, productHelpers, showToast } from '@/utils'
import { Actions, hasPermission } from '@/authorization'
export default defineComponent({
Expand Down Expand Up @@ -229,6 +229,8 @@ export default defineComponent({
const resp = await this.store.dispatch('shipment/receiveShipment', { items: eligibleItems, shipmentId })
if (resp.status === 200 && !hasError(resp)) {
this.router.push('/shipments');
} else {
showToast(translate("Failed to receive shipment"))
}
},
isEligibleForReceivingShipment() {
Expand Down

0 comments on commit 07e960f

Please sign in to comment.