Skip to content

Commit

Permalink
Use all item codes
Browse files Browse the repository at this point in the history
Use all codes, not only those from the latest schema version
  • Loading branch information
michaelglenister committed Oct 14, 2024
1 parent 566454b commit f220aee
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 33 deletions.
9 changes: 1 addition & 8 deletions municipal_finance/update/capital_facts_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ class CapitalFactsV2Updater(Updater):
"functions": GovernmentFunctionsV2,
"capital_types": CapitalTypeV2,
}
schema_version = references_cls["items"].objects.aggregate(version=Max("version"))[
"version"
]
ref_items = references_cls["items"].objects.filter(version=schema_version)
item_map = {}
for item in ref_items:
item_map[str(item)] = item

def build_unique_query(self, rows):
return build_unique_query_params_with_period(rows)
Expand All @@ -67,7 +60,7 @@ def row_to_obj(self, row):
financial_period,
) = period_code_details(row.period_code)
amount = int(row.amount) if row.amount else None
item = self.item_map[row.item_code]
item = self.references["items"][row.item_code]
amount_type = self.references["amount_types"][amount_type_code]
function = self.references["functions"][row.function_code]
capital_type = self.references["capital_types"][row.capital_type_code]
Expand Down
9 changes: 1 addition & 8 deletions municipal_finance/update/cash_flow_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ class CashFlowFactsV2Updater(Updater):
"amount_types": AmountTypeV2,
"items": CflowItemsV2,
}
schema_version = references_cls["items"].objects.aggregate(version=Max("version"))[
"version"
]
ref_items = references_cls["items"].objects.filter(version=schema_version)
item_map = {}
for item in ref_items:
item_map[str(item)] = item

def build_unique_query(self, rows):
return build_unique_query_params_with_period(rows)
Expand All @@ -67,7 +60,7 @@ def row_to_obj(self, row: CashFlowFactRow):
financial_period,
) = period_code_details(row.period_code)
amount = int(row.amount) if row.amount else None
item = self.item_map[row.item_code]
item = self.references["items"][row.item_code]
amount_type = self.references["amount_types"][amount_type_code]
return CflowFactsV2(
demarcation_code=row.demarcation_code,
Expand Down
10 changes: 1 addition & 9 deletions municipal_finance/update/financial_position_facts_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ class FinancialPositionFactsUpdater(Updater):
"items": FinancialPositionItemsV2,
"amount_types": AmountTypeV2,
}
schema_version = references_cls["items"].objects.aggregate(version=Max("version"))[
"version"
]
ref_items = references_cls["items"].objects.filter(version=schema_version)

item_map = {}
for item in ref_items:
item_map[str(item)] = item

def build_unique_query(self, rows):
return build_unique_query_params_with_period(rows)
Expand All @@ -62,7 +54,7 @@ def row_to_obj(self, row):
financial_period,
) = period_code_details(row.period_code)
amount = int(row.amount) if row.amount else None
item = self.item_map[row.item_code]
item = self.references["items"][row.item_code]
amount_type = self.references["amount_types"][amount_type_code]
return self.facts_cls(
demarcation_code=row.demarcation_code,
Expand Down
9 changes: 1 addition & 8 deletions municipal_finance/update/income_expenditure_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ class IncomeExpenditureFactsV2Updater(Updater):
"items": IncexpItemsV2,
"functions": GovernmentFunctionsV2,
}
schema_version = references_cls["items"].objects.aggregate(version=Max("version"))[
"version"
]
ref_items = references_cls["items"].objects.filter(version=schema_version)
item_map = {}
for item in ref_items:
item_map[str(item)] = item

def build_unique_query(self, rows):
return build_unique_query_params_with_period(rows)
Expand All @@ -69,7 +62,7 @@ def row_to_obj(self, row: IncomeExpenditureFactRow):
financial_period,
) = period_code_details(row.period_code)
amount = int(row.amount) if row.amount else None
item = self.item_map[row.item_code]
item = self.references["items"][row.item_code]
function = self.references["functions"][row.function_code]
amount_type = self.references["amount_types"][amount_type_code]
return IncexpFactsV2(
Expand Down

0 comments on commit f220aee

Please sign in to comment.