| | |
| | | } |
| | | |
| | | const calculateTotal = () => { |
| | | form.discountAmount = form.subtotal * (form.discountRate / 100) |
| | | form.totalAmount = form.subtotal + form.freight + form.otherFee - form.discountAmount |
| | | const rate = Number(form.discountRate) |
| | | const hasRate = Number.isFinite(rate) && rate > 0 |
| | | const subtotal = Number(form.subtotal) || 0 |
| | | const freight = Number(form.freight) || 0 |
| | | const otherFee = Number(form.otherFee) || 0 |
| | | form.discountAmount = hasRate ? subtotal * (rate / 100) : 0 |
| | | form.totalAmount = subtotal + freight + otherFee - form.discountAmount |
| | | } |
| | | |
| | | const handleCustomerChange = () => { |