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.
37 lines
1.7 KiB
Python
37 lines
1.7 KiB
Python
3 years ago
|
"""
|
||
|
Author: Michel Peltriaux
|
||
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||
|
Contact: michel.peltriaux@sgdnord.rlp.de
|
||
3 years ago
|
Created on: 24.01.22
|
||
3 years ago
|
|
||
|
"""
|
||
3 years ago
|
from api.utils.serializer.v1.serializer import AbstractModelAPISerializerV1
|
||
3 years ago
|
from compensation.models import EcoAccount
|
||
|
from intervention.models import Legal, Responsibility
|
||
|
|
||
|
|
||
3 years ago
|
class EcoAccountAPISerializerV1(AbstractModelAPISerializerV1):
|
||
3 years ago
|
model = EcoAccount
|
||
|
|
||
3 years ago
|
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())
|
||
3 years ago
|
|
||
|
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,
|
||
|
}
|