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

Improved: displayed order invoicing facility on order lookup details page (#796) #799

Merged
merged 2 commits into from
Sep 30, 2024
Merged
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
44 changes: 42 additions & 2 deletions src/views/OrderLookupDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,14 @@
<ion-label class="ion-text-wrap">{{ translate("Customer ID") }}</ion-label>
<ion-label slot="end">{{ order.orderAttributes.customerid || "-" }}</ion-label>
</ion-item>
<ion-item lines="none">
<ion-item>
<ion-label class="ion-text-wrap">{{ translate("Municipio") }}</ion-label>
<ion-label slot="end">{{ order.orderAttributes.municipio || "-" }}</ion-label>
</ion-item>
<ion-item lines="none">
<ion-label class="ion-text-wrap">{{ translate("Invoicing facility") }}</ion-label>
<ion-label class="ion-text-wrap" slot="end">{{ (invoicingFacility.facilityName ? invoicingFacility.facilityName : invoicingFacility.facilityId) || '-' }}</ion-label>
</ion-item>
</ion-list>
</ion-card>
</div>
Expand Down Expand Up @@ -278,7 +282,11 @@ import { cubeOutline, golfOutline, callOutline, cashOutline, closeCircleOutline,
import { mapGetters, useStore } from "vuex";
import { DateTime } from "luxon";
import { formatCurrency, getColorByDesc } from "@/utils"
import { prepareSolrQuery } from '@/utils/solrHelper';
import OrderLookupLabelActionsPopover from '@/components/OrderLookupLabelActionsPopover.vue';
import { hasError } from "@hotwax/oms-api";
import logger from "@/logger";
import { OrderService } from "@/services/OrderService";

export default defineComponent({
name: "OrderLookupDetail",
Expand Down Expand Up @@ -308,7 +316,8 @@ export default defineComponent({
orderStatuses: JSON.parse(process.env.VUE_APP_ORDER_STATUS as any),
itemStatuses: JSON.parse(process.env.VUE_APP_ITEM_STATUS as any),
isFetchingStock: false,
isFetchingOrderInfo: false
isFetchingOrderInfo: false,
invoicingFacility: {} as any
}
},
computed: {
Expand All @@ -320,11 +329,13 @@ export default defineComponent({
getStatusDesc: "util/getStatusDesc",
getShipmentMethodDesc: "util/getShipmentMethodDesc",
getPaymentMethodDesc: 'util/getPaymentMethodDesc',
userProfile: 'user/getUserProfile',
})
},
async ionViewWillEnter() {
this.isFetchingOrderInfo = true
await this.store.dispatch("orderLookup/getOrderDetails", this.orderId)
await this.fetchOrderInvoicingFacility()
this.isFetchingOrderInfo = false
},
methods: {
Expand Down Expand Up @@ -361,6 +372,35 @@ export default defineComponent({

return popover.present()
},
async fetchOrderInvoicingFacility() {
const params = {
viewSize: 1,
sort: "createdDate_dt desc",
filters: {
id: { value: this.order.orderName }
},
docType: "ORDER_TO_INVOICE_API",
coreName: "logInsights"
}

const orderInvoicingQueryPayload = prepareSolrQuery(params)

try {
const resp = await OrderService.findOrderInvoicingInfo(orderInvoicingQueryPayload);

if(!hasError(resp) && resp.data?.response?.docs?.length) {
const response = resp.data.response.docs[0];

const request = Object.keys(response.request_txt_en).length ? JSON.parse(response.request_txt_en) : {}
const invoicingFacility = this.userProfile.facilities.find((facility: any) => facility.facilityId === request.InvoicingStore)
if(invoicingFacility) {
this.invoicingFacility = invoicingFacility
}
}
} catch(error: any) {
logger.error(error);
}
}
},
setup() {
const store = useStore();
Expand Down
Loading