Merge pull request 'master' (#241) from master into Docker
Reviewed-on: SGD-Nord/konova#241
This commit is contained in:
commit
c9dac9ad5e
@ -1,5 +1,5 @@
|
||||
{
|
||||
"eco_account": "CHANGE_BEFORE_RUN!!!",
|
||||
"surface": 500.0,
|
||||
"surface": 500.50,
|
||||
"intervention": "CHANGE_BEFORE_RUN!!!"
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"eco_account": "CHANGE_BEFORE_RUN!!!",
|
||||
"surface": 523400.0,
|
||||
"surface": 523400.50,
|
||||
"intervention": "CHANGE_BEFORE_RUN!!!"
|
||||
}
|
@ -118,8 +118,15 @@ class EcoAccount(AbstractCompensation, ShareableObjectMixin, RecordableObjectMix
|
||||
intervention__deleted=None,
|
||||
)
|
||||
deductions_surfaces = deductions.aggregate(Sum("surface"))["surface__sum"] or 0
|
||||
available_surfaces = self.deductable_surface or deductions_surfaces ## no division by zero
|
||||
ret_val = available_surfaces - deductions_surfaces
|
||||
|
||||
available_surface = self.deductable_surface
|
||||
if available_surface is None:
|
||||
# Fallback!
|
||||
available_surface = deductions_surfaces
|
||||
else:
|
||||
available_surface = float(available_surface)
|
||||
|
||||
ret_val = available_surface - deductions_surfaces
|
||||
|
||||
return ret_val
|
||||
|
||||
|
@ -188,7 +188,7 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
|
||||
# Prepare data for deduction creation
|
||||
deduct_url = reverse("compensation:acc:new-deduction", args=(self.eco_account.id,))
|
||||
test_surface = 10.00
|
||||
test_surface = 10.50
|
||||
post_data = {
|
||||
"surface": test_surface,
|
||||
"account": self.eco_account.id,
|
||||
@ -207,7 +207,7 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
# Make sure the deductible surface is valid for the request
|
||||
self.eco_account.set_recorded(self.superuser)
|
||||
self.eco_account.refresh_from_db()
|
||||
self.eco_account.deductable_surface = test_surface + 1.00
|
||||
self.eco_account.deductable_surface = test_surface + 1.0
|
||||
self.eco_account.save()
|
||||
self.assertIsNotNone(self.eco_account.recorded)
|
||||
self.assertGreater(self.eco_account.deductable_surface, test_surface)
|
||||
@ -244,7 +244,7 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
deduction = EcoAccountDeduction.objects.create(
|
||||
intervention=self.intervention,
|
||||
account=self.eco_account,
|
||||
surface=0
|
||||
surface=1.10
|
||||
)
|
||||
self.assertEqual(1, self.intervention.deductions.count())
|
||||
self.assertEqual(1, self.eco_account.deductions.count())
|
||||
|
@ -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
|
||||
|
@ -15,7 +15,7 @@ DEFAULT_SRID_RLP = 25832
|
||||
|
||||
# Needed to redirect to LANIS
|
||||
## Values to be inserted are [zoom_level, x_coord, y_coord]
|
||||
LANIS_LINK_TEMPLATE = "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/index.php?lang=de&zl={}&x={}&y={}&bl=tk_rlp_tms_grau&bo=1&lo=0.8,0.8,0.8,0.6,0.8,0.8,0.8,0.8,0.8&layers=eiv_f,eiv_l,eiv_p,kom_f,kom_l,kom_p,oek_f,ema_f,mae&service=kartendienste_naturschutz"
|
||||
LANIS_LINK_TEMPLATE = "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/index.php?lang=de&zl={}&x={}&y={}&bl=tk_rlp_tms_grau&bo=1&lo=0.8,0.8,0.8,0.6,0.8,0.8,0.8,0.8,0.8&layers=eiv_recorded,eiv_unrecorded,kom_recorded,kom_unrecorded,oek_recorded,oek_unrecorded,ema_recorded,ema_unrecorded,mae&service=kartendienste_naturschutz"
|
||||
## This look up table (LUT) defines different zoom levels on the size of the calculate area of a geometry.
|
||||
LANIS_ZOOM_LUT = {
|
||||
1000000000: 6,
|
||||
|
Loading…
Reference in New Issue
Block a user