Skip to content

Commit

Permalink
calculate_invoice_for_reg_id(
Browse files Browse the repository at this point in the history
    registration_id: int, update_record: bool = False
  • Loading branch information
lexxai committed Apr 18, 2024
1 parent 2d08164 commit 556f514
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion FRONTEND/fastparking/photos/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ def calculate_invoice(
return parking_fee


def calculate_invoice_for_reg_id(registration_id: int) -> float | None:
def calculate_invoice_for_reg_id(
registration_id: int, update_record: bool = False
) -> float | None:
result = None
try:
registration = Registration.objects.get(pk=registration_id)
Expand All @@ -395,6 +397,10 @@ def calculate_invoice_for_reg_id(registration_id: int) -> float | None:
exit_datetime=registration.exit_datetime,
tariff_in=tariff_in,
)
if update_record and result:
registration.invoice = str(result)
registration.save()

except Registration.DoesNotExist as e:
print(f"Error: {e}")

Expand Down

0 comments on commit 556f514

Please sign in to comment.