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

Implemented: common admin permission on ship now button if any shipment package require tracking (#281) #289

Merged
merged 7 commits into from
Oct 30, 2023
1 change: 1 addition & 0 deletions src/authorization/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export default {
"APP_UPDT_ECOM_INV_CONFIG": "APP_UPDT_ECOM_INV_CONFIG",
"APP_UNPACK_ORDER": "APP_UNPACK_ORDER",
"APP_RECYCLE_ORDER": "APP_RECYCLE_ORDER",
"APP_FORCE_SHIP_ORDER": "APP_FORCE_SHIP_ORDER"
}
1 change: 1 addition & 0 deletions src/authorization/Rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export default {
"APP_UNPACK_ORDER": "COMMON_ADMIN",
"APP_RECYCLE_ORDER": "COMMON_ADMIN",
"APP_STOREFULFILLMENT_ADMIN": "STOREFULFILLMENT_ADMIN",
"APP_FORCE_SHIP_ORDER": "COMMON_ADMIN"
} as any
2 changes: 1 addition & 1 deletion src/services/OrderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const fetchShipmentPackages = async (shipmentIds: Array<string>): Promise<any> =
"trackingCode_op": "empty",
"shipmentItemSeqId_op": "not-empty"
},
"fieldList": ["shipmentId", "shipmentPackageSeqId", "shipmentBoxTypeId", "packageName", "primaryOrderId", "carrierPartyId"],
"fieldList": ["shipmentId", "shipmentPackageSeqId", "shipmentBoxTypeId", "packageName", "primaryOrderId", "carrierPartyId", "isTrackingRequired"],
"viewSize": 250, // maximum records we could have
"distinct": "Y"
}
Expand Down
25 changes: 20 additions & 5 deletions src/views/Completed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</ion-item>
</div>
<div class="results">
<ion-button :disabled="!hasAnyPackedShipment() || hasAnyMissingInfo()" expand="block" class="bulk-action desktop-only" fill="outline" size="large" @click="bulkShipOrders()">{{ $t("Ship") }}</ion-button>
<ion-button :disabled="!hasAnyPackedShipment() || hasAnyMissingInfo() || !hasPermission(Actions.APP_FORCE_SHIP_ORDER)" expand="block" class="bulk-action desktop-only" fill="outline" size="large" @click="bulkShipOrders()">{{ $t("Ship") }}</ion-button>

<ion-card class="order" v-for="(order, index) in getCompletedOrders()" :key="index">
<div class="order-header">
Expand Down Expand Up @@ -93,7 +93,7 @@
<!-- TODO: implement functionality to mobile view -->
<div class="mobile-only">
<ion-item>
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" fill="clear" >{{ $t("Ship Now") }}</ion-button>
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo || (isTrackingRequiredForAnyShipmentPackage(order) && !hasPermission(Actions.APP_FORCE_SHIP_ORDER))" fill="clear" >{{ $t("Ship Now") }}</ion-button>
<ion-button slot="end" fill="clear" color="medium" @click="shippingPopover">
<ion-icon slot="icon-only" :icon="ellipsisVerticalOutline" />
</ion-button>
Expand All @@ -104,7 +104,7 @@
<div class="actions">
<div class="desktop-only">
<ion-button v-if="!hasPackedShipments(order)" :disabled="true">{{ $t("Shipped") }}</ion-button>
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" @click="shipOrder(order)" v-else>{{ $t("Ship Now") }}</ion-button>
<ion-button v-else :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo || (isTrackingRequiredForAnyShipmentPackage(order) && !hasPermission(Actions.APP_FORCE_SHIP_ORDER))" @click="shipOrder(order)">{{ $t("Ship Now") }}</ion-button>
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" fill="outline" @click="regenerateShippingLabel(order)">
{{ $t("Regenerate Shipping Label") }}
<ion-spinner color="primary" slot="end" v-if="order.isGeneratingShippingLabel" name="crescent" />
Expand All @@ -125,9 +125,8 @@
</ion-infinite-scroll>
</div>
</div>
<!-- TODO: make mobile view functional -->
<ion-fab v-if="completedOrders.total" class="mobile-only" vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button @click="bulkShipOrders()">
<ion-fab-button :disabled="!hasAnyPackedShipment() || hasAnyMissingInfo() || !hasPermission(Actions.APP_FORCE_SHIP_ORDER)" @click="bulkShipOrders()">
<ion-icon :icon="checkmarkDoneOutline" />
</ion-fab-button>
</ion-fab>
Expand Down Expand Up @@ -332,6 +331,15 @@ export default defineComponent({
handler: async () => {
let orderList = JSON.parse(JSON.stringify(this.completedOrders.list))

// if there are orders with tracking required and label image present
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we only need to exclude those orders for which tracking is required but the shipping label is missing. Please correct the logic.

const trackingRequiredOrders = orderList.filter((order: any) => this.isTrackingRequiredForAnyShipmentPackage(order))
if (trackingRequiredOrders.length) {
const isTrackingCodeRequired = orderList.some((order: any) => order.missingLabelImage)
if (!isTrackingCodeRequired) {
orderList = trackingRequiredOrders
}
}

let shipmentIds = orderList.reduce((shipmentIds: any, order: any) => {
if (order.shipments) {
order.shipments.reduce((shipmentIds: any, shipment: any) => {
Expand Down Expand Up @@ -609,6 +617,13 @@ export default defineComponent({
},
fetchProductStock(productId: string) {
this.store.dispatch('stock/fetchStock', { productId })
},
isTrackingRequiredForAnyShipmentPackage(order: any) {
if (!order.shipmentPackages) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the length of shipment packages.

return false
}

return order.shipmentPackages.some((shipmentPackage: any) => shipmentPackage.isTrackingRequired === 'Y')
}
},
setup() {
Expand Down