From 2c493d33dc43c814a78a5c8ae2b8dc1a43cb2faf Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Fri, 18 Nov 2022 07:40:35 +0100 Subject: [PATCH] Egon Payment compatibility * EGON expects the payment amount to be a localized string instead of float * adds transformation for this --- intervention/utils/egon_export.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/intervention/utils/egon_export.py b/intervention/utils/egon_export.py index 14ea6b6..0b979a1 100644 --- a/intervention/utils/egon_export.py +++ b/intervention/utils/egon_export.py @@ -11,6 +11,7 @@ import json import pika import xmltodict from django.db.models import Sum +from django.utils import formats from intervention.settings import EGON_RABBITMQ_HOST, EGON_RABBITMQ_USER, EGON_RABBITMQ_PW, EGON_RABBITMQ_PORT from konova.sub_settings.django_settings import DEFAULT_DATE_FORMAT @@ -92,6 +93,9 @@ class EgonGmlBuilder: )["summed"] return all_payments + def _float_to_localized_string(self, value: float): + return formats.number_format(value, use_l10n=True, decimal_pos=2) + def _gen_kompensationsArt(self) -> (str, int): comp_type = "Ersatzzahlung" comp_type_code = 774898901 @@ -191,7 +195,7 @@ class EgonGmlBuilder: "@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1053/{reg_office.atom_id if reg_office else None}", "#text": reg_office.long_name if reg_office else None }, - "oneo:ersatzzahlung": self._sum_all_payments(), + "oneo:ersatzzahlung": self._float_to_localized_string(self._sum_all_payments()), "oneo:kompensationsart": { "@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/88140/{comp_type_code}", "#text": comp_type