Surye / mfp-keto-userscript

MyFitnessPal Keto Script
164 stars 54 forks source link

Net Carbs not adding correctly #50

Closed ghost closed 5 years ago

ghost commented 5 years ago

A few others have noticed that sometimes the Net Carbs total is incorrect. In the total row, it is calculating the Total Net Carbs as TNC = Total Carbs - Total Fibre:

image

But, as you can see from the image, this results in a negative value, which is obviously wrong.

I think a better calculation would be to simply sum the meal totals for Net Carbs:

image

This would also tally with the remaining value (5 in my image).

Daily Goal = 19 Net Carbs = 12 + 2 = 14 Remaining = 5

Can the script be updated to calculate the Total Net Carbs this way?

Surye commented 5 years ago

This is not a bug, it's because you have food with bad data. You can't have more fiber than carbs. I am also aware that food in UK and other countries have fiber already removed, so this script isn't necessary. But if you mix them they are not going to work. Total Net Carbs as TNC = Total Carbs - Total Fibre is by definition.

Surye commented 5 years ago

I stand corrected, there indeed was a calculation bug (those pesky "net carb" entries in MFP, I hate them!). Pushed a fix.

ghost commented 5 years ago

Here is my modified version that fixes the Net Carbs calculation issue. It also keeps the Daily Goal and Remaining totals intact. MyFitnessPal Percentages and Net Carbs.user.js.txt