From 4596b3e4e5caf8b33a2b90cd57bc2904b839e2a9 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 22 Jan 2025 15:58:40 +0700 Subject: [PATCH 1/5] feat: 05 => update TableQuotation to display '-' for empty --- src/components/05_quotation/TableQuotation.vue | 4 ++-- src/pages/05_quotation/MainPage.vue | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/05_quotation/TableQuotation.vue b/src/components/05_quotation/TableQuotation.vue index 102558d6..d24b0448 100644 --- a/src/components/05_quotation/TableQuotation.vue +++ b/src/components/05_quotation/TableQuotation.vue @@ -69,7 +69,7 @@ defineEmits<{
-
{{ props.row.workName }}
+
{{ props.row.workName || '-' }}
{{ props.row.code }}
@@ -83,7 +83,7 @@ defineEmits<{ - {{ props.row.contactName }} + {{ props.row.contactName || '-' }} diff --git a/src/pages/05_quotation/MainPage.vue b/src/pages/05_quotation/MainPage.vue index 64b1b7c2..30b4b081 100644 --- a/src/pages/05_quotation/MainPage.vue +++ b/src/pages/05_quotation/MainPage.vue @@ -80,7 +80,7 @@ const pageState = reactive({ hideStat: false, inputSearch: '', fieldSelected: [''], - gridView: true, + gridView: false, total: 0, currentTab: 'Issued', From 4d7e2b16453d3a0e00ec86e4395143144b2254ef Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Thu, 23 Jan 2025 08:55:31 +0700 Subject: [PATCH 2/5] refactor: add mode edit --- .../09_task-order/order_view/MainPage.vue | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/pages/09_task-order/order_view/MainPage.vue b/src/pages/09_task-order/order_view/MainPage.vue index 6ffd5ade..f5287f53 100644 --- a/src/pages/09_task-order/order_view/MainPage.vue +++ b/src/pages/09_task-order/order_view/MainPage.vue @@ -15,7 +15,12 @@ import AdditionalFileExpansion from '../expansion/AdditionalFileExpansion.vue'; import RemarkExpansion from '../expansion/RemarkExpansion.vue'; import InfoMessengerExpansion from '../expansion/receive/InfoMessengerExpansion.vue'; import TableEmployee from '../TableEmployee.vue'; -import { SaveButton, MainButton, EditButton } from 'src/components/button'; +import { + SaveButton, + MainButton, + EditButton, + UndoButton, +} from 'src/components/button'; import FormGroupHead from 'src/pages/08_request-list/FormGroupHead.vue'; import FailRemarkDialog from '../receive_view/FailRemarkDialog.vue'; @@ -412,6 +417,26 @@ function openProductDialog() { pageState.productDialog = true; } +async function closeTab() { + if (state.value.mode === 'edit' && !!currentFormData.value.id) { + taskOrderFormStore.resetForm(); + await taskOrderFormStore.assignFormData(currentFormData.value.id, 'edit'); + } else { + dialogWarningClose(t, { + message: t('dialog.message.close'), + action: () => { + window.close(); + }, + cancel: () => {}, + }); + } +} + +function undo() { + if (!currentFormData.value) return; + taskOrderFormStore.assignFormData(currentFormData.value?.id || '', 'info'); +} + onMounted(async () => { initTheme(); initLang(); @@ -1124,13 +1149,18 @@ watch([currentFormData.value.taskStatus], () => { {{ $t('general.view', { msg: $t('general.example') }) }}
- From ec61c733426979035ce65227c379a22afd6d7c47 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 23 Jan 2025 09:25:20 +0700 Subject: [PATCH 4/5] fix: wrong vat excluded calc --- src/pages/05_quotation/QuotationForm.vue | 2 +- src/pages/05_quotation/preview/ViewForm.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index 0cfe7c8b..5e11b252 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -253,7 +253,7 @@ function getPrice( a.vat = c.product.calcVat ? precisionRound(a.vat + vat) : a.vat; a.vatExcluded = c.product.calcVat ? a.vatExcluded - : precisionRound(a.vat + vat); + : precisionRound(a.vatExcluded + vat); a.finalPrice = precisionRound( a.totalPrice - a.totalDiscount + diff --git a/src/pages/05_quotation/preview/ViewForm.vue b/src/pages/05_quotation/preview/ViewForm.vue index 0906e3d7..636d32d9 100644 --- a/src/pages/05_quotation/preview/ViewForm.vue +++ b/src/pages/05_quotation/preview/ViewForm.vue @@ -264,7 +264,7 @@ onMounted(async () => { a.vat = c.product.calcVat ? precisionRound(a.vat + vat) : a.vat; a.vatExcluded = c.product.calcVat ? a.vatExcluded - : precisionRound(a.vat + vat); + : precisionRound(a.vatExcluded + vat); a.finalPrice = precisionRound( a.totalPrice - a.totalDiscount + From e12a87f496c34f1cfc061e0c175301068abb57fc Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:20:46 +0700 Subject: [PATCH 5/5] fix: inaccurate .01 price --- src/components/05_quotation/ProductItem.vue | 15 ++++-- src/pages/05_quotation/QuotationForm.vue | 40 ++++++++------ src/pages/05_quotation/preview/ViewForm.vue | 60 +++++++++++++-------- 3 files changed, 73 insertions(+), 42 deletions(-) diff --git a/src/components/05_quotation/ProductItem.vue b/src/components/05_quotation/ProductItem.vue index a705631d..20990594 100644 --- a/src/components/05_quotation/ProductItem.vue +++ b/src/components/05_quotation/ProductItem.vue @@ -57,11 +57,18 @@ const currentBtnOpen = ref<{ title: string; opened: boolean[] }[]>([ ]); function calcPrice(c: (typeof rows.value)[number]) { - const price = c.pricePerUnit * c.amount; + const originalPrice = c.pricePerUnit; + const finalPriceWithVat = precisionRound( + originalPrice + + (c.product.vatIncluded || c.vat !== 0 + ? 0 + : originalPrice * (config.value?.vat || 0.07)), + ); + const finalPriceNoVat = finalPriceWithVat / (1 + (config.value?.vat || 0.07)); + + const price = finalPriceNoVat * c.amount; const vat = c.product.calcVat - ? (c.pricePerUnit * (c.discount ? c.amount : 1) - c.discount) * - (config.value?.vat || 0.07) * - (!c.discount ? c.amount : 1) + ? (finalPriceNoVat * c.amount - c.discount) * (config.value?.vat || 0.07) : 0; return precisionRound(price + vat); } diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index 5e11b252..26329fff 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -242,11 +242,19 @@ function getPrice( return a; } - const price = c.pricePerUnit * c.amount; + const originalPrice = c.pricePerUnit; + const finalPriceWithVat = precisionRound( + originalPrice + + (c.product.vatIncluded + ? 0 + : originalPrice * (config.value?.vat || 0.07)), + ); + const finalPriceNoVat = + finalPriceWithVat / (1 + (config.value?.vat || 0.07)); + + const price = finalPriceNoVat * c.amount; const vat = - (c.pricePerUnit * (c.discount ? c.amount : 1) - c.discount) * - (config.value?.vat || 0.07) * - (!c.discount ? c.amount : 1); + (finalPriceNoVat * c.amount - c.discount) * (config.value?.vat || 0.07); a.totalPrice = precisionRound(a.totalPrice + price); a.totalDiscount = precisionRound(a.totalDiscount + Number(c.discount)); @@ -704,12 +712,12 @@ function handleUpdateProductTable( const pricePerUnit = c.pricePerUnit || 0; const discount = c.discount || 0; - return precisionRound( + return ( pricePerUnit * c.amount - - discount + - (c.product.calcVat - ? (pricePerUnit * c.amount - discount) * (config.value?.vat || 0.07) - : 0), + discount + + (c.product.calcVat + ? (pricePerUnit * c.amount - discount) * (config.value?.vat || 0.07) + : 0) ); }; @@ -767,17 +775,15 @@ function toggleDeleteProduct(index: number) { ? currProduct.product.agentPrice : currProduct.product.price; const pricePerUnit = currProduct.product.vatIncluded - ? precisionRound(price / (1 + (config.value?.vat || 0.07))) + ? price / (1 + (config.value?.vat || 0.07)) : price; - const vat = precisionRound( + const vat = (pricePerUnit * currProduct.amount - currProduct.discount) * - (config.value?.vat || 0.07), - ); - const finalPrice = precisionRound( + (config.value?.vat || 0.07); + const finalPrice = pricePerUnit * currProduct.amount + - vat - - Number(currProduct.discount || 0), - ); + vat - + Number(currProduct.discount || 0); currTempPaySplit.amount = currPaySplit.amount - finalPrice; currPaySplit.amount = currTempPaySplit.amount; diff --git a/src/pages/05_quotation/preview/ViewForm.vue b/src/pages/05_quotation/preview/ViewForm.vue index 636d32d9..c1fab7b7 100644 --- a/src/pages/05_quotation/preview/ViewForm.vue +++ b/src/pages/05_quotation/preview/ViewForm.vue @@ -228,23 +228,33 @@ onMounted(async () => { productList.value = (data?.value?.productServiceList ?? data.value?.productServiceList).map( - (v) => ({ - id: v.product.id, - code: v.product.code, - detail: v.product.name, - amount: v.amount || 0, - priceUnit: v.pricePerUnit || 0, - discount: v.discount || 0, - vat: v.vat || 0, - value: precisionRound( - (v.pricePerUnit || 0) * v.amount - - (v.discount || 0) + - (v.product.calcVat - ? ((v.pricePerUnit || 0) * v.amount - (v.discount || 0)) * - (config.value?.vat || 0.07) - : 0), - ), - }), + (v) => { + const originalPrice = v.pricePerUnit; + const finalPriceWithVat = precisionRound( + originalPrice + + (v.product.vatIncluded || v.vat !== 0 + ? 0 + : originalPrice * (config.value?.vat || 0.07)), + ); + const finalPriceNoVat = + finalPriceWithVat / (1 + (config.value?.vat || 0.07)); + + const price = finalPriceNoVat * v.amount; + const vat = + (finalPriceNoVat * v.amount - v.discount) * + (config.value?.vat || 0.07); + + return { + id: v.product.id, + code: v.product.code, + detail: v.product.name, + amount: v.amount || 0, + priceUnit: v.pricePerUnit || 0, + discount: v.discount || 0, + vat: v.vat || 0, + value: precisionRound(price + (v.product.calcVat ? vat : 0)), + }; + }, ) || []; } @@ -253,11 +263,19 @@ onMounted(async () => { [] ).reduce( (a, c) => { - const price = precisionRound((c.pricePerUnit || 0) * c.amount); - const vat = precisionRound( - ((c.pricePerUnit || 0) * c.amount - (c.discount || 0)) * - (config.value?.vat || 0.07), + const originalPrice = c.pricePerUnit; + const finalPriceWithVat = precisionRound( + originalPrice + + (c.product.vatIncluded || c.vat !== 0 + ? 0 + : originalPrice * (config.value?.vat || 0.07)), ); + const finalPriceNoVat = + finalPriceWithVat / (1 + (config.value?.vat || 0.07)); + + const price = finalPriceNoVat * c.amount; + const vat = + (finalPriceNoVat * c.amount - c.discount) * (config.value?.vat || 0.07); a.totalPrice = precisionRound(a.totalPrice + price); a.totalDiscount = precisionRound(a.totalDiscount + Number(c.discount));