Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: issue in receiving shipment when adding a new item due to missing locationSeqId for that item(#319) #321

Merged
merged 6 commits into from
Feb 21, 2024
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 update product identifier preference": "Failed to update product identifier preference",
"facility location": "facility location",
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 @@ -93,6 +93,10 @@
},
receiveShipmentItem ({ commit }, payload) {
return Promise.all(payload.items.map(async (item: any) => {
if(!item.locationSeqId) {
return Promise.reject("Missing locationSeqId on item")

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 / reusable_workflow_job (20.x)

'commit' is defined but never used
}

const params = {
shipmentId: payload.shipmentId,
facilityId: this.state.user.currentFacility.facilityId,
Expand Down Expand Up @@ -125,6 +129,7 @@
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 @@ -111,7 +111,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 @@ -213,6 +213,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
Loading