From e74f5510f043a666cc61d4ea81ace764df9e9f14 Mon Sep 17 00:00:00 2001 From: Edwin Eames Date: Sat, 6 Sep 2025 13:40:58 -0400 Subject: [PATCH] small fixes routing --- .../profile/profile/DeliveriesTable.vue | 4 +- src/pages/delivery/create.vue | 9 +- .../update_tickets/finalize_ticket.vue | 13 +- src/pages/delivery/view.vue | 143 +++++++++++++++--- 4 files changed, 134 insertions(+), 35 deletions(-) diff --git a/src/pages/customer/profile/profile/DeliveriesTable.vue b/src/pages/customer/profile/profile/DeliveriesTable.vue index 52758c8..7c07ff3 100644 --- a/src/pages/customer/profile/profile/DeliveriesTable.vue +++ b/src/pages/customer/profile/profile/DeliveriesTable.vue @@ -84,6 +84,6 @@ interface Props { // 3. Use the generic version of defineProps to apply the types defineProps(); -const deliveryStatus = (s: number) => ({0:'Waiting',1:'Cancelled',2:'Out',3:'Tomorrow',5:'Issue',10:'Finalized'}[s] || 'N/A'); -const statusClass = (s: number) => ({0:'badge-warning',1:'badge-error',2:'badge-info',3:'badge-ghost',5:'badge-error',10:'badge-success'}[s] || ''); +const deliveryStatus = (s: number) => ({0:'Waiting',1:'Cancelled',2:'Out',3:'Tomorrow',5:'Issue',9:'Pending_Payment', 10:'Finalized'}[s] || 'N/A'); +const statusClass = (s: number) => ({0:'badge-warning',1:'badge-error',2:'badge-info',3:'badge-ghost',5:'badge-error', 9:'badge-warning', 10:'badge-success'}[s] || ''); \ No newline at end of file diff --git a/src/pages/delivery/create.vue b/src/pages/delivery/create.vue index 275bdb4..bd23258 100755 --- a/src/pages/delivery/create.vue +++ b/src/pages/delivery/create.vue @@ -110,7 +110,7 @@ @@ -213,7 +213,7 @@
Primary
-

**** **** **** {{ card.last_four_digits }}

+

{{ card.card_number }}

Exp: 0{{ card.expiration_month }} / {{ card.expiration_year }}

CVV: {{ card.security_number }}

@@ -282,8 +282,8 @@

Confirm Payment Method

You have selected a non-standard payment method (Cash or Check). Please confirm you wish to proceed.

@@ -328,6 +328,7 @@ interface UserCard { expiration_year: number; main_card: boolean; security_number: string; + card_number: string; } interface Promo { id: number; diff --git a/src/pages/delivery/update_tickets/finalize_ticket.vue b/src/pages/delivery/update_tickets/finalize_ticket.vue index c716f7a..bb4f221 100755 --- a/src/pages/delivery/update_tickets/finalize_ticket.vue +++ b/src/pages/delivery/update_tickets/finalize_ticket.vue @@ -622,7 +622,6 @@ export default defineComponent({ text: "Confirmed Transaction", type: "success", }) - this.$router.push({ name: "deliveryOutForDelivery" }); } else { notify({ @@ -660,8 +659,14 @@ export default defineComponent({ type: "success", }); this.CreateTransaction() - this.$router.push({ name: "deliveryOutForDelivery" }); - + // Navigate to delivery view page with proper error handling + if (this.deliveryOrder && this.deliveryOrder.id) { + this.$router.push({ name: "deliveryOrder", params: { id: this.deliveryOrder.id } }); + } else { + // Fallback if delivery ID is not available + this.$router.push({ name: "delivery" }); + } + } if (response.data.error) { notify({ @@ -669,7 +674,7 @@ export default defineComponent({ text: "Could not finalize ticket", type: "error", }); - this.$router.push("delivery"); + this.$router.push({ name: "delivery" }); } }) }, diff --git a/src/pages/delivery/view.vue b/src/pages/delivery/view.vue index 632532b..b369c0b 100755 --- a/src/pages/delivery/view.vue +++ b/src/pages/delivery/view.vue @@ -111,35 +111,77 @@
- -
- FILL - {{ deliveryOrder.gallons_ordered }} gallons +
+
+ +
+ FILL + {{ deliveryOrder.gallons_ordered }} gallons +
+
+
+ +
+ 0 gallons + {{ deliveryOrder.gallons_delivered }} gallons +
+
- -
- + +
+ -
- ${{ deliveryMoney.total_amount_oil }} -
- -
Before Discount: ${{ total_amount }}
Discount: -${{ discount }}
Subtotal: ${{ total_amount_after_discount }}
${{ total_amount }}
-
+ ${{ pricing.price_prime }} Prime Fee
+ ${{ pricing.price_emergency }} Emergency Fee
+ ${{ pricing.price_same_day }} Same Day Fee
+
+ + +
+ +
+
+ Gallons Delivered: + {{ deliveryOrder.gallons_delivered }} gallons +
+
+ Price per Gallon: + ${{ pricing.price_for_customer }} +
+
+ Subtotal: + ${{ (parseFloat(deliveryOrder.gallons_delivered) * pricing.price_for_customer).toFixed(2) }} +
+
+ Prime Fee: + + ${{ pricing.price_prime }} +
+
+ Same Day Fee: + + ${{ pricing.price_same_day }} +
+
+ Emergency Fee: + + ${{ pricing.price_emergency }} +
+
+
+ Total: + ${{ calculateDeliveryTotal() }} +
+ +
@@ -184,7 +226,7 @@
-

**** **** **** {{ userCard.last_four_digits }}

+

{{ userCard.card_number }}

Exp: @@ -522,24 +564,53 @@ getOilOrder(delivery_id: any) { withCredentials: true, }) .then((response: any) => { - if (response.data.ok) { - this.priceprime = response.data.priceprime; - this.pricesameday = response.data.pricesameday; - this.priceemergency = response.data.priceemergency; - this.total_amount = response.data.total_amount; - this.discount = response.data.discount; - this.total_amount_after_discount = response.data.total_amount_after_discount; + if (response.data && response.data.ok) { + this.priceprime = response.data.priceprime || 0; + this.pricesameday = response.data.pricesameday || 0; + this.priceemergency = response.data.priceemergency || 0; + this.total_amount = response.data.total_amount || 0; + this.discount = response.data.discount || 0; + this.total_amount_after_discount = response.data.total_amount_after_discount || 0; + } else { + // Fallback calculation if API doesn't return expected data + this.calculateFallbackTotal(); } }) - .catch(() => { + .catch((error: any) => { + console.error("Error fetching delivery totals:", error); + // Fallback calculation on error + this.calculateFallbackTotal(); notify({ - title: "Error", - text: "Could not get oil pricing", - type: "error", + title: "Warning", + text: "Could not get delivery totals, using estimated calculation", + type: "warn", }); }); }, + calculateFallbackTotal() { + // Fallback calculation using available data + if (this.deliveryOrder.gallons_ordered && this.pricing.price_for_customer) { + const gallons = Number(this.deliveryOrder.gallons_ordered); + const pricePerGallon = Number(this.pricing.price_for_customer); + let total = gallons * pricePerGallon; + + if (this.deliveryOrder.prime == 1) { + total += Number(this.pricing.price_prime) || 0; + } + if (this.deliveryOrder.same_day == 1) { + total += Number(this.pricing.price_same_day) || 0; + } + if (this.deliveryOrder.emergency == 1) { + total += Number(this.pricing.price_emergency) || 0; + } + + this.total_amount = total; + this.total_amount_after_discount = total; // No discount info available + this.discount = 0; + } + }, + getPromo(promo_id: any) { let path = import.meta.env.VITE_BASE_URL + "/promo/" + promo_id; axios({ @@ -554,6 +625,28 @@ getOilOrder(delivery_id: any) { } }) }, + + calculateDeliveryTotal() { + if (!this.deliveryOrder.gallons_delivered || !this.pricing.price_for_customer) { + return '0.00'; + } + + const gallons = Number(this.deliveryOrder.gallons_delivered); + const pricePerGallon = Number(this.pricing.price_for_customer); + let total = gallons * pricePerGallon; + + if (this.deliveryOrder.prime == 1) { + total += Number(this.pricing.price_prime) || 0; + } + if (this.deliveryOrder.same_day == 1) { + total += Number(this.pricing.price_same_day) || 0; + } + if (this.deliveryOrder.emergency == 1) { + total += Number(this.pricing.price_emergency) || 0; + } + + return total.toFixed(2); + }, },