diff --git a/src/layouts/headers/headerauth.vue b/src/layouts/headers/headerauth.vue index a013753..f2b8849 100755 --- a/src/layouts/headers/headerauth.vue +++ b/src/layouts/headers/headerauth.vue @@ -269,8 +269,6 @@ export default defineComponent({ this.userStatus(); }, mounted() { - console.log('VITE_VOIPMS_URL:', import.meta.env.VITE_VOIPMS_URL); - console.log('VITE_VOIPMS_TOKEN:', import.meta.env.VITE_VOIPMS_TOKEN); this.updatestatus(); this.fetchCurrentPhone(); }, @@ -285,7 +283,6 @@ export default defineComponent({ }) .then((response: any) => { - console.log(this.user) if (response.data.ok) { this.user = response.data.user; } else { @@ -307,7 +304,6 @@ export default defineComponent({ }) }, logout() { - console.log("Logging out..."); // Clear auth data const authStore = useAuthStore(); authStore.clearAuth(); @@ -331,9 +327,7 @@ export default defineComponent({ }); }, routeTo(route: string): Promise { - console.log('Routing to:', route); const path = `${import.meta.env.VITE_VOIPMS_URL}/route/${route}`; - console.log('API path:', path); return axios({ method: 'post', url: path, @@ -342,13 +336,11 @@ export default defineComponent({ }, }) .then((response: any) => { - console.log('Success routing to:', route); this.routeResponse = response.data; // Find the corresponding label const option = this.routingOptions.find(opt => opt.value === route); if (option) { this.currentPhone = option.label; - console.log('Updated currentPhone to:', this.currentPhone); } return response.data; }); diff --git a/src/pages/automatic/home.vue b/src/pages/automatic/home.vue index bcc3400..9fd110e 100755 --- a/src/pages/automatic/home.vue +++ b/src/pages/automatic/home.vue @@ -50,7 +50,7 @@ - +
New Auto
@@ -76,8 +76,11 @@ {{ oil.customer_address }}, {{ oil.customer_town }}
- Edit Customer - + + + + + @@ -126,7 +129,10 @@
Edit Customer - + + + + @@ -162,6 +168,8 @@ interface AutoDelivery { customer_town: string; house_factor: number; tank_size: number; + auto_status: number; + open_ticket_id?: number | null; } export default defineComponent({ @@ -185,6 +193,15 @@ export default defineComponent({ const sorted = [...this.deliveries]; sorted.sort((a, b) => { + // First, prioritize auto_status = 3 to be at the top + if (a.auto_status === 3 && b.auto_status !== 3) { + return -1; + } + if (a.auto_status !== 3 && b.auto_status === 3) { + return 1; + } + + // Then sort by the selected key let valA: any; let valB: any; @@ -200,7 +217,7 @@ export default defineComponent({ // Handle nulls or different types if necessary if (valA === null) return 1; if (valB === null) return -1; - + // Comparison logic if (valA < valB) { return this.sortAsc ? -1 : 1; diff --git a/src/pages/delivery/update_tickets/finalize_ticket_auto.vue b/src/pages/delivery/update_tickets/finalize_ticket_auto.vue index b6c704e..0a9352e 100644 --- a/src/pages/delivery/update_tickets/finalize_ticket_auto.vue +++ b/src/pages/delivery/update_tickets/finalize_ticket_auto.vue @@ -94,7 +94,7 @@
-
+

Finalize Auto Delivery

@@ -107,6 +107,10 @@
+
+

Error

+

Customer information not found. Please check the automatic delivery data.

+
@@ -201,26 +205,52 @@ description: '', }, - autoDelivery: { + + autoTicket: { id: 0, customer_id: '', account_number: '', + + customer_town : '', + customer_state : '', + customer_address : '', + customer_zip: '', + customer_full_name : '', + + oil_prices_id : '', + fill_date : '', + gallons_delivered : '', + price_per_gallon : '', + + total_amount_customer : '', + + payment_type : '', + payment_card_id : '', + payment_status : '', + open_ticket_id: 0 + + }, + + autoDelivery: { + id: 0, + customer_id: 0, + account_number: '', customer_town: '', - customer_state: '', + customer_state: 0, customer_address: '', customer_zip: '', customer_full_name: '', last_fill: '', days_since_last_fill: 0, last_updated: '', - estimated_gallons_left: '', - estimated_gallons_left_prev_day: '', + estimated_gallons_left: 0, + estimated_gallons_left_prev_day: 0, tank_height: '', tank_size: '', - house_factor: '', - auto_status: '', + house_factor: 0, + auto_status: 0, + open_ticket_id: null, }, - } }, @@ -231,12 +261,12 @@ watch: { $route() { this.today_price_oil(); - this.getAutoDelivery(this.$route.params.id); + this.getAutoTicket(this.$route.params.id); }, }, mounted() { this.today_price_oil(); - this.getAutoDelivery(this.$route.params.id); + this.getAutoTicket(this.$route.params.id); }, @@ -290,11 +320,16 @@ }) .then((response: any) => { this.userCards = response.data; + if (this.userCards && this.userCards.length > 0) { + this.userCardfound = true; + this.userCard = this.userCards.find((card: any) => card.main_card) || this.userCards[0]; + } }) .catch(() => { }); }, getCustomer(user_id: any) { + if (!user_id || user_id === 'undefined') return; let path = import.meta.env.VITE_BASE_URL + "/customer/" + user_id; axios({ method: "get", @@ -303,7 +338,9 @@ }) .then((response: any) => { this.customer = response.data; - + if (this.customer.id > 0) { + this.getPaymentCards(this.customer.user_id || this.customer.id); + } }) .catch(() => { notify({ @@ -311,6 +348,7 @@ text: "Could not find customer", type: "error", }); + this.customer = { id: 0, user_id: 0, customer_address: '', customer_first_name: '', customer_last_name: '', customer_town: '', customer_state: 0, customer_zip: '', customer_apt: '', customer_home_type: 0, customer_phone_number: '' }; }); }, getCustomerDescription(user_id: any) { @@ -331,16 +369,40 @@ type: "error", }); }); - }, - getAutoDelivery(delivery_id: any) { - let path = import.meta.env.VITE_AUTO_URL + "/delivery/" + delivery_id; + },//TODO STUCK HERE !!!!!!!!! + getAutoTicket(delivery_id: any) { + let path = import.meta.env.VITE_AUTO_URL + "/delivery/autoticket/" + delivery_id; axios({ method: "get", url: path, withCredentials: true, }) .then((response: any) => { - + this.autoTicket = response.data; + this.getCustomer(this.autoTicket.customer_id) + + this.getAutoDelivery(this.autoTicket.id) + this.getCustomerDescription(this.autoTicket.customer_id) + + }) + .catch(() => { + notify({ + title: "Error", + text: "Could not get automatic", + type: "error", + }); + }); + }, + + getAutoDelivery(delivery_id: any) { + let path = import.meta.env.VITE_AUTO_URL + "/delivery/finddelivery/" + delivery_id; + axios({ + method: "get", + url: path, + withCredentials: true, + }) + .then((response: any) => { + this.autoDelivery = response.data; this.getCustomer(this.autoDelivery.customer_id) this.getCustomerDescription(this.autoDelivery.customer_id) @@ -354,6 +416,7 @@ }); }); }, +//TODO STUCK HERE !!!!!!!!! today_price_oil() { let path = import.meta.env.VITE_BASE_URL + '/info/price/oil' axios({ @@ -398,10 +461,7 @@ }, - - ConfirmAuto(payload: { - gallons_delivered: string, }) { let path = import.meta.env.VITE_AUTO_URL + "/confirm/auto/create/" + this.autoDelivery.id; @@ -414,15 +474,16 @@ }) .then((response: any) => { if (response.data) { - + notify({ title: "Success", text: "Auto Delivered", type: "success", }); this.CreateTransaction(response.data['0']['auto_ticket_id']) - this.$router.push({ name: "auto" }); - + this.updateTransactionDelivery(this.autoDelivery.id, response.data['0']['auto_ticket_id']) + this.$router.push({ name: "payAutoCapture", params: { id: response.data['0']['auto_ticket_id'] } }); + } if (response.data.error) { notify({ @@ -439,6 +500,7 @@ UpdateDeliveredAuto(payload: { gallons_delivered: string, }) { + console.log(this.autoDelivery) let path = import.meta.env.VITE_AUTO_URL + "/confirm/auto/update/" + this.autoDelivery.id; axios({ method: "put", @@ -453,12 +515,19 @@ title: "Success", text: "Auto Updated", type: "success", - }); + }); + this.$router.push({ name: "payAutoCapture", params: { id: this.autoTicket.id } }); } - }) }, + updateTransactionDelivery(current_delivery_id: any, new_delivery_id: any) { + const path = `${import.meta.env.VITE_AUTHORIZE_URL}/api/auto/transaction/delivery/${current_delivery_id}/update/${new_delivery_id}`; + axios.put(path, {}, { withCredentials: true, headers: authHeader() }) + .then(() => console.log("Transaction auto_id updated")) + .catch(() => console.error("Error updating transaction auto_id")); + }, + CreateTransaction(auto_ticket_id: string,) { let path = import.meta.env.VITE_MONEY_URL + "/delivery/add/auto/" + auto_ticket_id; axios({ @@ -474,7 +543,6 @@ type: 'positive', position: 'top' }) - this.$router.push({ name: "auto" }); } else { notify({ @@ -486,11 +554,11 @@ }) }, onSubmit() { + let payload = { gallons_delivered: this.FinalizeOilOrderForm.gallons_delivered, }; this.UpdateDeliveredAuto(payload); - this.ConfirmAuto(payload); }, @@ -498,4 +566,4 @@ }) - \ No newline at end of file + diff --git a/src/pages/pay/auto/authorize_precharge_autho.vue b/src/pages/pay/auto/authorize_precharge_autho.vue new file mode 100644 index 0000000..74bef2c --- /dev/null +++ b/src/pages/pay/auto/authorize_precharge_autho.vue @@ -0,0 +1,551 @@ + + + + + + diff --git a/src/pages/pay/auto/capture_authorize_autho.vue b/src/pages/pay/auto/capture_authorize_autho.vue new file mode 100644 index 0000000..f8071f4 --- /dev/null +++ b/src/pages/pay/auto/capture_authorize_autho.vue @@ -0,0 +1,558 @@ + + + + + + diff --git a/src/pages/pay/routes.ts b/src/pages/pay/routes.ts index 2529df9..7e95409 100755 --- a/src/pages/pay/routes.ts +++ b/src/pages/pay/routes.ts @@ -6,9 +6,11 @@ import CaptureAuthorize from './oil/capture_authorize.vue'; import PayService from './service/pay_service.vue'; import AuthorizeServicePreauthCharge from './service/authorize_preauthcharge.vue'; import ChargeServiceAuthorize from './service/capture_authorize.vue'; +import AuthorizePrechargeAutho from './auto/authorize_precharge_autho.vue'; +import CaptureAuthorizeAutho from './auto/capture_authorize_autho.vue'; const payRoutes = [ - + // This is for oil delivery { path: '/pay/oil/:id', name: 'payOil', @@ -19,14 +21,15 @@ const payRoutes = [ name: 'authorizePreauthCharge', component: AuthorizePreauthCharge, }, - // This is for oil delivery { path: '/pay/capture/authorize/:id', name: 'captureAuthorize', component: CaptureAuthorize, }, - + + + // this is for service { path: '/pay/service/:id', name: 'payService', @@ -37,13 +40,25 @@ const payRoutes = [ name: 'authorizeServicePreauthCharge', component: AuthorizeServicePreauthCharge, }, - // this is for service + { path: '/pay/service/capture/authorize/:id', name: 'chargeServiceAuthorize', component: ChargeServiceAuthorize, }, + // this is for auto + { + path: '/pay/auto/authorize/:id', + name: 'payAutoAuthorize', + component: AuthorizePrechargeAutho, + }, + { + path: '/pay/auto/capture/:id', + name: 'payAutoCapture', + component: CaptureAuthorizeAutho, + }, + ] export default payRoutes diff --git a/src/pages/ticket/ticketauto.vue b/src/pages/ticket/ticketauto.vue index 2a01101..c43f10f 100644 --- a/src/pages/ticket/ticketauto.vue +++ b/src/pages/ticket/ticketauto.vue @@ -230,7 +230,7 @@ export default defineComponent({ methods: { getAutoOrder(delivery_id: any) { - let path = import.meta.env.VITE_AUTO_URL + "/delivery/" + delivery_id; + let path = import.meta.env.VITE_AUTO_URL + "/delivery/delivery/" + delivery_id; axios({ method: "get", url: path,