From cd01ba82733062db99075ad7690bdb52fb85745a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 3 Feb 2023 17:03:45 +0700 Subject: no message --- src/pages/shop/quotation/index.js | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'src/pages/shop/quotation') diff --git a/src/pages/shop/quotation/index.js b/src/pages/shop/quotation/index.js index cf2b956d..e1c196db 100644 --- a/src/pages/shop/quotation/index.js +++ b/src/pages/shop/quotation/index.js @@ -16,8 +16,7 @@ export default function Quotation() { const router = useRouter(); const [ auth ] = useAuth(); const [ products, setProducts ] = useState([]); - const [ totalPriceBeforeTax, setTotalPriceBeforeTax ] = useState(0); - const [ totalTaxAmount, setTotalTaxAmount ] = useState(0); + const [ totalAmount, setTotalAmount ] = useState(0); const [ totalDiscountAmount, setTotalDiscountAmount ] = useState(0); useEffect(() => { @@ -43,18 +42,13 @@ export default function Quotation() { useEffect(() => { if (products) { - const productsSelected = products.filter((product) => product.selected == true); - let calculateTotalPriceBeforeTax = 0; - let calculateTotalTaxAmount = 0; + let calculateTotalAmount = 0; let calculateTotalDiscountAmount = 0; - productsSelected.forEach(product => { - let priceBeforeTax = product.price.price / 1.11; - calculateTotalPriceBeforeTax += priceBeforeTax * product.quantity; - calculateTotalTaxAmount += (product.price.price - priceBeforeTax) * product.quantity; + products.forEach(product => { + calculateTotalAmount += product.price.price * product.quantity; calculateTotalDiscountAmount += (product.price.price - product.price.price_discount) * product.quantity; }); - setTotalPriceBeforeTax(calculateTotalPriceBeforeTax); - setTotalTaxAmount(calculateTotalTaxAmount); + setTotalAmount(calculateTotalAmount); setTotalDiscountAmount(calculateTotalDiscountAmount); } }, [products]); @@ -102,22 +96,26 @@ export default function Quotation() {
-

Subtotal

-

{currencyFormat(totalPriceBeforeTax)}

+

Total Belanja

+

{currencyFormat(totalAmount)}

-

PPN 11%

-

{currencyFormat(totalTaxAmount)}

+

Total Diskon

+

{'- ' + currencyFormat(totalDiscountAmount)}

-

Total Diskon

-

- {currencyFormat(totalDiscountAmount)}

+

Subtotal

+

{currencyFormat(totalAmount - totalDiscountAmount)}

+
+
+

PPN 11% (Incl.)

+

{currencyFormat((totalAmount - totalDiscountAmount) * 0.11)}


Grand Total

-

{currencyFormat(totalPriceBeforeTax + totalTaxAmount - totalDiscountAmount)}

+

{currencyFormat(totalAmount - totalDiscountAmount)}

*) Belum termasuk biaya pengiriman

-- cgit v1.2.3