You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
konova/api/utils/serializer/v1/ecoaccount.py

37 lines
1.7 KiB
Python

"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 24.01.22
"""
from api.utils.serializer.v1.serializer import AbstractModelAPISerializerV1
from compensation.models import EcoAccount
from intervention.models import Legal, Responsibility
class EcoAccountAPISerializerV1(AbstractModelAPISerializerV1):
model = EcoAccount
def extend_properties_data(self, entry):
self.properties_data["deductable_surface"] = entry.deductable_surface
self.properties_data["deductable_surface_available"] = entry.deductable_surface - entry.get_deductions_surface()
self.properties_data["responsible"] = self.responsible_to_json(entry.responsible)
self.properties_data["legal"] = self.legal_to_json(entry.legal)
self.properties_data["before_states"] = self.compensation_state_to_json(entry.before_states.all())
self.properties_data["after_states"] = self.compensation_state_to_json(entry.after_states.all())
self.properties_data["actions"] = self.compensation_actions_to_json(entry.actions.all())
self.properties_data["deadlines"] = self.deadlines_to_json(entry.deadlines.all())
self.properties_data["deductions"] = self.deductions_to_json(entry.deductions.all())
def legal_to_json(self, legal: Legal):
return {
"agreement_date": legal.registration_date,
}
def responsible_to_json(self, responsible: Responsibility):
return {
"conservation_office": self.konova_code_to_json(responsible.conservation_office),
"conservation_file_number": responsible.conservation_file_number,
"handler": responsible.handler,
}