working auto
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
|
||||
<!-- RIGHT COLUMN: Finalize Form -->
|
||||
<div class="space-y-4">
|
||||
<div class="bg-base-100 rounded-lg p-5">
|
||||
<div v-if="customer.id > 0" class="bg-base-100 rounded-lg p-5">
|
||||
<h2 class="text-2xl font-bold mb-4">Finalize Auto Delivery</h2>
|
||||
<form class="space-y-4" @submit.prevent="onSubmit">
|
||||
<div>
|
||||
@@ -107,6 +107,10 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div v-else class="bg-base-100 rounded-lg p-5">
|
||||
<h2 class="text-2xl font-bold mb-4 text-error">Error</h2>
|
||||
<p>Customer information not found. Please check the automatic delivery data.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
<style scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user