diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 1846b2d5..94ad68ae 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -447,7 +447,6 @@ export default function Estimate({ params }) { }) //아이템들 중 조건에 맞는애들 뽑아서 상단 공급가액 부가세 총액 수정 setItemChangeYn(true) - } else { } } @@ -471,10 +470,15 @@ export default function Estimate({ params }) { updateList = estimateContextState.itemList.map((item) => { if (item.dispOrder === dispOrder) { return { ...item, ...updates } + } else if (item.paDispOrder === dispOrder) { + return { ...item, ...updates, amount: (item.bomAmount * amount?.replaceAll(',', '')).toLocaleString(), saleTotPrice: '0' } } else { return item } }) + + console.log('updateList::', updateList) + // return setEstimateContextState({ itemList: updateList, }) @@ -556,7 +560,6 @@ export default function Estimate({ params }) { return { ...item, ...updates } } else if (item.paDispOrder === dispOrder) { return { ...item, delFlg: '0' } - // return { ...item, delFlg: '1' } } else { return item } @@ -569,14 +572,16 @@ export default function Estimate({ params }) { bomItem.dispOrder = (index + 1 + maxItemDispOrder).toString() bomItem.paDispOrder = dispOrder bomItem.salePrice = '0' - //unitPrice는?? bomItem.saleTotPrice = '0' + bomItem.unitPrice = '0' + bomItem.amount = bomItem.bomAmount } else { bomItem.dispOrder = (index + 1 + Number(dispOrder)).toString() bomItem.paDispOrder = dispOrder bomItem.salePrice = '0' - //unitPrice는?? bomItem.saleTotPrice = '0' + bomItem.unitPrice = '0' + bomItem.amount = bomItem.bomAmount } bomItem.delFlg = '0' @@ -620,6 +625,8 @@ export default function Estimate({ params }) { } }) + console.log('updateList::', updateList) + let delCnt = 0 updateList.map((item) => { if (item.delFlg === '1') { @@ -696,15 +703,16 @@ export default function Estimate({ params }) { estimateContextState.itemList.map((item) => { if (item.delFlg === '0') { let amount = Number(item.amount?.replace(/[^0-9]/g, '').replaceAll(',', '')) - let price = Number(item.saleTotPrice?.replaceAll(',', '')) + console.log('amount::', amount) let salePrice = Number(item.salePrice?.replaceAll(',', '')) + let saleTotPrice = Number(item.saleTotPrice?.replaceAll(',', '')) if (isNaN(amount)) { amount = 0 } - if (isNaN(price)) { - price = 0 + if (isNaN(saleTotPrice)) { + saleTotPrice = 0 } if (isNaN(salePrice)) { @@ -715,9 +723,7 @@ export default function Estimate({ params }) { const volKw = (item.pnowW * amount) / 1000 totVolKw += volKw } - - // const price - supplyPrice += price + // const saleTotPrice totAmount += amount if (item.pkgMaterialFlg === '1') { const pkgPrice = amount * salePrice @@ -725,6 +731,7 @@ export default function Estimate({ params }) { //YJSS는 PKG제외상품들만(1) 모아서 수량 * 단가를 공급가액(supplyPrice)에 추가로 더해줌 addSupplyPrice += pkgPrice } + if (!item.paDispOrder) { //paDispOrder if (item.pkgMaterialFlg === '0') { @@ -735,7 +742,7 @@ export default function Estimate({ params }) { } }) - supplyPrice += addSupplyPrice + supplyPrice = addSupplyPrice + Number(estimateContextState.pkgTotPrice) vatPrice = supplyPrice * 0.1 totPrice = supplyPrice + vatPrice setEstimateContextState({ @@ -1145,15 +1152,15 @@ export default function Estimate({ params }) {