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: case to display shipping label button always on completed page and show an error toast when having missing shipment method configuration #364

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"Unlimited Capacity": "Unlimited Capacity",
"Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.": "Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.",
"Unlimited fulfillment capacity": "Unlimited fulfillment capacity",
"Unable to generate shipping label due to missing product store shipping method configuration": "Unable to generate shipping label due to missing product store shipping method configuration",
"Unable to open as browser is blocking pop-ups.": "Unable to open { documentName } as browser is blocking pop-ups.",
"Unpack": "Unpack",
"Unpacking this order will send it back to 'In progress' and it will have to be repacked.": "Unpacking this order will send it back to 'In progress' and it will have to be repacked.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"Unlimited Capacity": "Capacidad Ilimitada",
"Unlimited fulfillment capacity": "Capacidad de cumplimiento ilimitada",
"Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.": "La capacidad ilimitada elimina por completo el límite de capacidad de cumplimiento. Para agregar una capacidad de cumplimiento a esta instalación, use la opción personalizada.",
"Unable to generate shipping label due to missing product store shipping method configuration": "Unable to generate shipping label due to missing product store shipping method configuration",
"Unable to open as browser is blocking pop-ups.": "No se puede abrir { documentName } porque el navegador bloquea las ventanas emergentes.",
"Unpack": "Desempacar",
"Unpacking this order will send it back to 'In progress' and it will have to be repacked.": "Desempacar este pedido lo enviará de vuelta a 'En curso' y tendrá que ser vuelto a empacar.",
Expand Down
29 changes: 24 additions & 5 deletions src/views/Completed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<div class="desktop-only">
<ion-button v-if="!hasPackedShipments(order)" :disabled="true">{{ translate("Shipped") }}</ion-button>
<ion-button v-else :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo || ((isTrackingRequiredForAnyShipmentPackage(order) && !order.trackingCode) && !hasPermission(Actions.APP_FORCE_SHIP_ORDER))" @click.stop="shipOrder(order)">{{ translate("Ship Now") }}</ion-button>
<ion-button v-if="productStoreShipmentMethCount > 0" :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" fill="outline" @click.stop="regenerateShippingLabel(order)">
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" fill="outline" @click.stop="regenerateShippingLabel(order)">
{{ translate("Regenerate Shipping Label") }}
<ion-spinner color="primary" slot="end" v-if="order.isGeneratingShippingLabel" name="crescent" />
</ion-button>
Expand Down Expand Up @@ -570,7 +570,14 @@ export default defineComponent({
async retryShippingLabel(order: any) {
// Getting all the shipmentIds from shipmentPackages, as we only need to pass those shipmentIds for which label is missing
// In shipmentPackages only those shipmentInformation is available for which shippingLabel is missing
const shipmentIds = order.shipmentPackages.map((shipmentPackage: any) => shipmentPackage.shipmentId);
const shipmentIds = order.shipmentPackages?.map((shipmentPackage: any) => shipmentPackage.shipmentId);

// Don't make any api call when we does not have any shipmentIds for order
if(!shipmentIds?.length) {
showToast(translate("Failed to generate shipping label"))
return;
}

// TODO Handle error case
const resp = await OrderService.retryShippingLabel(shipmentIds)
if (!hasError(resp)) {
Expand All @@ -589,16 +596,28 @@ export default defineComponent({
return;
}

const shipmentIds = order.shipments.map((shipment: any) => shipment.shipmentId)
const shipmentIds = order.shipments?.map((shipment: any) => shipment.shipmentId)
order.isGeneratingPackingSlip = true;
await OrderService.printPackingSlip(shipmentIds);
order.isGeneratingPackingSlip = false;
},
async printShippingLabel(order: any) {
const shipmentIds = order.shipments.map((shipment: any) => shipment.shipmentId)
const shipmentIds = order.shipments?.map((shipment: any) => shipment.shipmentId)

if(!shipmentIds?.length) {
showToast(translate('Failed to generate shipping label'))
return
}

await OrderService.printShippingLabel(shipmentIds)
},
async regenerateShippingLabel(order: any) {
// If there are no product store shipment method configured, then not generating the label and displaying an error toast
if(this.productStoreShipmentMethCount <= 0) {
showToast(translate('Unable to generate shipping label due to missing product store shipping method configuration'))
return;
}

// if the request to print shipping label is not yet completed, then clicking multiple times on the button
// should not do anything
if(order.isGeneratingShippingLabel) {
Expand All @@ -617,7 +636,7 @@ export default defineComponent({
},
async showShippingLabelErrorModal(order: any){
// Getting all the shipment ids
const shipmentIds = order.shipments.map((shipment: any) => shipment.shipmentId);
const shipmentIds = order.shipments?.map((shipment: any) => shipment.shipmentId);
const shippingLabelErrorModal = await modalController.create({
component: ShippingLabelErrorModal,
componentProps: {
Expand Down
34 changes: 27 additions & 7 deletions src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ export default defineComponent({
getPartyName: 'util/getPartyName',
getfacilityTypeDesc: 'util/getFacilityTypeDesc',
getPaymentMethodDesc: 'util/getPaymentMethodDesc',
getStatusDesc: 'util/getStatusDesc'
getStatusDesc: 'util/getStatusDesc',
productStoreShipmentMethCount: 'util/getProductStoreShipmentMethCount'
})
},
data() {
Expand Down Expand Up @@ -627,6 +628,13 @@ export default defineComponent({
return packageType;
},
async regenerateShippingLabel(order: any) {
// If there are no product store shipment method configured, then not generating the label and displaying an error toast
if(this.productStoreShipmentMethCount <= 0) {
showToast(translate('Unable to generate shipping label due to missing product store shipping method configuration'))
return;
}


// if the request to print shipping label is not yet completed, then clicking multiple times on the button
// should not do anything
if(order.isGeneratingShippingLabel) {
Expand All @@ -652,7 +660,13 @@ export default defineComponent({
async retryShippingLabel(order: any) {
// Getting all the shipmentIds from shipmentPackages, as we only need to pass those shipmentIds for which label is missing
// In shipmentPackages only those shipmentInformation is available for which shippingLabel is missing
const shipmentIds = order.shipmentPackages.map((shipmentPackage: any) => shipmentPackage.shipmentId);
const shipmentIds = order.shipmentPackages?.map((shipmentPackage: any) => shipmentPackage.shipmentId);

if(!shipmentIds?.length) {
showToast(translate("Failed to generate shipping label"))
return;
}

// TODO Handle error case
const resp = await OrderService.retryShippingLabel(shipmentIds)
if (!hasError(resp)) {
Expand All @@ -674,7 +688,13 @@ export default defineComponent({
return popover.present();
},
async printShippingLabel(order: any) {
const shipmentIds = order.shipments.map((shipment: any) => shipment.shipmentId)
const shipmentIds = order.shipments?.map((shipment: any) => shipment.shipmentId)

if(!shipmentIds?.length) {
showToast(translate('Failed to generate shipping label'))
return;
}

await OrderService.printShippingLabel(shipmentIds)
},
async addShipmentBox(order: any) {
Expand Down Expand Up @@ -794,14 +814,14 @@ export default defineComponent({
form.append('facilityId', this.currentFacility.facilityId)
form.append('orderId', order.orderId)

order.shipmentIds.map((shipmentId: string) => {
order.shipmentIds?.map((shipmentId: string) => {
form.append('shipmentIds', shipmentId)
})

const items = JSON.parse(JSON.stringify(order.items));

// creating updated data for shipment packages
order.shipmentPackages.map((shipmentPackage: any, index: number) => {
order.shipmentPackages?.map((shipmentPackage: any, index: number) => {
form.append(`box_shipmentId_${index}`, shipmentPackage.shipmentId)
form.append(`${index}_box_rowSubmit_`, ''+index)
form.append(`box_shipmentBoxTypeId_${index}`, shipmentPackage.shipmentBoxTypeId)
Expand Down Expand Up @@ -951,7 +971,7 @@ export default defineComponent({
showToast(translate('Order shipped successfully'))

// updating order locally after ship action is success, as solr takes some time to update
order.shipments.map((shipment: any) => {
order.shipments?.map((shipment: any) => {
if(shipment.shipmentId === order.shipmentId) shipment.statusId = 'SHIPMENT_SHIPPED'
})
this.store.dispatch('order/updateCurrent', order)
Expand Down Expand Up @@ -1052,7 +1072,7 @@ export default defineComponent({
return;
}

const shipmentIds = order.shipments.map((shipment: any) => shipment.shipmentId)
const shipmentIds = order.shipments?.map((shipment: any) => shipment.shipmentId)
order.isGeneratingPackingSlip = true;
await OrderService.printPackingSlip(shipmentIds);
order.isGeneratingPackingSlip = false;
Expand Down
Loading