Add lines settings
This commit is contained in:
parent
fa21d1f17a
commit
c825f52bcb
|
@ -8,6 +8,7 @@ ventas as (
|
||||||
select division.name as organisation,parent.name as parentorg,ad_orginfo.taxid as ruc,
|
select division.name as organisation,parent.name as parentorg,ad_orginfo.taxid as ruc,
|
||||||
ad_client.name,documentno,c_invoice.description,dateinvoiced,totallines,grandtotal,qtyinvoiced,priceactual,
|
ad_client.name,documentno,c_invoice.description,dateinvoiced,totallines,grandtotal,qtyinvoiced,priceactual,
|
||||||
linenetamt,c_invoiceline.taxbaseamt,m_product.value,m_product.name,iso_code,
|
linenetamt,c_invoiceline.taxbaseamt,m_product.value,m_product.name,iso_code,
|
||||||
|
c_invoiceline.line,c_invoice.c_invoice_id,c_invoiceline.c_invoiceline_id,
|
||||||
c_bpartner.name,c_bpartner.taxid,c_uom.name as uom,c_doctype.name,
|
c_bpartner.name,c_bpartner.taxid,c_uom.name as uom,c_doctype.name,
|
||||||
c_paymentterm.name as paymentterm,c_paymentterm.netdays,
|
c_paymentterm.name as paymentterm,c_paymentterm.netdays,
|
||||||
c_invoice.isactive,c_invoice.issotrx,
|
c_invoice.isactive,c_invoice.issotrx,
|
||||||
|
@ -54,6 +55,7 @@ select
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
'cabecera', json_agg(DISTINCT
|
'cabecera', json_agg(DISTINCT
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
|
'ivoiceid',c_invoice_id,
|
||||||
'tipoOperacion','0101',
|
'tipoOperacion','0101',
|
||||||
'fecEmision',date(dateinvoiced),
|
'fecEmision',date(dateinvoiced),
|
||||||
'horEmision',dateinvoiced::time,
|
'horEmision',dateinvoiced::time,
|
||||||
|
@ -76,7 +78,72 @@ select
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
'encabezado', jsonb_agg(
|
'adicionalCabecera', json_agg(DISTINCT
|
||||||
|
jsonb_build_object(
|
||||||
|
'invoiceid',c_invoice_id,
|
||||||
|
'codPaisCliente','PE',
|
||||||
|
'codUbigeoCliente','150140',
|
||||||
|
'desDireccionCliente','AV. ANGAMOS 1111, SURCO, LIMA',
|
||||||
|
'codPaisEntrega','PE',
|
||||||
|
'codUbigeoEntrega','150140',
|
||||||
|
'desDireccionEntrega','AV. ANGAMOS 1111, SURCO, LIMA'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
||
|
||||||
|
jsonb_build_object(
|
||||||
|
'detalle', json_agg(DISTINCT
|
||||||
|
jsonb_build_object(
|
||||||
|
'invoiceline',c_invoiceline_id,
|
||||||
|
'codUnidadMedida','BX',
|
||||||
|
'ctdUnidadItem','5.00',
|
||||||
|
'codProducto','10001',
|
||||||
|
'codProductoSUNAT','50161813',
|
||||||
|
'desItem','PRODUCTO 1',
|
||||||
|
'mtoValorUnitario','10.00',
|
||||||
|
'sumTotTributosItem','9.00',
|
||||||
|
|
||||||
|
'codTriIGV','1000',
|
||||||
|
'mtoIgvItem','9.00',
|
||||||
|
'mtoBaseIgvItem','50.00',
|
||||||
|
'nomTributoIgvItem','IGV',
|
||||||
|
'codTipTributoIgvItem','VAT',
|
||||||
|
'tipAfeIGV','10',
|
||||||
|
'porIgvItem','18.00',
|
||||||
|
|
||||||
|
'codTriISC','2000',
|
||||||
|
'mtoIscItem','0.00',
|
||||||
|
'mtoBaseIscItem','0.00',
|
||||||
|
'nomTributoIscItem','ISC',
|
||||||
|
'codTipTributoIscItem','EXC',
|
||||||
|
'tipSisISC','02',
|
||||||
|
'porIscItem','0.00',
|
||||||
|
|
||||||
|
'codTriOtro','9999',
|
||||||
|
'mtoTriOtroItem','0.00',
|
||||||
|
'mtoBaseTriOtroItem','0.00',
|
||||||
|
'nomTributoOtroItem','OTROS',
|
||||||
|
'codTipTributoOtroItem','OTH',
|
||||||
|
'porTriOtroItem','0.00',
|
||||||
|
|
||||||
|
'codTriIcbper','7152',
|
||||||
|
'mtoTriIcbperItem','0.00',
|
||||||
|
'ctdBolsasTriIcbperItem','0',
|
||||||
|
'nomTributoIcbperItem','ICBPER',
|
||||||
|
'codTipTributoIcbperItem','OTH',
|
||||||
|
'mtoTriIcbperUnidad','0.30',
|
||||||
|
|
||||||
|
'mtoPrecioVentaUnitario','11.80',
|
||||||
|
'mtoValorVentaItem','50.00',
|
||||||
|
'mtoValorReferencialUnitario','0.00'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
||
|
||||||
|
jsonb_build_object(
|
||||||
|
'encabezado', jsonb_agg(
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
'factura',ventas.documentno,
|
'factura',ventas.documentno,
|
||||||
'terminopago',ventas.paymentterm,
|
'terminopago',ventas.paymentterm,
|
||||||
|
@ -84,7 +151,7 @@ select
|
||||||
'parent',ventas.parentorg
|
'parent',ventas.parentorg
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
'lineas', jsonb_agg(
|
'lineas', jsonb_agg(
|
||||||
|
|
Loading…
Reference in a new issue