Skip to content

Commit 524d2ff

Browse files
Add default field to update
1 parent 1fabeb9 commit 524d2ff

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

municipal_finance/management/commands/make_sub_totals.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,15 @@ def handle(self, *args, **options):
7777
item_code = FinancialPositionItemsV2.objects.get(code=item_key)
7878

7979
if sub_total != 0:
80-
try:
81-
FinancialPositionFactsV2.objects.update_or_create(
82-
financial_year=fin_year,
83-
financial_period=fin_year,
84-
period_code=f"{fin_year}{amount_type_model.code}",
85-
item_id=item_code.id,
86-
demarcation_code=muni_code,
87-
amount_type=amount_type_model,
88-
period_length="year",
89-
amount=sub_total,
90-
)
91-
except (ValueError, TypeError) as e:
92-
pass
80+
FinancialPositionFactsV2.objects.update_or_create(
81+
financial_year=fin_year,
82+
financial_period=fin_year,
83+
period_code=f"{fin_year}{amount_type_model.code}",
84+
item_id=item_code.id,
85+
demarcation_code=muni_code,
86+
amount_type=amount_type_model,
87+
period_length="year",
88+
defaults={
89+
'amount': sub_total,
90+
}
91+
)

0 commit comments

Comments
 (0)