feat: price vat
This commit is contained in:
parent
fb5e10fe04
commit
c5b3e4dbd7
3 changed files with 73 additions and 53 deletions
|
|
@ -16,6 +16,10 @@ import {
|
|||
Service,
|
||||
Work,
|
||||
} from 'src/stores/product-service/types';
|
||||
import { precisionRound } from 'src/utils/arithmetic';
|
||||
import { useConfigStore } from 'src/stores/config';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onMounted } from 'vue';
|
||||
|
||||
type Node = {
|
||||
[key: string]: any;
|
||||
|
|
@ -29,6 +33,13 @@ type Node = {
|
|||
type ProductGroupId = string;
|
||||
|
||||
const optionStore = useOptionStore();
|
||||
const configStore = useConfigStore();
|
||||
|
||||
const { data: config } = storeToRefs(configStore);
|
||||
|
||||
const prop = defineProps<{
|
||||
agentPrice: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'selectGroup', id: string): void;
|
||||
|
|
@ -69,6 +80,8 @@ const priceDisplay = computed(() => ({
|
|||
]),
|
||||
}));
|
||||
|
||||
onMounted(configStore.getConfig);
|
||||
|
||||
const nodes = ref<Node[]>([]);
|
||||
const productServiceCard = ref<{
|
||||
service: Record<string, any>[];
|
||||
|
|
@ -217,29 +230,44 @@ function mapNode() {
|
|||
opened: w.productOnWork.length > 0,
|
||||
checked: true,
|
||||
attributes: w.attributes,
|
||||
children: w.productOnWork.map((p) => ({
|
||||
id: p.product.id,
|
||||
title: p.product.name,
|
||||
subtitle: p.product.code || ' ',
|
||||
checked: true,
|
||||
detail: p.product.detail,
|
||||
remark: p.product.remark,
|
||||
value: {
|
||||
vat: 0,
|
||||
pricePerUnit: 0,
|
||||
discount: 0,
|
||||
amount: 0,
|
||||
service: v.raw,
|
||||
work: w,
|
||||
product: p.product,
|
||||
},
|
||||
type: 'product',
|
||||
})),
|
||||
children: w.productOnWork.map((p) => {
|
||||
const price = prop.agentPrice
|
||||
? p.product.agentPrice
|
||||
: p.product.price;
|
||||
const pricePerUnit = p.product.vatIncluded
|
||||
? precisionRound(price / (1 + (config.value?.vat || 0.07)))
|
||||
: price;
|
||||
console.log(pricePerUnit);
|
||||
return {
|
||||
id: p.product.id,
|
||||
title: p.product.name,
|
||||
subtitle: p.product.code || ' ',
|
||||
checked: true,
|
||||
detail: p.product.detail,
|
||||
remark: p.product.remark,
|
||||
value: {
|
||||
vat: 0,
|
||||
pricePerUnit,
|
||||
discount: 0,
|
||||
amount: 0,
|
||||
service: v.raw,
|
||||
work: w,
|
||||
product: p.product,
|
||||
},
|
||||
type: 'product',
|
||||
};
|
||||
}),
|
||||
}));
|
||||
return noNameObjects.concat(withNameObjects);
|
||||
})(),
|
||||
};
|
||||
} else {
|
||||
const price = prop.agentPrice ? v.agentPrice : v.price;
|
||||
const pricePerUnit = v.vatIncluded
|
||||
? precisionRound(price / (1 + (config.value?.vat || 0.07)))
|
||||
: price;
|
||||
|
||||
console.log(pricePerUnit);
|
||||
return {
|
||||
id: v.id,
|
||||
title: v.name,
|
||||
|
|
@ -248,7 +276,7 @@ function mapNode() {
|
|||
remark: v.remark,
|
||||
value: {
|
||||
vat: 0,
|
||||
pricePerUnit: 0,
|
||||
pricePerUnit,
|
||||
discount: 0,
|
||||
amount: 0,
|
||||
product: v.raw,
|
||||
|
|
|
|||
|
|
@ -690,6 +690,7 @@ watch(
|
|||
v-model:product-group="productGroup"
|
||||
v-model:product-list="productList"
|
||||
v-model:service-list="serviceList"
|
||||
:agent-price="agentPrice"
|
||||
@submit="convertToTable"
|
||||
@select-group="
|
||||
async (id) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue