From 01eb9364e016977da90a279a09fbfd03aee964c3 Mon Sep 17 00:00:00 2001 From: Diana Boiangiu Date: Mon, 19 Jan 2026 11:45:00 +0200 Subject: [PATCH 1/3] Add data_type 'decimal-money' to Fields import --- .../projects_v2/Fields_24_10_2025.json | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core/import_data/resources/projects_v2/Fields_24_10_2025.json b/core/import_data/resources/projects_v2/Fields_24_10_2025.json index d84c2a93d..c2807b05a 100644 --- a/core/import_data/resources/projects_v2/Fields_24_10_2025.json +++ b/core/import_data/resources/projects_v2/Fields_24_10_2025.json @@ -319,7 +319,7 @@ "WRITE_FIELD_NAME": "support_cost_psc", "READ_FIELD_NAME": "support_cost_psc", "TABLE": "project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "Cross-Cutting", "SORT_ORDER": 20, "EDITABLE_IN_VERSIONS": [1,2,3], @@ -1438,7 +1438,7 @@ "WRITE_FIELD_NAME": "aggregated_consumption", "READ_FIELD_NAME": "aggregated_consumption", "TABLE": "project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "Impact", "SORT_ORDER": 108, "EDITABLE_IN_VERSIONS": [1,2,3], @@ -1450,7 +1450,7 @@ "WRITE_FIELD_NAME": "aggregated_consumption_actual", "READ_FIELD_NAME": "aggregated_consumption_actual", "TABLE": "project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "Impact", "IS_ACTUAL": true, "SORT_ORDER": 109, @@ -1463,7 +1463,7 @@ "WRITE_FIELD_NAME": "cost_effectiveness", "READ_FIELD_NAME": "cost_effectiveness", "TABLE": "project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "Impact", "SORT_ORDER": 109, "EDITABLE_IN_VERSIONS": [1,2,3], @@ -1475,7 +1475,7 @@ "WRITE_FIELD_NAME": "cost_effectiveness_actual", "READ_FIELD_NAME": "cost_effectiveness_actual", "TABLE": "project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "Impact", "IS_ACTUAL": true, "SORT_ORDER": 110, @@ -1488,7 +1488,7 @@ "WRITE_FIELD_NAME": "cost_effectiveness_co2", "READ_FIELD_NAME": "cost_effectiveness_co2", "TABLE": "project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "Impact", "SORT_ORDER": 110, "EDITABLE_IN_VERSIONS": [1,2,3], @@ -1500,7 +1500,7 @@ "WRITE_FIELD_NAME": "cost_effectiveness_co2_actual", "READ_FIELD_NAME": "cost_effectiveness_co2_actual", "TABLE": "project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "Impact", "IS_ACTUAL": true, "SORT_ORDER": 111, @@ -1549,7 +1549,7 @@ "WRITE_FIELD_NAME": "aggregated_consumption", "READ_FIELD_NAME": "aggregated_consumption", "TABLE": "meta_project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "MYA", "SORT_ORDER": 114, "EDITABLE_IN_VERSIONS": [1,2,3], @@ -1585,7 +1585,7 @@ "WRITE_FIELD_NAME": "mya_project_funding", "READ_FIELD_NAME": "mya_project_funding", "TABLE": "meta_project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "MYA", "SORT_ORDER": 117, "EDITABLE_IN_VERSIONS": [1,2,3], @@ -1597,7 +1597,7 @@ "WRITE_FIELD_NAME": "mya_support_cost", "READ_FIELD_NAME": "mya_support_cost", "TABLE": "meta_project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "MYA", "SORT_ORDER": 118, "EDITABLE_IN_VERSIONS": [1,2,3], @@ -1681,7 +1681,7 @@ "WRITE_FIELD_NAME": "cost_effectiveness", "READ_FIELD_NAME": "cost_effectiveness", "TABLE": "meta_project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "MYA", "SORT_ORDER": 125, "EDITABLE_IN_VERSIONS": [1,2,3], @@ -1693,7 +1693,7 @@ "WRITE_FIELD_NAME": "cost_effectiveness_co2", "READ_FIELD_NAME": "cost_effectiveness_co2", "TABLE": "meta_project", - "DATA_TYPE": "decimal", + "DATA_TYPE": "decimal-money", "SECTION": "MYA", "SORT_ORDER": 126, "EDITABLE_IN_VERSIONS": [1,2,3], From 70b8f20e47dae217af4cd9d646e02b83b21a2dd3 Mon Sep 17 00:00:00 2001 From: Diana Boiangiu Date: Mon, 19 Jan 2026 11:57:03 +0200 Subject: [PATCH 2/3] Use decimal-money in exports --- .../api/export/single_project_v2/compare_versions_as_xlsx.py | 5 +++-- core/api/export/single_project_v2/xlsx_headers.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/api/export/single_project_v2/compare_versions_as_xlsx.py b/core/api/export/single_project_v2/compare_versions_as_xlsx.py index 65c51744e..48bb9b0e9 100644 --- a/core/api/export/single_project_v2/compare_versions_as_xlsx.py +++ b/core/api/export/single_project_v2/compare_versions_as_xlsx.py @@ -266,9 +266,10 @@ def get_other_headers(self, fields, specific_fields, exclude=None): "section": f.section, "headerName": f.label, } - if f.data_type == "decimal": + if f.data_type == "decimal-money": h_def["cell_format"] = "$###,###,##0.00#############" - + elif f.data_type == "decimal": + h_def["cell_format"] = "###,###,##0.00#############" elif f.data_type == "date": h_def["formatter"] = format_iso_date result.append(h_def) diff --git a/core/api/export/single_project_v2/xlsx_headers.py b/core/api/export/single_project_v2/xlsx_headers.py index b0486f72d..6685a2dc1 100644 --- a/core/api/export/single_project_v2/xlsx_headers.py +++ b/core/api/export/single_project_v2/xlsx_headers.py @@ -127,7 +127,7 @@ def get_headers_specific_information(fields: Iterable[ProjectField]): header["type"] = "bool" elif field_type == "number": header["type"] = "int" - elif field_type == "decimal": + elif field_type == "decimal" or field_type == "decimal-money": header["type"] = "number" header["align"] = "right" From bc42600eae006740de4d930f253ed17b0aa87a26 Mon Sep 17 00:00:00 2001 From: Diana Boiangiu Date: Mon, 19 Jan 2026 15:16:40 +0200 Subject: [PATCH 3/3] Modify import of fields to include actual metaproject table fields --- .../export/single_project_v2/xlsx_headers.py | 2 +- .../import_project_resources_v2.py | 15 +- .../projects_v2/Fields_24_10_2025.json | 212 ++++++++++++++++-- 3 files changed, 206 insertions(+), 23 deletions(-) diff --git a/core/api/export/single_project_v2/xlsx_headers.py b/core/api/export/single_project_v2/xlsx_headers.py index 6685a2dc1..ec6d21c5d 100644 --- a/core/api/export/single_project_v2/xlsx_headers.py +++ b/core/api/export/single_project_v2/xlsx_headers.py @@ -127,7 +127,7 @@ def get_headers_specific_information(fields: Iterable[ProjectField]): header["type"] = "bool" elif field_type == "number": header["type"] = "int" - elif field_type == "decimal" or field_type == "decimal-money": + elif field_type in ["decimal", "decimal-money"]: header["type"] = "number" header["align"] = "right" diff --git a/core/import_data/import_project_resources_v2.py b/core/import_data/import_project_resources_v2.py index 336434d1d..246af85a8 100644 --- a/core/import_data/import_project_resources_v2.py +++ b/core/import_data/import_project_resources_v2.py @@ -415,9 +415,9 @@ def _clean_up_field_name(field_name, mya=False): if field_name in FIELDS_WITH_ACTUAL_VALUES ] field_names_excluding_mya.extend(actual_field_names) - project_fields = ProjectField.objects.exclude(section="MYA").filter( - import_name__in=field_names_excluding_mya - ) + project_fields = ProjectField.objects.exclude( + section__in=["MYA", "N/A"] + ).filter(import_name__in=field_names_excluding_mya) missing_fields = set(field_names_excluding_mya) - set( project_fields.values_list("import_name", flat=True) @@ -436,9 +436,10 @@ def _clean_up_field_name(field_name, mya=False): if row[field_index] != "" ] project_fields = ProjectField.objects.filter( - import_name__in=mya_field_names, section="MYA" + import_name__in=mya_field_names, section__in=["MYA", "N/A"] ) - missing_fields = set(mya_field_names) - set( + + missing_fields = set(missing_fields) - set( project_fields.values_list("import_name", flat=True) ) for missing_field in missing_fields: @@ -608,7 +609,9 @@ def import_fields(file_path): } ProjectField.objects.update_or_create( - import_name=field_data["import_name"], defaults=field_data + import_name=field_data["import_name"], + table=field_data["table"], + defaults=field_data, ) diff --git a/core/import_data/resources/projects_v2/Fields_24_10_2025.json b/core/import_data/resources/projects_v2/Fields_24_10_2025.json index c2807b05a..15fa82517 100644 --- a/core/import_data/resources/projects_v2/Fields_24_10_2025.json +++ b/core/import_data/resources/projects_v2/Fields_24_10_2025.json @@ -1512,7 +1512,7 @@ "LABEL": "Number of enterprises assisted (MYA)", "WRITE_FIELD_NAME": "number_of_enterprises_assisted", "READ_FIELD_NAME": "number_of_enterprises_assisted", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "number", "SECTION": "MYA", "SORT_ORDER": 111, @@ -1524,7 +1524,7 @@ "LABEL": "Number of production lines assisted", "WRITE_FIELD_NAME": "number_of_production_lines_assisted", "READ_FIELD_NAME": "number_of_production_lines_assisted", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "number", "SECTION": "MYA", "SORT_ORDER": 112, @@ -1536,7 +1536,7 @@ "LABEL": "Number of enterprises (MYA)", "WRITE_FIELD_NAME": "number_of_enterprises", "READ_FIELD_NAME": "number_of_enterprises", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "number", "SECTION": "MYA", "SORT_ORDER": 113, @@ -1548,7 +1548,7 @@ "LABEL": "Aggregated consumption (MYA)", "WRITE_FIELD_NAME": "aggregated_consumption", "READ_FIELD_NAME": "aggregated_consumption", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal-money", "SECTION": "MYA", "SORT_ORDER": 114, @@ -1560,7 +1560,7 @@ "LABEL": "Start date (MYA)", "WRITE_FIELD_NAME": "mya_start_date", "READ_FIELD_NAME": "mya_start_date", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "date", "SECTION": "MYA", "SORT_ORDER": 115, @@ -1572,7 +1572,7 @@ "LABEL": "End date (MYA)", "WRITE_FIELD_NAME": "mya_end_date", "READ_FIELD_NAME": "mya_end_date", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "date", "SECTION": "MYA", "SORT_ORDER": 116, @@ -1584,7 +1584,7 @@ "LABEL": "Project funding (MYA)", "WRITE_FIELD_NAME": "mya_project_funding", "READ_FIELD_NAME": "mya_project_funding", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal-money", "SECTION": "MYA", "SORT_ORDER": 117, @@ -1596,7 +1596,7 @@ "LABEL": "Support cost (MYA)", "WRITE_FIELD_NAME": "mya_support_cost", "READ_FIELD_NAME": "mya_support_cost", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal-money", "SECTION": "MYA", "SORT_ORDER": 118, @@ -1608,7 +1608,7 @@ "LABEL": "Targets", "WRITE_FIELD_NAME": "targets", "READ_FIELD_NAME": "targets", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal", "SECTION": "MYA", "SORT_ORDER": 119, @@ -1620,7 +1620,7 @@ "LABEL": "Starting point", "WRITE_FIELD_NAME": "starting_point", "READ_FIELD_NAME": "starting_point", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal", "SECTION": "MYA", "SORT_ORDER": 120, @@ -1632,7 +1632,7 @@ "LABEL": "Baseline", "WRITE_FIELD_NAME": "baseline", "READ_FIELD_NAME": "baseline", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal", "SECTION": "MYA", "SORT_ORDER": 121, @@ -1644,7 +1644,7 @@ "LABEL": "Phase out (CO2-eq t) (MYA)", "WRITE_FIELD_NAME": "mya_phase_out_co2_eq_t", "READ_FIELD_NAME": "mya_phase_out_co2_eq_t", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal", "SECTION": "MYA", "SORT_ORDER": 122, @@ -1656,7 +1656,7 @@ "LABEL": "Phase out (M t) (MYA)", "WRITE_FIELD_NAME": "mya_phase_out_mt", "READ_FIELD_NAME": "mya_phase_out_mt", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal", "SECTION": "MYA", "SORT_ORDER": 123, @@ -1668,7 +1668,7 @@ "LABEL": "Phase out (ODP t) (MYA)", "WRITE_FIELD_NAME": "mya_phase_out_odp_t", "READ_FIELD_NAME": "mya_phase_out_odp_t", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal", "SECTION": "MYA", "SORT_ORDER": 124, @@ -1680,7 +1680,7 @@ "LABEL": "Cost effectiveness (US$/ Kg) (MYA)", "WRITE_FIELD_NAME": "cost_effectiveness", "READ_FIELD_NAME": "cost_effectiveness", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal-money", "SECTION": "MYA", "SORT_ORDER": 125, @@ -1692,11 +1692,191 @@ "LABEL": "Cost effectiveness (US$/ CO2-eq) (MYA)", "WRITE_FIELD_NAME": "cost_effectiveness_co2", "READ_FIELD_NAME": "cost_effectiveness_co2", - "TABLE": "meta_project", + "TABLE": "project", "DATA_TYPE": "decimal-money", "SECTION": "MYA", "SORT_ORDER": 126, "EDITABLE_IN_VERSIONS": [1,2,3], "VISIBLE_IN_VERSIONS": [1,2,3] + }, + { + "IMPORT_NAME": "Project Funding (MYA)", + "LABEL": "Project funding (MYA)", + "WRITE_FIELD_NAME": "project_funding", + "READ_FIELD_NAME": "project_funding", + "TABLE": "meta_project", + "DATA_TYPE": "decimal-money", + "SECTION": "N/A", + "SORT_ORDER": 127, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Support Cost (MYA)", + "LABEL": "Support Cost (MYA)", + "WRITE_FIELD_NAME": "support_cost", + "READ_FIELD_NAME": "support_cost", + "TABLE": "meta_project", + "DATA_TYPE": "decimal-money", + "SECTION": "N/A", + "SORT_ORDER": 128, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Start date (MYA)", + "LABEL": "Start date (MYA)", + "WRITE_FIELD_NAME": "start_date", + "READ_FIELD_NAME": "start_date", + "TABLE": "meta_project", + "DATA_TYPE": "date", + "SECTION": "N/A", + "SORT_ORDER": 129, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "End date (MYA)", + "LABEL": "End date (MYA)", + "WRITE_FIELD_NAME": "end_date", + "READ_FIELD_NAME": "end_date", + "TABLE": "meta_project", + "DATA_TYPE": "date", + "SECTION": "N/A", + "SORT_ORDER": 130, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Phase out (ODP t) (MYA)", + "LABEL": "Phase out (ODP t) (MYA)", + "WRITE_FIELD_NAME": "phase_out_odp", + "READ_FIELD_NAME": "phase_out_odp", + "TABLE": "meta_project", + "DATA_TYPE": "decimal", + "SECTION": "N/A", + "SORT_ORDER": 131, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Phase out (Mt) (MYA)", + "LABEL": "Phase out (M t) (MYA)", + "WRITE_FIELD_NAME": "phase_out_mt", + "READ_FIELD_NAME": "phase_out_mt", + "TABLE": "meta_project", + "DATA_TYPE": "decimal", + "SECTION": "N/A", + "SORT_ORDER": 132, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Targets", + "LABEL": "Targets", + "WRITE_FIELD_NAME": "targets", + "READ_FIELD_NAME": "targets", + "TABLE": "meta_project", + "DATA_TYPE": "decimal", + "SECTION": "N/A", + "SORT_ORDER": 133, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Starting Point", + "LABEL": "Starting point", + "WRITE_FIELD_NAME": "starting_point", + "READ_FIELD_NAME": "starting_point", + "TABLE": "meta_project", + "DATA_TYPE": "decimal", + "SECTION": "N/A", + "SORT_ORDER": 134, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Baseline", + "LABEL": "Baseline", + "WRITE_FIELD_NAME": "baseline", + "READ_FIELD_NAME": "baseline", + "TABLE": "meta_project", + "DATA_TYPE": "decimal", + "SECTION": "N/A", + "SORT_ORDER": 135, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Number of enterprises assisted (MYA)", + "LABEL": "Number of enterprises assisted", + "WRITE_FIELD_NAME": "number_of_enterprises_assisted", + "READ_FIELD_NAME": "number_of_enterprises_assisted", + "TABLE": "meta_project", + "DATA_TYPE": "number", + "SECTION": "N/A", + "SORT_ORDER": 136, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Number of enterprises (MYA)", + "LABEL": "Number of enterprises", + "WRITE_FIELD_NAME": "number_of_enterprises", + "READ_FIELD_NAME": "number_of_enterprises", + "TABLE": "meta_project", + "DATA_TYPE": "number", + "SECTION": "N/A", + "SORT_ORDER": 137, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Aggregated consumption (MYA)", + "LABEL": "Aggregated consumption", + "WRITE_FIELD_NAME": "aggregated_consumption", + "READ_FIELD_NAME": "aggregated_consumption", + "TABLE": "meta_project", + "DATA_TYPE": "decimal-money", + "SECTION": "N/A", + "SORT_ORDER": 138, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Number of Production Lines assisted (MYA)", + "LABEL": "Number of Production Lines assisted", + "WRITE_FIELD_NAME": "number_of_production_lines_assisted", + "READ_FIELD_NAME": "number_of_production_lines_assisted", + "TABLE": "meta_project", + "DATA_TYPE": "number", + "SECTION": "MYA", + "SORT_ORDER": 139, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Cost effectiveness (US$/ Kg) (MYA)", + "LABEL": "Cost effectiveness (US$/ Kg)", + "WRITE_FIELD_NAME": "cost_effectiveness_kg", + "READ_FIELD_NAME": "cost_effectiveness_kg", + "TABLE": "meta_project", + "DATA_TYPE": "decimal-money", + "SECTION": "MYA", + "SORT_ORDER": 140, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] + }, + { + "IMPORT_NAME": "Cost effectiveness (US$/ CO2-eq) (MYA)", + "LABEL": "Cost effectiveness (US$/ CO2-ep)", + "WRITE_FIELD_NAME": "cost_effectiveness_co2", + "READ_FIELD_NAME": "cost_effectiveness_co2", + "TABLE": "meta_project", + "DATA_TYPE": "decimal-money", + "SECTION": "MYA", + "SORT_ORDER": 141, + "EDITABLE_IN_VERSIONS": [3], + "VISIBLE_IN_VERSIONS": [3] } ]