from djcopybook.fixedwidth import Record
from djcopybook.fixedwidth import fields


class AccountMoveLine(Record):
    codi_empr = fields.StringField(length=2)
    exercici = fields.StringField(length=4)
    data_assent = fields.DateField(length=8, format="%Y%m%d")
    data_doc = fields.DateField(length=8, format="%Y%m%d")
    document = fields.StringField(length=10)
    codi_cto = fields.StringField(length=2)
    descr_cto = fields.StringField(length=30)
    deure = fields.DecimalField(length=16, decimals=6)
    haver = fields.DecimalField(length=16, decimals=6)
    codi_compte = fields.StringField(length=12)
    diari = fields.StringField(length=2)
    num_provisional = fields.DecimalField(length=6, decimals=0)
    descr_compte = fields.StringField(length=30)
    domicili = fields.StringField(length=30)
    codipostal = fields.StringField(length=5)
    poblacio = fields.StringField(length=30)
    nif = fields.StringField(length=15)
    banc = fields.StringField(length=4)
    agencia = fields.StringField(length=4)
    compte_banc = fields.StringField(length=12)
    adr_agencia = fields.StringField(length=25)
    annex_iva = fields.StringField(length=2)
    serie_iva = fields.StringField(length=2)
    nom_prov = fields.StringField(length=30)
    nif_prov = fields.StringField(length=15)
    total_fra = fields.DecimalField(length=16, decimals=6)
    tipo_base1 = fields.StringField(length=1)
    base1 = fields.DecimalField(length=16, decimals=6)
    perc_iva1 = fields.DecimalField(length=5, decimals=2)
    perc_rec1 = fields.DecimalField(length=5, decimals=2)
    imp_iva1 = fields.DecimalField(length=16, decimals=6)
    imp_rec1 = fields.DecimalField(length=16, decimals=6)
    tipo_base2 = fields.StringField(length=1)
    base2 = fields.DecimalField(length=16, decimals=6)
    perc_iva2 = fields.DecimalField(length=5, decimals=2)
    perc_rec2 = fields.DecimalField(length=5, decimals=2)
    imp_iva2 = fields.DecimalField(length=16, decimals=6)
    imp_rec2 = fields.DecimalField(length=16, decimals=6)
    tipo_base3 = fields.StringField(length=1)
    base3 = fields.DecimalField(length=16, decimals=6)
    perc_iva3 = fields.DecimalField(length=5, decimals=2)
    perc_rec3 = fields.DecimalField(length=5, decimals=2)
    imp_iva3 = fields.DecimalField(length=16, decimals=6)
    imp_rec3 = fields.DecimalField(length=16, decimals=6)
    tipo_base4 = fields.StringField(length=1)
    base4 = fields.DecimalField(length=16, decimals=6)
    perc_iva4 = fields.DecimalField(length=5, decimals=2)
    perc_rec4 = fields.DecimalField(length=5, decimals=2)
    imp_iva4 = fields.DecimalField(length=16, decimals=6)
    imp_rec4 = fields.DecimalField(length=16, decimals=6)
    annex_cart = fields.StringField(length=2)
    banc_cart = fields.StringField(length=4)
    agencia_cart = fields.StringField(length=4)
    compte_cart = fields.StringField(length=12)
    descr_agen_cart = fields.StringField(length=25)
    dcp_codi = fields.StringField(length=2)
    cls_codi = fields.StringField(length=2)
    scp_codi = fields.StringField(length=2)
    data_venc1 = fields.DateField(length=8, format="%Y%m%d")
    import_venc1 = fields.DecimalField(length=16, decimals=6)
    data_venc2 = fields.DateField(length=8, format="%Y%m%d")
    import_venc2 = fields.DecimalField(length=16, decimals=6)
    data_venc3 = fields.DateField(length=8, format="%Y%m%d")
    import_venc3 = fields.DecimalField(length=16, decimals=6)
    data_venc4 = fields.DateField(length=8, format="%Y%m%d")
    import_venc4 = fields.DecimalField(length=16, decimals=6)
    data_venc5 = fields.DateField(length=8, format="%Y%m%d")
    import_venc5 = fields.DecimalField(length=16, decimals=6)
    data_venc6 = fields.DateField(length=8, format="%Y%m%d")
    import_venc6 = fields.DecimalField(length=16, decimals=6)
    cta_prv_iva = fields.StringField(length=12)
    divisa = fields.StringField(length=3)
    cambio = fields.DecimalField(length=12, decimals=6)
    centro = fields.StringField(length=6)
    divimportedebe = fields.DecimalField(length=16, decimals=6)
    divimportehaber = fields.DecimalField(length=16, decimals=6)
    divimporteven1 = fields.DecimalField(length=16, decimals=6)
    divimporteven2 = fields.DecimalField(length=16, decimals=6)
    divimporteven3 = fields.DecimalField(length=16, decimals=6)
    divimporteven4 = fields.DecimalField(length=16, decimals=6)
    divimporteven5 = fields.DecimalField(length=16, decimals=6)
    divimporteven6 = fields.DecimalField(length=16, decimals=6)
    codigodivisacliente = fields.StringField(length=3)
    descripciondivisacliente = fields.StringField(length=25)
    abreviaciondivisacliente = fields.StringField(length=3)
    dpdivisacliente = fields.IntegerField(length=1)
    didivisacliente = fields.IntegerField(length=1)
    cotizaciondivisacliente = fields.DecimalField(length=12, decimals=6)
    codigopaiscliente = fields.StringField(length=3)
    nombrepaiscliente = fields.StringField(length=30)
    rivapaiscliente = fields.IntegerField(length=1)
    intrastatpaiscliente = fields.StringField(length=3)
    agentecliente = fields.StringField(length=3)
    provinciacliente = fields.StringField(length=35)
    tipodocs = fields.StringField(length=12)
    negociablesdocs = fields.StringField(length=12)
    data_venc7 = fields.DateField(length=8, format="%Y%m%d")
    data_venc8 = fields.DateField(length=8, format="%Y%m%d")
    data_venc9 = fields.DateField(length=8, format="%Y%m%d")
    data_venc10 = fields.DateField(length=8, format="%Y%m%d")
    data_venc11 = fields.DateField(length=8, format="%Y%m%d")
    data_venc12 = fields.DateField(length=8, format="%Y%m%d")
    import_venc7 = fields.DecimalField(length=16, decimals=6)
    import_venc8 = fields.DecimalField(length=16, decimals=6)
    import_venc9 = fields.DecimalField(length=16, decimals=6)
    import_venc10 = fields.DecimalField(length=16, decimals=6)
    import_venc11 = fields.DecimalField(length=16, decimals=6)
    import_venc12 = fields.DecimalField(length=16, decimals=6)
    divimporteven7 = fields.DecimalField(length=16, decimals=6)
    divimporteven8 = fields.DecimalField(length=16, decimals=6)
    divimporteven9 = fields.DecimalField(length=16, decimals=6)
    divimporteven10 = fields.DecimalField(length=16, decimals=6)
    divimporteven11 = fields.DecimalField(length=16, decimals=6)
    divimporteven12 = fields.DecimalField(length=16, decimals=6)
    negociablesdocs2 = fields.StringField(length=12)
    tipodocs2 = fields.StringField(length=12)
    cobrador = fields.StringField(length=3)
    cobnom = fields.StringField(length=35)
    responsable = fields.StringField(length=10)
    respnom = fields.StringField(length=30)
    formapago = fields.StringField(length=3)
    diapago1 = fields.DecimalField(length=2, decimals=0)
    diapago2 = fields.DecimalField(length=2, decimals=0)
    diapago3 = fields.DecimalField(length=2, decimals=0)
    centrecodi1 = fields.StringField(length=16)
    centretext1 = fields.StringField(length=35)
    centrecodi2 = fields.StringField(length=16)
    centretext2 = fields.StringField(length=35)
    centrecodi3 = fields.StringField(length=16)
    centretext3 = fields.StringField(length=35)
    centrecodi4 = fields.StringField(length=16)
    centretext4 = fields.StringField(length=35)
    centrecodi5 = fields.StringField(length=35)
    centretext5 = fields.StringField(length=35)
    seriefra = fields.StringField(length=2)
    dia_nom = fields.StringField(length=40)
    cobobserva = fields.StringField(length=200)
    criteriocoste = fields.StringField(length=6)
    rupturaccoste = fields.StringField(length=6)
    nifampliado = fields.StringField(length=15)
    documentoampliado = fields.StringField(length=25)
    iban = fields.StringField(length=34)
    swift = fields.StringField(length=11)
    esp_tipoapunte = fields.StringField(length=10)
    tiqueini = fields.StringField(length=20)
    tiquefin = fields.StringField(length=20)
    localizador = fields.StringField(length=25)
    compraregivafinanigualnumfactprov = fields.StringField(length=1)
    compranumfactregivafinanigualnumfactprov = fields.StringField(length=1)
    compranumfactcartpagfinanigualnumfactprov = fields.StringField(length=1)
    compranumfactprov = fields.StringField(length=20)
    tipoidentdoc = fields.StringField(length=2)


if __name__ == '__main__':
    from datetime import date
    m = AccountMoveLine(
        data_assent = date(2018, 5, 28),
        data_doc=date(2018, 5, 27),
        document="F43453543",
        codi_cto="01",
        descr_cto="P1",
        deure=200.43,
        haver=0,
        codi_compte="70000004",
        diari="01",
        num_provisional=4353,
        descr_compte="Vendes energia"
    )
    print(m.to_record())