Skip to content

Commit

Permalink
Invoice XML: Use correct timezone for reservation times
Browse files Browse the repository at this point in the history
Instead of adding the reservation times in UTC, convert them to
the correct timezone.

Refs TTVA-187
  • Loading branch information
jopesy committed Dec 20, 2023
1 parent 50162f9 commit 015e024
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions payments/sap_invoices.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytz

from django.conf import settings
from django.template import loader
from django.utils import timezone
Expand Down Expand Up @@ -75,9 +77,12 @@ def get_sales_orders(reservations):
}

if reservation.begin and reservation.end:
timezone = pytz.timezone(settings.TIME_ZONE)
begin = reservation.begin.astimezone(timezone)
end = reservation.end.astimezone(timezone)
billing_period = _("Invoice for reservation %(begin)s - %(end)s") % {
"begin": reservation.begin.strftime("%d.%m.%Y %H:%M"),
"end": reservation.end.strftime("%d.%m.%Y %H:%M"),
"begin": begin.strftime("%d.%m.%Y %H:%M"),
"end": end.strftime("%d.%m.%Y %H:%M"),
}
else:
billing_period = ""
Expand Down

0 comments on commit 015e024

Please sign in to comment.