johnuberbacher / invoice-generator

An Invoice creator project built with React. Uses jspdf-react to capture the data from the modal and convert it from canvas -> pdf.
https://invoice-generator-react.netlify.app/
239 stars 172 forks source link

there are few bugs if I am not wrong in the subtotal of the invoice #1

Open kishanmodi opened 2 years ago

kishanmodi commented 2 years ago

When I checked the functionality of your app while I was trying to replicate your project, I encountered a few bugs.

  1. Subtotal is not calculating the remaining items other than the first one image

  2. Showing wrong precision image

  3. Subtotal is not updated in the preview invoice as well. image

I may be wrong as I am a beginner in react. Do check out these issues.

amarcin3 commented 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) git13

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) git2 You can also add toString like on the image since the taxAmmount and discountAmmount are string values.

kishanmodi commented 1 year ago

@amarcin3 Back When I was learning, I created the same project. if you would like to check here's the link Invoice Generator.

amarcin3 commented 1 year ago

@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.

Vyomrana02 commented 1 year ago

Still there was error in subtotal calculation, Can @johnuberbacher u assign me this issue?

rahulS-repo commented 1 year ago

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😅