diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-03 17:03:45 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-03 17:03:45 +0700 |
| commit | cd01ba82733062db99075ad7690bdb52fb85745a (patch) | |
| tree | df86ed690452945463abc77263ac058d5b7f9823 /src/pages/shop/quotation | |
| parent | 87af032177192ed1d5d7c68cab911ed102e647bc (diff) | |
no message
Diffstat (limited to 'src/pages/shop/quotation')
| -rw-r--r-- | src/pages/shop/quotation/index.js | 34 |
1 files changed, 16 insertions, 18 deletions
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() { <hr className="my-4 border-gray_r-6"/> <div className="flex flex-col gap-y-4"> <div className="flex gap-x-2 justify-between"> - <p>Subtotal</p> - <p className="font-medium">{currencyFormat(totalPriceBeforeTax)}</p> + <p>Total Belanja</p> + <p className="font-medium">{currencyFormat(totalAmount)}</p> </div> <div className="flex gap-x-2 justify-between"> - <p>PPN 11%</p> - <p className="font-medium">{currencyFormat(totalTaxAmount)}</p> + <p>Total Diskon</p> + <p className="font-medium text-red_r-11">{'- ' + currencyFormat(totalDiscountAmount)}</p> </div> <div className="flex gap-x-2 justify-between"> - <p>Total Diskon</p> - <p className="font-medium text-red_r-11">- {currencyFormat(totalDiscountAmount)}</p> + <p>Subtotal</p> + <p className="font-medium">{currencyFormat(totalAmount - totalDiscountAmount)}</p> + </div> + <div className="flex gap-x-2 justify-between"> + <p>PPN 11% (Incl.)</p> + <p className="font-medium">{currencyFormat((totalAmount - totalDiscountAmount) * 0.11)}</p> </div> </div> <hr className="my-4 border-gray_r-6"/> <div className="flex gap-x-2 justify-between mb-4"> <p>Grand Total</p> - <p className="font-medium text-yellow_r-11">{currencyFormat(totalPriceBeforeTax + totalTaxAmount - totalDiscountAmount)}</p> + <p className="font-medium text-yellow_r-11">{currencyFormat(totalAmount - totalDiscountAmount)}</p> </div> <p className="text-caption-2 text-gray_r-10 mb-2">*) Belum termasuk biaya pengiriman</p> <p className="text-caption-2 text-gray_r-10 leading-5"> |
