Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kishanmodi opened this issue Aug 19, 2022 · 5 comments
Open

Comments

@kishanmodi
Copy link

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
Copy link

amarcin3 commented Oct 4, 2022

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
Copy link
Author

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

@amarcin3
Copy link

amarcin3 commented Dec 21, 2022

@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
Copy link

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

@rahulS-repo
Copy link

rahulS-repo commented Sep 17, 2023

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😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants