# Path: netvisor/schemas/common.py
# class DateSchema(FlattenElementSchema):
#     text = fields.Date(load_from='#text')
# 
# class DecimalSchema(FlattenElementSchema):
#     text = Decimal(load_from='#text')
# 
# class StringSchema(FlattenElementSchema):
#     text = fields.String(load_from='#text')
# 
# Path: netvisor/schemas/fields.py
# class Boolean(fields.Boolean):
#     def __init__(self, true, false, **kwargs):
#         super(Boolean, self).__init__(**kwargs)
#         self.truthy = [true]
#         self.falsy = [false]
# 
#     def _serialize(self, value, attr, obj):
#         if value:
#             return self.truthy[0]
#         else:
#             return self.falsy[0]
# 
# class Decimal(fields.Decimal):
#     def _deserialize(self, value, attr, data):
#         return super(Decimal, self)._deserialize(
#             value.replace(',', '.'),
#             attr,
#             data
#         )
# 
#     def serialize(self, attr, obj, accessor=None):
#         value = super(Decimal, self).serialize(attr, obj, accessor)
#         if value is missing:
#             return value
#         return str(value).replace('.', ',')
# 
# class List(fields.List):
#     def _deserialize(self, value, attr, data):
#         if not is_collection(value) and value is not None:
#             value = [value]
#         return super(List, self)._deserialize(value, attr, data)


from marshmallow import Schema, fields, post_load
from ..common import DateSchema, DecimalSchema, StringSchema
from ..fields import Boolean, Decimal, List
    def preprocess_invoice_lines(self, input_data):
        if input_data:
            return input_data['invoice_line']


class GetSalesInvoiceSchema(Schema):
    number = fields.Integer(
        required=True,
        load_from='sales_invoice_number'
    )
    date = fields.Nested(
        DateSchema,
        required=True,
        load_from='sales_invoice_date'
    )
    delivery_date = fields.Nested(
        DateSchema,
        required=True,
        load_from='sales_invoice_delivery_date'
    )
    due_date = fields.Nested(
        DateSchema,
        required=True,
        load_from='sales_invoice_due_date'
    )
    reference_number = fields.String(
        required=True,
        load_from='sales_invoice_referencenumber'
    )
    amount = fields.Nested(

# Path: netvisor/schemas/common.py
# class DateSchema(FlattenElementSchema):
#     text = fields.Date(load_from='#text')
# 
# class DecimalSchema(FlattenElementSchema):
#     text = Decimal(load_from='#text')
# 
# class StringSchema(FlattenElementSchema):
#     text = fields.String(load_from='#text')
# 
# Path: netvisor/schemas/fields.py
# class Boolean(fields.Boolean):
#     def __init__(self, true, false, **kwargs):
#         super(Boolean, self).__init__(**kwargs)
#         self.truthy = [true]
#         self.falsy = [false]
# 
#     def _serialize(self, value, attr, obj):
#         if value:
#             return self.truthy[0]
#         else:
#             return self.falsy[0]
# 
# class Decimal(fields.Decimal):
#     def _deserialize(self, value, attr, data):
#         return super(Decimal, self)._deserialize(
#             value.replace(',', '.'),
#             attr,
#             data
#         )
# 
#     def serialize(self, attr, obj, accessor=None):
#         value = super(Decimal, self).serialize(attr, obj, accessor)
#         if value is missing:
#             return value
#         return str(value).replace('.', ',')
# 
# class List(fields.List):
#     def _deserialize(self, value, attr, data):
#         if not is_collection(value) and value is not None:
#             value = [value]
#         return super(List, self)._deserialize(value, attr, data)


# Path: netvisor/schemas/sales_invoices/get.py
from marshmallow import Schema, fields, post_load
from ..common import DateSchema, DecimalSchema, StringSchema
from ..fields import Boolean, Decimal, List

    def preprocess_invoice_lines(self, input_data):
        if input_data:
            return input_data['invoice_line']


class GetSalesInvoiceSchema(Schema):
    number = fields.Integer(
        required=True,
        load_from='sales_invoice_number'
    )
    date = fields.Nested(
        DateSchema,
        required=True,
        load_from='sales_invoice_date'
    )
    delivery_date = fields.Nested(
        DateSchema,
        required=True,
        load_from='sales_invoice_delivery_date'
    )
    due_date = fields.Nested(
        DateSchema,
        required=True,
        load_from='sales_invoice_due_date'
    )
    reference_number = fields.String(
        required=True,
        load_from='sales_invoice_referencenumber'
    )
    amount = fields.Nested(

        DecimalSchema(),