<?xml version="1.0" encoding="UTF-8"?>
<!--
    Document   : albaranescli.xml
    Author     : Carlos Garcia Gomez
    Description:
        Structure for the albaranescli table.
-->
<table>
    <column>
        <name>apartado</name>
        <type>character varying(10)</type>
    </column>
    <column>
        <name>cifnif</name>
        <type>character varying(30)</type>
        <null>NO</null>
    </column>
    <column>
        <name>ciudad</name>
        <type>character varying(100)</type>
    </column>
    <column>
        <name>codagente</name>
        <type>character varying(10)</type>
    </column>
    <column>
        <name>codalmacen</name>
        <type>character varying(4)</type>
    </column>
    <column>
        <name>codcliente</name>
        <type>character varying(10)</type>
    </column>
    <column>
        <name>coddivisa</name>
        <type>character varying(3)</type>
        <null>NO</null>
    </column>
    <column>
        <name>codejercicio</name>
        <type>character varying(4)</type>
        <null>NO</null>
    </column>
    <column>
        <name>codigo</name>
        <type>character varying(20)</type>
        <null>NO</null>
    </column>
    <column>
        <name>codigoenv</name>
        <type>character varying(200)</type>
    </column>
    <column>
        <name>codpago</name>
        <type>character varying(10)</type>
        <null>NO</null>
    </column>
    <column>
        <name>codpais</name>
        <type>character varying(20)</type>
    </column>
    <column>
        <name>codpostal</name>
        <type>character varying(10)</type>
    </column>
    <column>
        <name>codserie</name>
        <type>character varying(4)</type>
        <null>NO</null>
    </column>
    <column>
        <name>codtrans</name>
        <type>character varying(8)</type>
    </column>
    <column>
        <name>direccion</name>
        <type>character varying(200)</type>
    </column>
    <column>
        <name>dtopor1</name>
        <type>double precision</type>
    </column>
    <column>
        <name>dtopor2</name>
        <type>double precision</type>
    </column>
    <column>
        <name>editable</name>
        <type>boolean</type>
    </column>
    <column>
        <name>fecha</name>
        <type>date</type>
        <null>NO</null>
    </column>
    <column>
        <name>femail</name>
        <type>date</type>
    </column>
    <column>
        <name>hora</name>
        <type>time</type>
    </column>
    <column>
        <name>idalbaran</name>
        <type>serial</type>
        <null>NO</null>
    </column>
    <column>
        <name>idcontactoenv</name>
        <type>integer</type>
    </column>
    <column>
        <name>idcontactofact</name>
        <type>integer</type>
    </column>
    <column>
        <name>idempresa</name>
        <type>integer</type>
    </column>
    <column>
        <name>idestado</name>
        <type>integer</type>
    </column>
    <column>
        <name>idestado_ant</name>
        <type>integer</type>
    </column>
    <column>
        <name>irpf</name>
        <type>double precision</type>
    </column>
    <column>
        <name>neto</name>
        <type>double precision</type>
    </column>
    <column>
        <name>netosindto</name>
        <type>double precision</type>
        <default>0</default>
    </column>
    <column>
        <name>nick</name>
        <type>character varying(50)</type>
    </column>
    <column>
        <name>nombrecliente</name>
        <type>character varying(100)</type>
    </column>
    <column>
        <name>numdocs</name>
        <type>integer</type>
        <default>0</default>
    </column>
    <column>
        <name>numero</name>
        <type>character varying(12)</type>
        <null>NO</null>
    </column>
    <column>
        <name>numero2</name>
        <type>character varying(50)</type>
    </column>
    <column>
        <name>observaciones</name>
        <type>text</type>
    </column>
    <column>
        <name>operacion</name>
        <type>character varying(20)</type>
    </column>
    <column>
        <name>provincia</name>
        <type>character varying(100)</type>
    </column>
    <column>
        <name>tasaconv</name>
        <type>double precision</type>
    </column>
    <column>
        <name>total</name>
        <type>double precision</type>
    </column>
    <column>
        <name>totalbeneficio</name>
        <type>double precision</type>
    </column>
    <column>
        <name>totalcoste</name>
        <type>double precision</type>
    </column>
    <column>
        <name>totaleuros</name>
        <type>double precision</type>
    </column>
    <column>
        <name>totalirpf</name>
        <type>double precision</type>
    </column>
    <column>
        <name>totaliva</name>
        <type>double precision</type>
    </column>
    <column>
        <name>totalrecargo</name>
        <type>double precision</type>
    </column>
    <column>
        <name>totalsuplidos</name>
        <type>double precision</type>
        <default>0</default>
    </column>
    <constraint>
        <name>albaranescli_pkey</name>
        <type>PRIMARY KEY (idalbaran)</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_codagente</name>
        <type>FOREIGN KEY (codagente) REFERENCES agentes (codagente) ON DELETE SET NULL ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_codalmacen</name>
        <type>FOREIGN KEY (codalmacen) REFERENCES almacenes (codalmacen) ON DELETE RESTRICT ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_codcliente</name>
        <type>FOREIGN KEY (codcliente) REFERENCES clientes (codcliente) ON DELETE RESTRICT ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_coddivisa</name>
        <type>FOREIGN KEY (coddivisa) REFERENCES divisas (coddivisa) ON DELETE RESTRICT ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_codejercicio</name>
        <type>FOREIGN KEY (codejercicio) REFERENCES ejercicios (codejercicio) ON DELETE RESTRICT ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_codpago</name>
        <type>FOREIGN KEY (codpago) REFERENCES formaspago (codpago) ON DELETE RESTRICT ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_codseries</name>
        <type>FOREIGN KEY (codserie) REFERENCES series (codserie) ON DELETE RESTRICT ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_codtrans</name>
        <type>FOREIGN KEY (codtrans) REFERENCES agenciastrans (codtrans) ON DELETE SET NULL ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_idempresas</name>
        <type>FOREIGN KEY (idempresa) REFERENCES empresas (idempresa) ON DELETE CASCADE ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_idestados</name>
        <type>FOREIGN KEY (idestado) REFERENCES estados_documentos (idestado) ON DELETE RESTRICT ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_idestado_ant</name>
        <type>FOREIGN KEY (idestado_ant) REFERENCES estados_documentos (idestado) ON DELETE SET NULL ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_albaranescli_nick</name>
        <type>FOREIGN KEY (nick) REFERENCES users (nick) ON DELETE SET NULL ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>uniq_codigo_albaranescli</name>
        <type>UNIQUE (codigo,idempresa)</type>
    </constraint>
</table>