refactor: calculate value
This commit is contained in:
parent
8f880fd34d
commit
81e5873e4c
1 changed files with 21 additions and 13 deletions
|
|
@ -8,8 +8,8 @@ import ThaiBahtText from 'thai-baht-text';
|
||||||
import useOptionStore from 'stores/options';
|
import useOptionStore from 'stores/options';
|
||||||
import { formatNumberDecimal } from 'stores/utils';
|
import { formatNumberDecimal } from 'stores/utils';
|
||||||
import { useQuotationForm } from 'pages/05_quotation/form';
|
import { useQuotationForm } from 'pages/05_quotation/form';
|
||||||
import { commaInput } from 'stores/utils';
|
|
||||||
import { useConfigStore } from 'stores/config';
|
import { useConfigStore } from 'stores/config';
|
||||||
|
import { commaInput } from 'stores/utils';
|
||||||
|
|
||||||
// NOTE Import Types
|
// NOTE Import Types
|
||||||
import { BankBook } from 'stores/branch/types';
|
import { BankBook } from 'stores/branch/types';
|
||||||
|
|
@ -44,7 +44,7 @@ type SummaryPrice = {
|
||||||
finalPrice: number;
|
finalPrice: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
const note = ref<string>('asdasd\d \n อะไรครับdasdasd');
|
const note = ref<string>('');
|
||||||
const productList = ref<Product[]>([
|
const productList = ref<Product[]>([
|
||||||
{
|
{
|
||||||
id: 'cm14grwo30002z8ch55keto89',
|
id: 'cm14grwo30002z8ch55keto89',
|
||||||
|
|
@ -159,17 +159,25 @@ onMounted(async () => {
|
||||||
|
|
||||||
data.value = JSON.parse(sessionStorage.getItem('quotation-preview') || '{}');
|
data.value = JSON.parse(sessionStorage.getItem('quotation-preview') || '{}');
|
||||||
|
|
||||||
if (data.value) {
|
if (data) {
|
||||||
productList.value = data.value?.productServiceList.map((v) => ({
|
productList.value =
|
||||||
id: v.product.id,
|
data.value?.productServiceList.map((v) => ({
|
||||||
code: v.product.code,
|
id: v.product.id,
|
||||||
detail: v.product.detail,
|
code: v.product.code,
|
||||||
amount: v.amount,
|
detail: v.product.detail,
|
||||||
priceUnit: v.pricePerUnit || 0,
|
amount: v.amount || 0,
|
||||||
discount: v.discount || 0,
|
priceUnit: v.pricePerUnit || 0,
|
||||||
vat: v.vat || 0,
|
discount: v.discount || 0,
|
||||||
value: 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),
|
||||||
|
),
|
||||||
|
})) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
summaryPrice.value = obj.productServiceList.reduce(
|
summaryPrice.value = obj.productServiceList.reduce(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue