class SharedGroupSerializer(EmbeddedDocumentSerializer): user = BDynamicField() access = ListField(child=CharField()) is_owner = BooleanField(default=False) class Meta: model = SharedGroup fields = '__all__'
class ViewQuerySerializer(EmbeddedDocumentSerializer): column = CharField() operator = CharField() value = BDynamicField() logical_operator = CharField() class Meta: model = ViewQuery fields = '__all__'
class BillingDocumentSerializer(DocumentSerializer): beneficiary = BDynamicField(required=True) comment = CharField(required=False, allow_null=True) doc_date = BDateField() attached_files = BEmbeddedListField(serializer=AttachedFileSerializer, allow_null=True, required=False) states = DocumentStateSerializer(required=False, allow_null=True) class Meta: model = BillingDocument fields = ['id', 'number', 'beneficiary', 'comment', 'doc_date', 'attached_files', 'states']
class PaymentLineSerializer(EmbeddedDocumentSerializer): total_amount = FloatField(required=False) encasement_amount = FloatField(required=False) paid_doc = BDynamicField(allow_null=True, required=False) class Meta: model = PaymentLine fields = [ 'encasement_amount', 'paid_doc', 'total_amount', 'remaining_amount' ]
class InvoiceLineSerializer(EmbeddedDocumentSerializer): details = BEmbeddedListField(serializer=DetailLineSerializer, allow_null=True, required=False) description = CharField() is_comment = BooleanField(default=False) line_doc = BDynamicField(allow_null=True, required=False) class Meta: model = InvoiceLine fields = ['details', 'description', 'is_comment', 'line_doc']
class DetailLineSerializer(EmbeddedDocumentSerializer): code = CharField(required=False) description = CharField(required=True) discount = FloatField(default=0) unit_price = FloatField(default=0) qte = FloatField(default=0) tariff = TariffSerializer(required=False, allow_null=True) line_doc = BDynamicField() is_comment = BooleanField(default=False) total_amount = FloatField(read_only=True) discount_amount = FloatField(read_only=True) class Meta: model = DetailLine fields = [ 'code', 'description', 'discount', 'unit_price', 'qte', 'tariff', 'line_doc', 'is_comment', 'total_amount', 'discount_amount' ]
class PaymentSerializer(BillingDocumentSerializer): beneficiary_type = CharField(allow_blank=True, allow_null=True) deadline = BDateField(allow_null=True, required=False) payer = BDynamicField(allow_null=True, required=False) payer_type = CharField(allow_blank=True, allow_null=True) received_amount = FloatField(default=0) payment_mode = PaymentModeSerializer(allow_null=True, required=False) lines = BEmbeddedListField(serializer=PaymentLineSerializer, allow_null=True, required=False) consumed_amount = FloatField(read_only=True) remaining_amount = FloatField(read_only=True) payer_name = CharField(read_only=True) beneficiary_name = CharField(read_only=True) class Meta: model = Payment fields = BillingDocumentSerializer.Meta.fields + [ 'beneficiary_type', 'deadline', 'payer', 'payer_type', 'received_amount', 'payment_mode', 'consumed_amount', 'remaining_amount', 'payer_name', 'beneficiary_name', 'lines' ]