refactor: quotation => hide final discount
This commit is contained in:
parent
be9606f5f3
commit
a60944a187
2 changed files with 4 additions and 47 deletions
|
|
@ -678,41 +678,6 @@ function triggerProductServiceDialog() {
|
|||
pageState.productServiceModal = true;
|
||||
}
|
||||
|
||||
function handlePaySplitDiscount() {
|
||||
if (readonly.value) return;
|
||||
if (quotationFormData.value.payCondition === 'Split') {
|
||||
// Calculate average discount
|
||||
const paySplitArray = JSON.parse(JSON.stringify(tempPaySplit.value));
|
||||
const numSplits = paySplitArray.length;
|
||||
let totalDiscount = quotationFormData.value.discount || 0;
|
||||
const averageDiscount = totalDiscount / numSplits;
|
||||
|
||||
// Adjust each amount
|
||||
paySplitArray.forEach((split: PaySplit) => {
|
||||
if (split.amount < averageDiscount) {
|
||||
totalDiscount -= split.amount; // Subtract the full amount from totalDiscount
|
||||
split.amount = 0; // Set the amount to 0
|
||||
} else {
|
||||
split.amount -= averageDiscount; // Subtract the average discount
|
||||
totalDiscount -= averageDiscount; // Adjust remaining totalDiscount
|
||||
}
|
||||
});
|
||||
|
||||
// Distribute any remaining discount
|
||||
if (totalDiscount > 0) {
|
||||
paySplitArray.forEach((split: PaySplit) => {
|
||||
if (totalDiscount === 0) return;
|
||||
const deduction = Math.min(split.amount, totalDiscount);
|
||||
split.amount -= deduction;
|
||||
totalDiscount -= deduction;
|
||||
});
|
||||
}
|
||||
|
||||
// Update paySplit in quotationFormData
|
||||
quotationFormData.value.paySplit = paySplitArray;
|
||||
}
|
||||
}
|
||||
|
||||
function handleChangePayType(type: PayCondition) {
|
||||
if (
|
||||
type === 'Split' &&
|
||||
|
|
@ -1082,13 +1047,6 @@ watch(
|
|||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => quotationFormData.value.discount,
|
||||
() => {
|
||||
handlePaySplitDiscount();
|
||||
},
|
||||
);
|
||||
|
||||
async function searchEmployee(text: string) {
|
||||
let query: string | undefined = text;
|
||||
let pageSize = 50;
|
||||
|
|
|
|||
|
|
@ -67,8 +67,8 @@ const summaryPrice = defineModel<{
|
|||
},
|
||||
});
|
||||
|
||||
const finalDiscount = defineModel<number>('finalDiscount', { default: 0 });
|
||||
const finalDiscount4Show = ref<string>(finalDiscount.value.toString());
|
||||
// const finalDiscount = defineModel<number>('finalDiscount', { default: 0 });
|
||||
// const finalDiscount4Show = ref<string>(finalDiscount.value.toString());
|
||||
const payTypeOption = computed(() => [
|
||||
{
|
||||
value: 'Full',
|
||||
|
|
@ -412,7 +412,7 @@ function calculateInstallments(param: {
|
|||
฿
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- <div class="row">
|
||||
{{ $t('general.discountAfterVat') }}
|
||||
<q-input
|
||||
:readonly
|
||||
|
|
@ -436,8 +436,7 @@ function calculateInstallments(param: {
|
|||
}
|
||||
"
|
||||
/>
|
||||
<!-- <span class="q-ml-auto">{{ data?.totalVatIncluded || 0 }} ฿</span> -->
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="q-pa-sm row surface-2 items-center text-weight-bold">
|
||||
{{ $t('quotation.totalPriceBaht') }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue