diff --git a/app/components/pos/ConfirmOrder.vue b/app/components/pos/ConfirmOrder.vue index 6e49414..d61aee0 100644 --- a/app/components/pos/ConfirmOrder.vue +++ b/app/components/pos/ConfirmOrder.vue @@ -17,25 +17,29 @@ const shipping_address = computed(() => { async function createOrder() { try { isPending.value = true; + + const invoicePayload = { + customer: activeCart.value.customer, + customer_name: activeCart.value.customer__fullname, + customer_phone: activeCart.value.customer__phone, + customer_email: activeCart.value.customer__email, + shipping_address: shipping_address.value, + product_amount: activeCartItems.value.length, + shipping_fee: 0, + total_amount: subtotal.value, + discount_amount: 0, + final_amount: subtotal.value, + order_type: "pos", + status: "pending", + payment_status: 1, + staff: 1, + ordered_at: new Date(), + paid_at: null, + delivery_method: orderInfo.value.deliveryMethod.id, + }; + const invoice = await $insertapi("Invoice", { - data: { - customer: activeCart.value.customer, - customer_name: activeCart.value.customer__fullname, - customer_phone: activeCart.value.customer__phone, - customer_email: activeCart.value.customer__email, - shipping_address: shipping_address.value, - product_amount: activeCartItems.value.length, - shipping_fee: 0, - total_amount: subtotal.value, - discount_amount: 0, - final_amount: subtotal.value, - order_type: "pos", - status: "pending", - staff: 1, - ordered_at: new Date(), - paid_at: null, - delivery_method: orderInfo.value.deliveryMethod.id, - }, + data: invoicePayload, notify: false, }); @@ -68,8 +72,8 @@ async function createOrder() { if (orderInfo.value.deliveryMethod.code === "HOME_DELIVERY") { const deliveryInfoPayload = { invoice: invoice.id, - receiver_name: invoice.customer_name, - receiver_phone: invoice.customer_phone, + receiver_name: orderInfo.value.receiver_name, + receiver_phone: orderInfo.value.receiver_phone, city: orderInfo.value.address.city, district: orderInfo.value.address.district, ward: orderInfo.value.address.ward, @@ -171,9 +175,9 @@ async function createOrder() {

{{ shipping_address }}

- {{ activeCart.customer__fullname }} + {{ orderInfo.receiver_name }} - {{ activeCart.customer__phone }} + {{ orderInfo.receiver_phone }}

diff --git a/app/components/pos/POS.vue b/app/components/pos/POS.vue index 7208e73..7659de1 100644 --- a/app/components/pos/POS.vue +++ b/app/components/pos/POS.vue @@ -215,10 +215,9 @@ provide("pos", {

@@ -227,10 +226,9 @@ provide("pos", {

diff --git a/app/components/pos/composables/useOrderInfo.js b/app/components/pos/composables/useOrderInfo.js index 0170c36..86990d5 100644 --- a/app/components/pos/composables/useOrderInfo.js +++ b/app/components/pos/composables/useOrderInfo.js @@ -1,6 +1,8 @@ export default function useOrderInfo({ activeCartId, activeCart, activeCartItems, addresses, getAddresses }) { const orderInfo = ref({ address: null, + receiver_name: null, + receiver_phone: null, deliveryMethod: null, paymentMethod: null, }); @@ -18,10 +20,14 @@ export default function useOrderInfo({ activeCartId, activeCart, activeCartItems if (!oldVal || !oldVal.customer || oldVal.customer !== newVal.customer) { const defaultAddress = addresses.value.find((add) => add.is_default); orderInfo.value.address = defaultAddress; + orderInfo.value.receiver_name = newVal.customer__fullname; + orderInfo.value.receiver_phone = newVal.customer__phone; } } else { addresses.value = null; orderInfo.value.address = null; + orderInfo.value.receiver_name = null; + orderInfo.value.receiver_phone = null; } });