iati-data-access / iati-flattener

Library to flatten IATI data
GNU Affero General Public License v3.0
1 stars 3 forks source link

Splitting budgets over quarters doesn't split them evenly when budgets span >1 calendar year #8

Closed simon-20 closed 1 year ago

simon-20 commented 1 year ago

The budget is split evenly by calendar year first, then split by number of quarters the budget runs over within each calendar year, and this can result in an uneven split.

Example: activity GB-COH-11126312-Cluster1 in gdihub-activities.xml produces the following in budget-GM.csv:

| value_original     | ... | transaction_date | country_code |
|--------------------| ... |------------------|--------------|
| 1689.4683333333335 | ... |        2021-3-01 | GM           |
|--------------------| ... |------------------|--------------|
| 1689.4683333333335 | ... |        2021-6-01 | GM           |
| 1689.4683333333335 | ... |        2021-9-01 | GM           |
|--------------------| ... |------------------|--------------|
|  5068.405000000001 | ... |        2022-0-01 | GM           |

The relevant code is in model.py in ActivityBudget._get_budget_periods.