Eco Accounts

* adds related eco account withdraw detail view to intervention detail view
* adds new route for removing withdraws using RemoveModalForm
* adds EcoAccountWithdraw model
* adds admin interfaces for EcoAccount and EcoAccountWithdraw
* adds message_templates.py to konova/utils for reusable messages
* splits related-documents.html and related-objects.html into separate templates for each related object type: compensations.html, documents.html, eco-account-withdraws.html and payments.html
* adds translations
This commit is contained in:
mipel
2021-08-02 10:14:34 +02:00
parent 52600c9a16
commit 6a650d2021
16 changed files with 412 additions and 209 deletions
+38 -1
View File
@@ -7,7 +7,7 @@ Created on: 17.11.20
"""
from django.contrib.auth.models import User
from django.contrib.gis.db import models
from django.core.validators import MinValueValidator
from django.core.validators import MinValueValidator, MaxValueValidator
from django.utils import timezone
from django.utils.timezone import now
@@ -152,3 +152,40 @@ class EcoAccount(Compensation):
"""
# Users having access on this object
users = models.ManyToManyField(User)
def __str__(self):
return "{}".format(self.identifier)
class EcoAccountWithdraw(BaseResource):
"""
A withdraw object for eco accounts
"""
account = models.ForeignKey(
EcoAccount,
on_delete=models.SET_NULL,
null=True,
blank=True,
help_text="Withdrawn from",
related_name="eco_withdraws",
)
amount = models.FloatField(
null=True,
blank=True,
help_text="Amount withdrawn (percentage)",
validators=[
MinValueValidator(limit_value=0.00),
MaxValueValidator(limit_value=100),
]
)
intervention = models.ForeignKey(
Intervention,
on_delete=models.CASCADE,
null=True,
blank=True,
help_text="Withdrawn for",
related_name="eco_withdraws",
)
def __str__(self):
return "{} of {}".format(self.amount, self.account)