Change numeric fields to text to match Facturador Sunat json format

This commit is contained in:
Enrique Barcelli 2021-12-04 21:12:16 +08:00
parent 81f3f6d5d8
commit 92b1d1e890

View file

@ -70,16 +70,16 @@ select
'horEmision',dateinvoiced::time, 'horEmision',dateinvoiced::time,
'codLocalEmisor','0001', 'codLocalEmisor','0001',
'tipDocUsuario','6', 'tipDocUsuario','6',
'numDocUsuario',ruc, 'numDocUsuario',taxid,
'rznSocialUsuario',parentorg, 'rznSocialUsuario',bpname,
'tipMoneda',iso_code, 'tipMoneda',iso_code,
'sumTotTributos',grandtotal-totallines, 'sumTotTributos',(grandtotal-totallines)::varchar,
'sumTotValVenta',totallines, 'sumTotValVenta',totallines::varchar,
'sumPrecioVenta',grandtotal, 'sumPrecioVenta',grandtotal::varchar,
'sumDescTotal','0.00', 'sumDescTotal','0.00',
'sumOtrosCargos','0.00', 'sumOtrosCargos','0.00',
'sumTotalAnticipos','0.00', 'sumTotalAnticipos','0.00',
'sumImpVenta',grandtotal, 'sumImpVenta',grandtotal::varchar,
'ublVersionId','2.1', 'ublVersionId','2.1',
'customizationId','2.0' 'customizationId','2.0'
) )
@ -105,16 +105,16 @@ select
jsonb_build_object( jsonb_build_object(
'invoiceline',c_invoiceline_id, 'invoiceline',c_invoiceline_id,
'codUnidadMedida','BX', 'codUnidadMedida','BX',
'ctdUnidadItem',qtyinvoiced, 'ctdUnidadItem',qtyinvoiced::varchar,
'codProducto',productcode, 'codProducto',productcode,
'codProductoSUNAT','50161813', 'codProductoSUNAT','50161813',
'desItem',productname, 'desItem',productname,
'mtoValorUnitario',priceactual, 'mtoValorUnitario',priceactual::varchar,
'sumTotTributosItem',linetaxtaxamt, 'sumTotTributosItem',linetaxtaxamt::varchar,
'codTriIGV','1000', 'codTriIGV','1000',
'mtoIgvItem',linetaxtaxamt, 'mtoIgvItem',linetaxtaxamt::varchar,
'mtoBaseIgvItem',linetaxbaseamt, 'mtoBaseIgvItem',linetaxbaseamt::varchar,
'nomTributoIgvItem','IGV', 'nomTributoIgvItem','IGV',
'codTipTributoIgvItem','VAT', 'codTipTributoIgvItem','VAT',
'tipAfeIGV','10', 'tipAfeIGV','10',
@ -142,8 +142,8 @@ select
'codTipTributoIcbperItem','OTH', 'codTipTributoIcbperItem','OTH',
'mtoTriIcbperUnidad','0.30', 'mtoTriIcbperUnidad','0.30',
'mtoPrecioVentaUnitario',round((linenetamt+linetaxtaxamt)/qtyinvoiced,2), 'mtoPrecioVentaUnitario',round((linenetamt+linetaxtaxamt)/qtyinvoiced,2)::varchar,
'mtoValorVentaItem',linenetamt, 'mtoValorVentaItem',linenetamt::varchar,
'mtoValorReferencialUnitario','0.00' 'mtoValorReferencialUnitario','0.00'
) )
) )
@ -159,8 +159,8 @@ select
'ideTributo','1000', 'ideTributo','1000',
'nomTributo','IGV', 'nomTributo','IGV',
'codTipTributo','VAT', 'codTipTributo','VAT',
'mtoBaseImponible',invoicetaxbaseamt, 'mtoBaseImponible',invoicetaxbaseamt::varchar,
'mtoTributo',invoicetaxtaxamt 'mtoTributo',invoicetaxtaxamt::varchar
) )
) )
) )
@ -186,7 +186,7 @@ select
'datoPago', jsonb_agg(DISTINCT 'datoPago', jsonb_agg(DISTINCT
jsonb_build_object( jsonb_build_object(
'formaPago','Credito', 'formaPago','Credito',
'mtoNetoPendientePago',grandtotal, 'mtoNetoPendientePago',grandtotal::varchar,
'tipMonedaMtoNetoPendientePago',iso_code 'tipMonedaMtoNetoPendientePago',iso_code
) )
) )
@ -196,7 +196,7 @@ select
'detallePago', jsonb_agg(DISTINCT 'detallePago', jsonb_agg(DISTINCT
jsonb_build_object( jsonb_build_object(
'cuotaid',fin_payment_schedule_id, 'cuotaid',fin_payment_schedule_id,
'mtoCuotaPago',cuota, 'mtoCuotaPago',cuota::varchar,
'fecCuotaPago',duedate::date, 'fecCuotaPago',duedate::date,
'tipMonedaCuotaPago',iso_code 'tipMonedaCuotaPago',iso_code
) )
@ -206,7 +206,7 @@ select
jsonb_build_object( jsonb_build_object(
'retencion', jsonb_agg(DISTINCT 'retencion', jsonb_agg(DISTINCT
jsonb_build_object( jsonb_build_object(
'impOperacion',grandtotal, 'impOperacion',grandtotal::varchar,
'porRetencion','0.00', 'porRetencion','0.00',
'impRetencion','0.00' 'impRetencion','0.00'
) )