refactor: handle intallment no
This commit is contained in:
parent
530ad6042b
commit
afb9ddf424
3 changed files with 45 additions and 5 deletions
|
|
@ -276,11 +276,38 @@ const successAll = computed(() => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getInstallmentInfo() {
|
||||||
|
if (
|
||||||
|
data.value?.quotation.payCondition === 'Full' ||
|
||||||
|
data.value?.quotation.payCondition === 'BillFull'
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const total = data.value?.quotation.paySplitCount || 0;
|
||||||
|
const paid = data.value?.quotation.invoice?.reduce((a, c) => {
|
||||||
|
if (c.payment?.paymentStatus === 'PaymentSuccess') {
|
||||||
|
a += c.installments.length || 0;
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return { total, paid };
|
||||||
|
}
|
||||||
|
|
||||||
function isInstallmentPaySuccess(installmentNo: number) {
|
function isInstallmentPaySuccess(installmentNo: number) {
|
||||||
const invoice = data.value?.quotation.invoice?.find((lhs) =>
|
if (
|
||||||
lhs.installements.some((rhs) => rhs.no === installmentNo),
|
data.value?.quotation.payCondition === 'Full' ||
|
||||||
);
|
data.value?.quotation.payCondition === 'BillFull'
|
||||||
return !!(invoice?.payment?.paymentStatus === 'Success');
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const invoice = data.value?.quotation.invoice?.find((lhs) => {
|
||||||
|
return lhs.installments?.some((rhs) => rhs.no === installmentNo);
|
||||||
|
});
|
||||||
|
|
||||||
|
return !!(invoice?.payment?.paymentStatus === 'PaymentSuccess');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -587,7 +614,13 @@ function isInstallmentPaySuccess(installmentNo: number) {
|
||||||
)"
|
)"
|
||||||
:key="value"
|
:key="value"
|
||||||
>
|
>
|
||||||
|
{{ getInstallmentInfo() }}
|
||||||
<ProductExpansion
|
<ProductExpansion
|
||||||
|
:class="{
|
||||||
|
'status-unpaid': !isInstallmentPaySuccess(
|
||||||
|
value.productService.installmentNo,
|
||||||
|
),
|
||||||
|
}"
|
||||||
:status="
|
:status="
|
||||||
value.stepStatus?.find((v) => v.step === pageState.currentStep)
|
value.stepStatus?.find((v) => v.step === pageState.currentStep)
|
||||||
"
|
"
|
||||||
|
|
@ -710,6 +743,12 @@ function isInstallmentPaySuccess(installmentNo: number) {
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.status-unpaid {
|
||||||
|
opacity: 0.5;
|
||||||
|
filter: grayscale(90%);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.status-color {
|
.status-color {
|
||||||
--_color: var(--gray-0);
|
--_color: var(--gray-0);
|
||||||
border-color: hsla(var(--_color));
|
border-color: hsla(var(--_color));
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export type Invoice = {
|
||||||
|
|
||||||
amount: number;
|
amount: number;
|
||||||
|
|
||||||
installements: QuotationFull['paySplit'];
|
installments: QuotationFull['paySplit'];
|
||||||
|
|
||||||
quotation: Quotation;
|
quotation: Quotation;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,7 @@ export type QuotationFull = {
|
||||||
productServiceId: string;
|
productServiceId: string;
|
||||||
employeeId: string;
|
employeeId: string;
|
||||||
}[];
|
}[];
|
||||||
|
installmentNo: number;
|
||||||
}[];
|
}[];
|
||||||
|
|
||||||
id: string;
|
id: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue