From 0b4e60970e9bbba3301f2c1f7b5ef0b5307b269d Mon Sep 17 00:00:00 2001 From: Todd Date: Fri, 20 Mar 2026 16:52:20 -0400 Subject: [PATCH] added discount --- index.html | 2 +- public/favicon.png | Bin 0 -> 571 bytes quotes.json | 22 ++++++++++++++ src/components/ItemSelector.jsx | 36 +++++++++++++++++++---- src/components/QuoteSummary.jsx | 49 +++++++++++++++++++------------- 5 files changed, 83 insertions(+), 26 deletions(-) create mode 100644 public/favicon.png diff --git a/index.html b/index.html index dca331a..e5cc337 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - + LB Quote Generator diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..526e89cec4a3081652678b465a0daf1cd2779c4f GIT binary patch literal 571 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10qA0*8#P$FG|3K#LCbkJD z6xeDpqj9GU@-zc>li;O#=#;@NNUDIU&8RiPwsO4d|$CFMwRZ zZ6~B}gVab{#fsj3A%A9^4nq=wgC-nlAZw6Wx@uuj)!NR9?&$# zk|4ie28U-iKt?krdAqwXbg;^L06Clm9+AZi419+`m{C;2s{ts;UgGKN%Km~yT*Oq^ zShpw_D73`W#WBR<^wr6?g_;a_Tz2Pf6kqU2cF)2?|LYg8?PET-<>l&kpHKR2@{~wc zII?HQf+w$cs;GQuci0%vU}nZT<&|u|SmA(J%{}qqq#na zHQWxilsPo#+%m?S`zE~eaILjs7B3QiTRKZ^-x{G8#tz3GnyLO`4cWSJ-`{6^HYqYc zYMiH^SSWF { if (selectedItemIndex !== '' && quantity > 0) { const selectedItem = items[selectedItemIndex]; - onAddItem({ ...selectedItem, quantity: parseInt(quantity, 10) }); + onAddItem({ + ...selectedItem, + quantity: parseInt(quantity, 10), + discount: parseFloat(discount) || 0 + }); setSelectedItemIndex(''); setQuantity(1); + setDiscount(''); } }; return (

Add Items to Quote

-
-
+
+
setDiscount(e.target.value)} + placeholder="0" + /> +
+
setQuantity(e.target.value)} />
-
diff --git a/src/components/QuoteSummary.jsx b/src/components/QuoteSummary.jsx index 8dc8245..b029b67 100644 --- a/src/components/QuoteSummary.jsx +++ b/src/components/QuoteSummary.jsx @@ -24,7 +24,11 @@ export default function QuoteSummary({ items, customer, shippingCost, onShipping }; const calculateSubtotal = () => { - return items.reduce((total, item) => total + (item.Price * item.quantity), 0); + return items.reduce((total, item) => { + const itemTotal = item.Price * item.quantity; + const discountAmount = itemTotal * ((item.discount || 0) / 100); + return total + (itemTotal - discountAmount); + }, 0); }; const subtotal = calculateSubtotal(); @@ -55,30 +59,37 @@ export default function QuoteSummary({ items, customer, shippingCost, onShipping Item ID Description Unit Price + Discount Quantity Total Action - {items.map((item, index) => ( - - {item['Item ID']} - {item.Description} - {formatCurrency(item.Price)} - {item.quantity} - {formatCurrency(item.Price * item.quantity)} - - - - - ))} + {items.map((item, index) => { + const itemTotal = item.Price * item.quantity; + const discountAmount = itemTotal * ((item.discount || 0) / 100); + const finalPrice = itemTotal - discountAmount; + return ( + + {item['Item ID']} + {item.Description} + {formatCurrency(item.Price)} + {item.discount ? `${item.discount}%` : '-'} + {item.quantity} + {formatCurrency(finalPrice)} + + + + + ); + })}