update limit
This commit is contained in:
@@ -199,14 +199,23 @@ export default function DialogBenefit({requestLog, setOpenDialog, openDialog, cl
|
||||
// Periksa apakah limitAmount Benefit lebih besar dari realTimeUsage
|
||||
if (limitAmountPlan != 999999999){
|
||||
let realTimeUsage = 0;
|
||||
let value = 0;
|
||||
for (let key in requestLog?.member_usage_benefit) {
|
||||
if (requestLog?.member_usage_benefit.hasOwnProperty(key)) {
|
||||
realTimeUsage += requestLog?.member_usage_benefit[key];
|
||||
let value = requestLog?.member_usage_benefit[key];
|
||||
// Menggunakan parseFloat() untuk mengonversi nilai menjadi angka
|
||||
let numericValue = parseFloat(value);
|
||||
// Memeriksa apakah numericValue adalah angka yang valid
|
||||
if (!isNaN(numericValue)) {
|
||||
realTimeUsage += numericValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let amountApproved = Number(benefitData[key].amount_approved) || 0;
|
||||
// Hitung penggunaan waktu nyata
|
||||
realTimeUsage += amountApproved;
|
||||
console.log(realTimeUsage)
|
||||
if (limitAmountPlan < realTimeUsage) {
|
||||
setError(`benefit_data.${key}.amount_approved`, { message: `Total Amount Approve sudah melebihi limit ${ fNumber(limitAmountPlan) } , silakan isikan di Amount Excess` });
|
||||
} else if (totalAll().totalAmountApproved > totalAll().totalAmountIncurred) {
|
||||
@@ -235,6 +244,12 @@ export default function DialogBenefit({requestLog, setOpenDialog, openDialog, cl
|
||||
clearErrors(`benefit_data.${key}.amount_approved`);
|
||||
}
|
||||
}
|
||||
|
||||
if (totalAll().totalAmountApproved + totalAll().totalAmountNotApproved === totalAll().totalAmountIncurred) {
|
||||
clearErrors(`benefit_data.${key}.excess_paid`);
|
||||
} else {
|
||||
setError(`benefit_data.${key}.excess_paid`, { message: 'Total Amount Excess tidak sama dengan Total Amount Incurred' });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (totalAll().totalAmountApproved > totalAll().totalAmountIncurred){
|
||||
@@ -248,7 +263,9 @@ export default function DialogBenefit({requestLog, setOpenDialog, openDialog, cl
|
||||
const handleOnChangeNotApprove = (key, value) => {
|
||||
setValue(`benefit_data.${key}.excess_paid`, value);
|
||||
if (totalAll().totalAmountApproved + totalAll().totalAmountNotApproved === totalAll().totalAmountIncurred) {
|
||||
clearErrors(`benefit_data.${key}.amount_approved`);
|
||||
clearErrors(`benefit_data.${key}.excess_paid`);
|
||||
} else {
|
||||
setError(`benefit_data.${key}.excess_paid`, { message: 'Total Amount Excess tidak sama dengan Total Amount Incurred' });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user