frappe / books

Free Accounting Software
https://frappe.io/books
GNU Affero General Public License v3.0
2.68k stars 614 forks source link

🐛 [Bug] - Profit and Loss Graph breaking on dashboard #820

Closed njmulsqb closed 5 months ago

njmulsqb commented 5 months ago

Expected Behavior

It should stay within the axis like for filter "this year"

image

Current Behavior

P&L graph is going out of axis in dashboard when "Year to Date" is selected

image

Steps to Reproduce

No response

FrappeBooks Version

0.20.1

Path or Feature name

Dashboard

Country

Pk

Language

EN

OS

Macos (Apple Silicon)

Additional OS Info

No response

njmulsqb commented 5 months ago

image Errors errors all the way. Miscalculated values and broken graphs, frappe seems to be in trouble recently

Isaac-GC commented 5 months ago

Unfortunately, in this case, it looks like this issue has been around for a while and has been hiding. It was fixed in https://github.com/frappe/books/pull/821 and in the latest version of Frappe Books

What happened is that the backend logic tries to figure out how to arrange and count the items needed for the graphs. In doing so, it subtracts 1 from a count and then divides by that subsequent value. As "Year to Date" starts with January, there will only be one item collected, and when 1 is subtracted from the items collected, there is 0 items/results remaining. That value (0) will be used in the denominator to try and divide by 0... which resulted in those (excessive) errors

Note: The line graph may look empty in the latest update, but the values are there and as soon as we hit February 1st (next Thursday), the line graph will show up as expected. The reason they don't show up now is that there is only one set of values for each of the profit and loss points, and when February hits, you'll have two sets of values each which will show up as expected. This has been part of the design since the feature had been added. IMO, it should be updated so if there is only set of values, you can at least see them on the graph. --> this will likely be in a future feature update