Third-Culture-Software / bhima

A hospital information management application for rural Congolese hospitals
https://docs.bhi.ma/
GNU General Public License v2.0
218 stars 104 forks source link

Clarify budget processing code #7741

Open jniles opened 2 weeks ago

jniles commented 2 weeks ago

Reference: https://github.com/IMA-WorldHealth/bhima/pull/7684#discussion_r1749299300.

The budget code recently introduced is a bit difficult to read and rationalize, since it include different processing for totals and summing in the same for loop. I propose we break this out with better variable names so that we remember in the future why we wrote the code the way we did.

Specifically, these lines: https://github.com/IMA-WorldHealth/bhima/blob/36e7a7fccf8e952071639c35db05fa8b730cba62/server/controllers/finance/reports/budget_analytical/index.js#L96C1-L147

Embed an if/else statement in two for loops, which is somewhat difficult to think about. We should try to break them out to be less convoluted.