Open kishanmodi opened 2 years ago
I found a solution to all problems. All bugs here are very easy to fix, but hard to find.
Solution for 1. and 3. In InvoiceForm.js around line 80 (mine says 84 because i have changed the code a little, you can also search for it using ctrl+f). you need to add another phraseFloat()
because (i think, i am also not an expert) .toFixed()
changes it back to string (and adding strings together is a mess)
Solution for 2. I am no longer sure what fixed it in my code, but I think it could have been one of toFixed(2)
around 85 line and below (see image)
You can also add toString like on the image since the taxAmmount
and discountAmmount
are string values.
@amarcin3 Back When I was learning, I created the same project. if you would like to check here's the link Invoice Generator.
@kishanmodi Well, you have made some things work, but you also broke it a bit. When you delete the row above it breaks all the rows below. I know it was like a "one day project", and It won't be used as an actual invoice maker for any company, so it's fine.
Still there was error in subtotal calculation, Can @johnuberbacher u assign me this issue?
Just add these lines in InvoiceForm component and it will fix all issue
handleCalculateTotal() {
var itemList = this.state.items;
var subTotal = 0;
// items.map(function (items) {
// subTotal = parseFloat(
// subTotal + parseFloat(items.price).toFixed(2) * parseInt(items.quantity)
// ).toFixed(2);
// });
itemList.map(
(itemDetail) =>
(subTotal +=
parseFloat(itemDetail.price).toFixed(2) *
parseInt(itemDetail.quantity))
);
i am also not an expert😅
When I checked the functionality of your app while I was trying to replicate your project, I encountered a few bugs.
Subtotal is not calculating the remaining items other than the first one
Showing wrong precision
Subtotal is not updated in the preview invoice as well.
I may be wrong as I am a beginner in react. Do check out these issues.