modificaciones facturacion electronica

This commit is contained in:
Luis
2026-10-15 16:07:57 -04:00
parent 07649704b1
commit ba982b7635
158 changed files with 206301 additions and 27838 deletions
+1
View File
@@ -39,6 +39,7 @@
<ToolBar name="ToolBar1">
<ToolBarItem comment="Nueva Factura" image="new" name="nuevo" text="Factura"/>
<ToolBarItem comment="Criterio de busqueda" image="find" name="buscar" text="Buscar Factura"/>
<ToolBarItem comment="Compra electronica e-CF 41" image="new" name="compra_e41" text="Compra Electronica"/>
<ToolBarSeparator name="ToolBarSeparator1"/>
<ToolBarItem image="quit" name="salir" text="Salir"/>
</ToolBar>
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ManagedForm databaseName="decomarmol" fileVersion="31400" gstVersion="31409" name="ManagedForm" uid="{08a7c711-2d89-468e-b9f4-764799aa743d}">
<AGSettings>
<DynamicProperties version="2"/>
</AGSettings>
<Record additionalTables="" joinLeft="" joinOperator="" joinRight="" name="factura1" order="" uid="{39fb09f4-aef4-4621-aa87-ee1bf1d6ed74}" where="">
<RecordField colName="tipo" fieldIdRef="13" name="tipo" sqlTabName="formonly" sqlType="CHAR" table_alias_name="" uid="{8675d671-5ba1-4fcc-af87-4f9189474f5d}"/>
<RecordField colName="aplica_a" fieldIdRef="14" fieldType="TABLE_COLUMN" name="cptb00001.aplica_a" sqlTabName="cptb00001" sqlType="VARCHAR" table_alias_name="" uid="{01a0fe69-f7be-4b2b-99f8-1244037bf182}"/>
<RecordField colName="tipo_doc" fieldIdRef="15" fieldType="TABLE_COLUMN" name="cptb00001.tipo_doc" sqlTabName="cptb00001" sqlType="VARCHAR" table_alias_name="" uid="{03c73aae-e409-46c6-8c8c-daf00568d214}"/>
<RecordField colName="valor_prep" fieldIdRef="16" name="valor_prep" precisionDecimal="12" scaleDecimal="2" sqlTabName="formonly" sqlType="DECIMAL" table_alias_name="" uid="{16fc3f19-4a17-4f98-b65d-f99680ffd4bf}"/>
<RecordField colName="valor" fieldIdRef="17" fieldType="TABLE_COLUMN" name="cptb00001.valor" precisionDecimal="12" scaleDecimal="2" sqlTabName="cptb00001" sqlType="DECIMAL" table_alias_name="" uid="{31d5ca07-01cf-4ff6-9bae-ab6910c7769b}"/>
</Record>
<Record additionalTables="" joinLeft="" joinOperator="" joinRight="" name="Undefined" order="" uid="{be8d9ace-199a-422a-9989-91b037c8ff0e}" where="">
<RecordField colName="cod_sp" fieldIdRef="1" fieldType="TABLE_COLUMN" name="cptb00001.cod_sp" sqlTabName="cptb00001" sqlType="SMALLINT" table_alias_name="" uid="{79a32a91-c552-4836-8435-fa6b75aa5b92}"/>
<RecordField colName="cod_sp_sec" fieldIdRef="2" fieldType="TABLE_COLUMN" name="cptb00001.cod_sp_sec" sqlTabName="cptb00001" sqlType="SMALLINT" table_alias_name="" uid="{361cc52e-b268-44b0-812a-9a3e3011d41b}"/>
<RecordField colName="nom_sup" fieldIdRef="4" name="nom_sup" sqlTabName="formonly" table_alias_name="" uid="{faf29dec-beb5-4516-a229-a3a50f87957e}"/>
<RecordField colName="" fieldIdRef="3" fieldType="NON_DATABASE" length="13" name="num_doc" sqlTabName="" sqlType="VARCHAR" table_alias_name="" uid="{3d7ad781-ff93-4144-9169-0987a16c434d}"/>
<RecordField colName="fecha_orig" fieldIdRef="5" fieldType="TABLE_COLUMN" name="cptb00001.fecha_orig" sqlTabName="cptb00001" sqlType="DATE" table_alias_name="" uid="{1f5322d6-4718-4e8e-b1de-3dde7a102352}"/>
<RecordField colName="fecha_proc" fieldIdRef="6" fieldType="TABLE_COLUMN" name="cptb00001.fecha_proc" sqlTabName="cptb00001" sqlType="DATE" table_alias_name="" uid="{951b8bf4-22ce-4564-a80c-9439ea8d326f}"/>
<RecordField colName="valor_fac" fieldIdRef="7" name="valor_fac" precisionDecimal="12" scaleDecimal="2" sqlTabName="formonly" sqlType="DECIMAL" table_alias_name="" uid="{bbefcfee-d8fa-4421-b7dc-2bcfa42617a4}"/>
<RecordField colName="tipo_oc" fieldIdRef="19" name="tipo_oc" sqlTabName="formonly" sqlType="CHAR" table_alias_name="" uid="{72940478-4ff5-4e79-b96f-60ece0cdef69}"/>
<RecordField colName="orden_no" fieldIdRef="18" fieldType="TABLE_COLUMN" name="cptb00001.orden_no" sqlTabName="cptb00001" sqlType="INTEGER" table_alias_name="" uid="{d9b891d8-43da-453e-8e43-c55e6fff570d}"/>
<RecordField colName="itbis" fieldIdRef="8" name="itbis" precisionDecimal="12" scaleDecimal="2" sqlTabName="formonly" sqlType="DECIMAL" table_alias_name="" uid="{c3ccfaab-a860-49ac-bc15-f902384bccf9}"/>
<RecordField colName="detalle" fieldIdRef="12" fieldType="TABLE_COLUMN" name="cptb00001.detalle" sqlTabName="cptb00001" sqlType="VARCHAR" table_alias_name="" uid="{cb8f2ac7-c863-4663-8645-1a3c14da423a}"/>
<RecordField colName="cod_mon" fieldIdRef="0" name="cod_mon" sqlTabName="formonly" table_alias_name="" uid="{e201c547-e9a9-4447-a2b6-5336972a736f}"/>
<RecordField colName="tipo_ncf" fieldIdRef="9" name="tipo_ncf" sqlTabName="formonly" sqlType="SMALLINT" table_alias_name="" uid="{7c0d2f39-0664-452a-9e23-175a20225bf2}"/>
<RecordField colName="descripcion_ncf" fieldIdRef="10" name="descripcion_ncf" sqlTabName="formonly" table_alias_name="" uid="{c192ad61-595a-49e3-b4db-37ac01b2076e}"/>
<RecordField colName="ncf" fieldIdRef="11" name="ncf" sqlTabName="formonly" table_alias_name="" uid="{3bc49d1f-3069-4cad-893f-803b24a5732e}"/>
<RecordField colName="debito1" fieldIdRef="20" name="debito1" sqlTabName="formonly" table_alias_name="" uid="{a55476d1-a505-4e40-8fa1-fbd539b5910d}"/>
<RecordField colName="credito1" fieldIdRef="21" name="credito1" sqlTabName="formonly" table_alias_name="" uid="{690f5cdc-bcd0-4086-a526-7048a86989c8}"/>
<RecordField colName="" fieldIdRef="22" name="monto_orden" sqlTabName="" table_alias_name="" uid="{8b0b15c8-64f2-46e5-a932-cbdb1f84e950}"/>
<RecordField colName="" fieldIdRef="23" name="valor_recibido_b" sqlTabName="" table_alias_name="" uid="{c228bb73-0d1b-485b-8854-930629c3e3bf}"/>
<RecordField colName="" fieldIdRef="24" name="xservicios" sqlTabName="" table_alias_name="" uid="{e4605002-65a8-49f0-80df-8ef3a06868fd}"/>
<RecordField colName="" fieldIdRef="25" name="xbienes" sqlTabName="" table_alias_name="" uid="{afba16a3-e96a-4cff-9876-5d1be636b223}"/>
<RecordField colName="foto_producto" fieldIdRef="26" name="foto" sqlTabName="formonly" table_alias_name="" uid="{cdf6e75e-eeb1-4e1c-933e-abdbc744cee4}"/>
<RecordField fieldIdRef="27" name="nombre_file_foto" uid="{86cfd7e8-06aa-4431-9041-d8146403a7a5}"/>
</Record>
<Form gridHeight="27" gridWidth="121" name="cpfmmt001" style="basic" text="CREACION FACTURAS CUENTAS POR PAGAR">
<ToolBar name="ToolBar1">
<ToolBarItem comment="Nueva Factura" image="new" name="nuevo" text="Factura"/>
<ToolBarItem comment="Criterio de busqueda" image="find" name="buscar" text="Buscar Factura"/>
<ToolBarSeparator name="ToolBarSeparator1"/>
<ToolBarItem image="quit" name="salir" text="Salir"/>
</ToolBar>
<Grid gridHeight="26" gridWidth="121" name="Grid1" posX="0" posY="0">
<Group gridHeight="12" gridWidth="75" name="Group1" posX="1" posY="1">
<Label posX="2" posY="1" text="Codigo Suplidor"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" autoNext="true" colName="cod_sp" fieldId="1" fieldType="TABLE_COLUMN" gridHeight="1" gridWidth="2" name="cptb00001.cod_sp" posX="20" posY="1" sqlTabName="cptb00001" sqlType="SMALLINT" tabIndex="1" table_alias_name="" widget="Edit"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" autoNext="true" colName="cod_sp_sec" comment="Presione Ctrl-W Para busca Suplidor" fieldId="2" fieldType="TABLE_COLUMN" gridHeight="1" gridWidth="4" name="cptb00001.cod_sp_sec" posX="25" posY="1" sqlTabName="cptb00001" sqlType="SMALLINT" tabIndex="2" table_alias_name="" widget="Edit"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="nom_sup" color="yellow" fieldId="4" gridHeight="1" gridWidth="41" name="nom_sup" noEntry="true" posX="31" posY="1" sqlTabName="formonly" tabIndex="3" table_alias_name="" widget="Edit"/>
<Label posX="2" posY="2" text="Numero Factura"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" case="upper" colName="" fieldId="3" fieldType="NON_DATABASE" gridHeight="1" gridWidth="14" length="13" name="num_doc" posX="20" posY="2" sqlTabName="" sqlType="VARCHAR" tabIndex="4" table_alias_name="" widget="Edit"/>
<Label posX="41" posY="2" text="Fecha Factura"/>
<DateEdit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="fecha_orig" fieldId="5" fieldType="TABLE_COLUMN" format="dd/mm/yyyy" gridHeight="1" gridWidth="10" name="cptb00001.fecha_orig" posX="62" posY="2" sqlTabName="cptb00001" sqlType="DATE" tabIndex="5" table_alias_name="" widget="DateEdit"/>
<Label posX="2" posY="3" text="Fecha Vencimento"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="fecha_proc" fieldId="6" fieldType="TABLE_COLUMN" format="dd/mm/yyyy" gridHeight="1" gridWidth="10" name="cptb00001.fecha_proc" posX="20" posY="3" sqlTabName="cptb00001" sqlType="DATE" tabIndex="6" table_alias_name="" widget="Edit"/>
<Label posX="41" posY="3" text="Monto Factura"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="valor_fac" comment="Digite el valor de la factura" fieldId="7" gridHeight="1" gridWidth="12" name="valor_fac" posX="60" posY="3" precisionDecimal="12" scaleDecimal="2" sqlTabName="formonly" sqlType="DECIMAL" tabIndex="7" table_alias_name="" widget="Edit"/>
<Label posX="2" posY="4" text="Orden"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" autoNext="true" colName="tipo_oc" comment="01-Generales 02-Rov.ltd 03-Locales 04-Miscelaneas" fieldId="19" gridHeight="1" gridWidth="3" name="tipo_oc" posX="20" posY="4" sqlTabName="formonly" sqlType="CHAR" tabIndex="8" table_alias_name="" widget="Edit"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="orden_no" fieldId="18" fieldType="TABLE_COLUMN" gridHeight="1" gridWidth="6" name="cptb00001.orden_no" posX="24" posY="4" sqlTabName="cptb00001" sqlType="INTEGER" tabIndex="9" table_alias_name="" widget="Edit"/>
<Label posX="41" posY="4" text="Monto Impuesto"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="itbis" comment="Digite el valor del impuesto de la factura" fieldId="8" gridHeight="1" gridWidth="12" name="itbis" posX="60" posY="4" precisionDecimal="12" scaleDecimal="2" sqlTabName="formonly" sqlType="DECIMAL" tabIndex="10" table_alias_name="" widget="Edit"/>
<Label gridHeight="1" gridWidth="10" name="Label3" posX="2" posY="5" text="Valor Orden"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="" fieldId="22" gridHeight="1" gridWidth="10" name="monto_orden" posX="20" posY="5" sqlTabName="" tabIndex="23" table_alias_name="" title="Edit1" widget="Edit"/>
<Label gridHeight="1" gridWidth="10" name="Label4" posX="41" posY="5" text="Valor Recibido"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="" fieldId="23" gridHeight="1" gridWidth="12" name="valor_recibido_b" posX="60" posY="5" sqlTabName="" tabIndex="24" table_alias_name="" title="Edit1" widget="Edit"/>
<Label posX="2" posY="6" text="Moneda"/>
<ComboBox aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="cod_mon" fieldId="0" gridHeight="1" gridWidth="12" items="" name="cod_mon" noEntry="true" posX="20" posY="6" sqlTabName="formonly" tabIndex="12" table_alias_name="" widget="ComboBox"/>
<Label gridHeight="1" gridWidth="10" name="Label5" posX="41" posY="6" text="Servicios"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="" fieldId="24" gridHeight="1" gridWidth="12" name="xservicios" posX="60" posY="6" sqlTabName="" tabIndex="25" table_alias_name="" title="Edit1" widget="Edit"/>
<Label posX="2" posY="7" text="NCF"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="ncf" comment="Digite el numero del NCF de la factura" fieldId="11" gridHeight="1" gridWidth="19" name="ncf" posX="20" posY="7" sqlTabName="formonly" tabIndex="15" table_alias_name="" widget="Edit"/>
<Label gridHeight="1" gridWidth="10" name="Label6" posX="41" posY="7" text="Bienes"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="" fieldId="25" gridHeight="1" gridWidth="12" name="xbienes" posX="60" posY="7" sqlTabName="" tabIndex="26" table_alias_name="" title="Edit2" widget="Edit"/>
<Label posX="2" posY="9" text="Observacion"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" case="upper" colName="detalle" fieldId="12" fieldType="TABLE_COLUMN" gridHeight="1" gridWidth="32" name="cptb00001.detalle" posX="20" posY="9" required="true" sqlTabName="cptb00001" sqlType="VARCHAR" tabIndex="11" table_alias_name="" widget="Edit"/>
<Label posX="2" posY="10" text="Tipo Gasto"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="tipo_ncf" comment="Digite el tipo del NCF" fieldId="9" gridHeight="1" gridWidth="3" name="tipo_ncf" posX="20" posY="10" sqlTabName="formonly" sqlType="SMALLINT" tabIndex="13" table_alias_name="" widget="Edit"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="descripcion_ncf" comment="Digite el tipo del NCF" fieldId="10" gridHeight="1" gridWidth="24" name="descripcion_ncf" posX="24" posY="10" sqlTabName="formonly" tabIndex="14" table_alias_name="" widget="Edit"/>
</Group>
<Group gridHeight="6" gridWidth="42" name="group4" posX="79" posY="1" text="Foto">
<FFImage aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" autoScale="true" colName="foto_producto" fieldId="26" gridHeight="3" gridWidth="36" name="foto" posX="2" posY="1" sqlTabName="formonly" stretch="both" table_alias_name="" unitWidth="characters" widget="FFImage" width="36"/>
</Group>
<Group gridHeight="11" gridWidth="27" name="group5" posX="79" posY="7">
<Button gridHeight="1" gridWidth="8" image="fa-picture-o" name="busca_foto" posX="2" posY="1" tabIndex="-1" text="Foto"/>
<Edit fieldId="27" gridHeight="1" gridWidth="24" name="nombre_file_foto" posX="2" posY="3" scroll="true" tabIndex="-1" title="edit1" widget="Edit"/>
</Group>
<Group gridHeight="6" gridWidth="75" name="Group2" posX="1" posY="14">
<Label posX="2" posY="1" text="Apl."/>
<Label posX="8" posY="1" text="Aplica a."/>
<Label posX="24" posY="1" text="Tipo"/>
<Label posX="36" posY="1" text="Monto Dcto."/>
<Label posX="56" posY="1" text="Valor Aplicado"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" case="upper" colName="tipo" columnCount="1" comment="Digite S = en caso de que desee aplica prepago, N = en caso contrario" fieldId="13" gridHeight="1" gridWidth="2" name="tipo" posX="3" posY="2" repeat="true" rowCount="3" sqlTabName="formonly" sqlType="CHAR" stepX="1" stepY="0" tabIndex="16" table_alias_name="" widget="Edit"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" case="upper" colName="aplica_a" columnCount="1" comment="Digite el numero del prepago" fieldId="14" fieldType="TABLE_COLUMN" gridHeight="1" gridWidth="10" name="cptb00001.aplica_a" posX="9" posY="2" repeat="true" rowCount="3" sqlTabName="cptb00001" sqlType="VARCHAR" stepX="1" stepY="0" tabIndex="17" table_alias_name="" widget="Edit"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="tipo_doc" columnCount="1" fieldId="15" fieldType="TABLE_COLUMN" gridHeight="1" gridWidth="2" name="cptb00001.tipo_doc" noEntry="true" posX="25" posY="2" repeat="true" rowCount="3" sqlTabName="cptb00001" sqlType="VARCHAR" stepX="1" stepY="0" tabIndex="18" table_alias_name="" widget="Edit"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="valor_prep" columnCount="1" fieldId="16" gridHeight="1" gridWidth="12" name="valor_prep" noEntry="true" posX="36" posY="2" precisionDecimal="12" repeat="true" rowCount="3" scaleDecimal="2" sqlTabName="formonly" sqlType="DECIMAL" stepX="1" stepY="0" tabIndex="19" table_alias_name="" widget="Edit"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="valor" columnCount="1" comment="Digite el valor a aplicar" fieldId="17" fieldType="TABLE_COLUMN" gridHeight="1" gridWidth="12" name="cptb00001.valor" notNull="true" posX="58" posY="2" precisionDecimal="12" repeat="true" required="true" rowCount="3" scaleDecimal="2" sqlTabName="cptb00001" sqlType="DECIMAL" stepX="1" stepY="0" tabIndex="20" table_alias_name="" widget="Edit"/>
</Group>
<Group gridHeight="4" gridWidth="74" name="Group3" posX="1" posY="21">
<Label gridHeight="1" gridWidth="12" name="Label1" posX="2" posY="1" text="Total Debito"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="debito1" fieldId="20" gridHeight="1" gridWidth="12" name="debito1" posX="58" posY="1" sqlTabName="formonly" tabIndex="21" table_alias_name="" widget="Edit"/>
<Label gridHeight="1" gridWidth="13" name="Label2" posX="2" posY="2" text="Total Credito"/>
<Edit aggregateColName="" aggregateName="" aggregateTableAliasName="" aggregateTableName="" colName="credito1" fieldId="21" gridHeight="1" gridWidth="12" name="credito1" posX="58" posY="2" sqlTabName="formonly" tabIndex="22" table_alias_name="" widget="Edit"/>
</Group>
</Grid>
<ActionDefaultList name="ActionDefaultList1">
<ActionDefault name="busca_foto" text="Buscar Fotos"/>
</ActionDefaultList>
</Form>
<DiagramLayout>
<![CDATA[AAAAAgAAAEwAewAzADkAZgBiADAAOQBmADQALQBhAGUAZgA0AC0ANAA2ADIAMQAtAGEAYQA4ADcALQBlAGUAMQBiAGYAMQBkADYAZQBkADcANAB9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAEwAewBiAGUAOABkADkAYQBjAGUALQAxADkAOQBhAC0ANAAyADIAYQAtADkAOQA4ADkALQA5ADEAYgAwADMANwBjADgAZgBmADAAZQB9QCAAACAAABxAIAAAIAAAHAAAAAAAAAAAAQ==]]>
</DiagramLayout>
</ManagedForm>
+50
View File
@@ -0,0 +1,50 @@
{
==============================================================================
FORMULARIO : CPFMWD041
OBJETIVO : Compra electronica e-CF 41 (Comprobante de Compras).
Se digita el neto, el % de ISR, el tipo de retencion ISR
(formato 606), si lleva ITBIS y si es bien o servicio;
el resto se calcula solo.
PROGRAMA Q. USA : CPPRMT001 (modulo cpprmt001_ecf.4gl)
FECHA : Octubre 2026
==============================================================================
}
SCHEMA FORMONLY
LAYOUT (TEXT="Compra electronica (e-CF 41)")
GRID
{
e-NCF [f01 ]
Suplidor [f02 ]
Cedula/RNC [f03 ]
Neto a pagar [f04 ]
% ISR [f05 ]
Tipo retencion ISR [f06 ]
Lleva ITBIS 18% [f07 ]
Bien o servicio [f13 ]
Subtotal [f08 ]
ITBIS 18% [f09 ]
ISR retenido [f10 ]
ITBIS retenido [f11 ]
Total comprobante [f12 ]
}
END
END
ATTRIBUTES
EDIT f01 = FORMONLY.ncf41 TYPE CHAR, NOENTRY;
EDIT f02 = FORMONLY.nom41 TYPE CHAR, NOENTRY;
EDIT f03 = FORMONLY.rnc41 TYPE CHAR, NOENTRY;
EDIT f04 = FORMONLY.neto41 TYPE DECIMAL(12,2), FORMAT="--,---,--&.&&",
COMMENT="Lo que recibe el proveedor";
COMBOBOX f05 = FORMONLY.porc41 TYPE DECIMAL(5,2),
ITEMS=((0,"0% - Exento"),(3,"3% - Servicios tecnicos"),(15,"15% - Honorarios / alquileres"));
COMBOBOX f06 = FORMONLY.cisr41 TYPE SMALLINT;
CHECKBOX f07 = FORMONLY.itbis41 TYPE CHAR, VALUECHECKED="S", VALUEUNCHECKED="N", TEXT="";
COMBOBOX f13 = FORMONLY.bs41 TYPE CHAR, ITEMS=(("1","Bien"),("2","Servicio"));
EDIT f08 = FORMONLY.sub41 TYPE DECIMAL(12,2), FORMAT="--,---,--&.&&", NOENTRY;
EDIT f09 = FORMONLY.itb41 TYPE DECIMAL(12,2), FORMAT="--,---,--&.&&", NOENTRY;
EDIT f10 = FORMONLY.isr41 TYPE DECIMAL(12,2), FORMAT="--,---,--&.&&", NOENTRY;
EDIT f11 = FORMONLY.itbret41 TYPE DECIMAL(12,2), FORMAT="--,---,--&.&&", NOENTRY;
EDIT f12 = FORMONLY.total41 TYPE DECIMAL(12,2), FORMAT="--,---,--&.&&", NOENTRY;
END
+76 -1
View File
@@ -192,6 +192,7 @@ LET tipo_ncf=NULL
LET descripcion_ncf=NULL
LET itbis =NULL
LET ncf = NULL
CALL e41_reset() -- compra electronica 41 (cpprmt001_ecf.4gl)
@@ -228,6 +229,29 @@ INPUT BY NAME factura.*,ITBIS,TIPO_NCF,cod_mon,NCF WITHOUT DEFAULTS
END IF
ON ACTION compra_e41 ATTRIBUTE(TEXT="Compra Electronica",IMAGE="new")
-- e-CF 41: trae el proximo e-NCF y calcula montos desde el neto
IF factura.cod_sp IS NULL OR factura.cod_sp_sec IS NULL THEN
CALL fgl_winmessage("COMPRA ELECTRONICA","Primero elija el suplidor.","exclamation")
NEXT FIELD cod_sp
END IF
IF e41_captura(factura.cod_sp, factura.cod_sp_sec) THEN
LET tipo_ncf = 41
SELECT a.descripcion INTO descripcion_ncf FROM cgtb00074 a
WHERE a.codigo_fiscal = 41
LET ncf = e41_ncf()
LET factura.num_doc = e41_ncf()
LET factura.valor_fac = e41_neto() -- CxP queda por el neto
LET itbis = e41_itbis()
DISPLAY BY NAME factura.num_doc, factura.valor_fac, itbis, tipo_ncf, ncf, descripcion_ncf
-- lo llena el sistema: no se digita
CALL DIALOG.setFieldActive("num_doc", FALSE)
CALL DIALOG.setFieldActive("valor_fac", FALSE)
CALL DIALOG.setFieldActive("itbis", FALSE)
CALL DIALOG.setFieldActive("tipo_ncf", FALSE)
CALL DIALOG.setFieldActive("ncf", FALSE)
END IF
AFTER FIELD itbis
IF itbis IS NULL THEN
CALL msg(16)
@@ -1306,7 +1330,9 @@ CLOSE WINDOW busca_sp
END FUNCTION
FUNCTION contab()
DEFINE tdebito,tcredito,diferencia DEC(12,2)
DEFINE tdebito,tcredito,diferencia DEC(12,2),
isr_ctas DEC(12,2),
ncf41 VARCHAR(13)
LET int_flag = FALSE
OPEN WINDOW cpfmwd007 AT 10,3 WITH FORM "cpfmwd007"
ATTRIBUTE(BORDER,FORM LINE FIRST + 2,COMMENT LINE LAST)
@@ -1380,6 +1406,16 @@ END CASE
END IF
DISPLAY BY NAME descripcion ATTRIBUTE(BLUE)
-- compra electronica 41: cuenta marcada como retencion -> ISR retenido
IF e41_activo() THEN
IF e41_cuenta_isr(cuentas[curr].cuenta_no) THEN
IF NVL(cuentas[curr].debito,0) = 0 AND NVL(cuentas[curr].credito,0) = 0 THEN
LET cuentas[curr].credito = e41_isr()
DISPLAY cuentas[curr].credito TO cuentas1[curr1].credito
END IF
END IF
END IF
IF cuentas[curr].cuenta_no = cuenta_mayor THEN
CALL msg(192)
@@ -1510,7 +1546,36 @@ END CASE
NEXT FIELD cuenta_no
END IF
-- compra electronica 41: el ISR de las cuentas de retencion debe ser el calculado
IF e41_activo() THEN
LET isr_ctas = 0
FOR idx = 1 TO arr_count()
IF cuentas[idx].cuenta_no IS NOT NULL THEN
IF e41_cuenta_isr(cuentas[idx].cuenta_no) THEN
LET isr_ctas = isr_ctas + NVL(cuentas[idx].credito,0) - NVL(cuentas[idx].debito,0)
END IF
END IF
END FOR
IF isr_ctas <> e41_isr() THEN
CALL fgl_winmessage("COMPRA ELECTRONICA",
"La retencion de ISR en las cuentas ("||isr_ctas||") no es igual a la calculada ("||e41_isr()||").\n"||
"Use una cuenta marcada como retencion en el catalogo.","stop")
NEXT FIELD cuenta_no
END IF
END IF
BEGIN WORK
-- compra electronica 41: se reserva el e-NCF ahora (si se cancela no se pierde)
IF e41_activo() THEN
LET ncf41 = e41_reserva_ncf()
IF ncf41 IS NULL THEN
ROLLBACK WORK
NEXT FIELD cuenta_no
END IF
LET factura.num_doc = ncf41
LET ncf = ncf41
END IF
###### Insertando registros en la Maestra de cuentas por Pagar ####
LET cod_sp1 = factura.cod_sp
@@ -1668,8 +1733,18 @@ LET credito=factura.valor_fac
END IF
END FOR
CALL cuadrada(factura.cod_sp,factura.cod_sp_sec,factura.num_doc) RETURNING cuadradatrx
IF cuadradatrx AND e41_activo() THEN
IF NOT e41_guarda(factura.cod_sp,factura.cod_sp_sec,factura.num_doc,factura.fecha_orig) THEN
LET cuadradatrx = FALSE
END IF
END IF
IF cuadradatrx THEN
COMMIT WORK
-- compra electronica 41: envio a la DGII
IF e41_activo() THEN
CALL e41_envia(factura.cod_sp,factura.cod_sp_sec,factura.num_doc,
factura.fecha_orig,factura.fecha_proc,factura.detalle)
END IF
ELSE
ROLLBACK WORK
File diff suppressed because it is too large Load Diff
+83
View File
@@ -0,0 +1,83 @@
/* ============================================================
DECOMARMOL - Compra electronica e-CF 41 en cpprmt001
Idempotente: se puede correr varias veces; solo agrega lo que falta.
============================================================ */
SET NOCOUNT ON;
GO
/* ---------------- 1) cptb00041: e-CF 41 emitidos desde cpprmt001 ---------------- */
IF OBJECT_ID('dbo.cptb00041', 'U') IS NULL
BEGIN
CREATE TABLE dbo.cptb00041 (
cod_sp SMALLINT NOT NULL,
cod_sp_sec SMALLINT NOT NULL,
num_doc CHAR(13) NOT NULL, -- = e-NCF (E41xxxxxxxxxx), igual que cptb00001.num_doc
ncf VARCHAR(13) NULL,
fecha DATE NULL,
rnc VARCHAR(11) NULL, -- cedula/RNC del proveedor (va como Comprador en el XML)
neto DECIMAL(18,2) NULL, -- lo que recibe el proveedor (= valor_fac en CxP)
porc_isr DECIMAL(5,2) NULL, -- 0, 3 o 15
codigo_isr SMALLINT NULL, -- tipo de retencion ISR del 606 (cgtb00077)
lleva_itbis CHAR(1) NULL, -- S/N
bien_servicio CHAR(1) NULL, -- 1 bien / 2 servicio
subtotal DECIMAL(18,2) NULL,
itbis DECIMAL(18,2) NULL,
isr_retenido DECIMAL(18,2) NULL,
itbis_retenido DECIMAL(18,2) NULL, -- 100% del ITBIS
total DECIMAL(18,2) NULL, -- subtotal + ITBIS (MontoTotal del XML)
-- rastreo DGII
hash VARCHAR(10) NULL,
ultima_respuesta VARCHAR(MAX) NULL,
fechafirmadigital DATETIME NULL,
trackid VARCHAR(100) NULL,
estado_dgii VARCHAR(50) NULL,
mensaje VARCHAR(2000) NULL,
status_t CHAR(1) NULL,
us_crea VARCHAR(50) NULL,
fech_crea DATETIME NULL CONSTRAINT df_cptb00041_fc DEFAULT GETDATE(),
us_mod VARCHAR(50) NULL,
fech_mod DATETIME NULL,
CONSTRAINT pk_cptb00041 PRIMARY KEY (cod_sp, cod_sp_sec, num_doc)
);
PRINT 'cptb00041 creada';
END
ELSE PRINT 'cptb00041 ya existe';
GO
/* ---------------- 2) Tipo NCF 41 en la lista de cpprmt001 ---------------- */
IF NOT EXISTS (SELECT 1 FROM cgtb00074 WHERE codigo_fiscal = 41)
INSERT INTO cgtb00074 (codigo_fiscal, descripcion) VALUES (41, 'COMPRAS ELECTRONICO');
GO
/* ---------------- 3) Tipos de retencion ISR del 606 (cgtb00077) ---------------- */
INSERT INTO cgtb00077 (codigo_isr, descripcion)
SELECT v.codigo_isr, v.descripcion
FROM (VALUES
(1, 'ALQUILERES'),
(2, 'HONORARIOS POR SERVICIOS'),
(3, 'OTRAS RENTAS'),
(4, 'OTRAS RENTAS (RENTAS PRESUNTAS)'),
(5, 'INTERESES PAGADOS A PERSONAS JURIDICAS RESIDENTES'),
(6, 'INTERESES PAGADOS A PERSONAS FISICAS RESIDENTES'),
(7, 'RETENCION POR PROVEEDORES DEL ESTADO'),
(8, 'JUEGOS TELEFONICOS'),
(9, 'RETENCIONES SUBSECTOR GANADERIA DE CARNE BOVINA')
) AS v(codigo_isr, descripcion)
WHERE NOT EXISTS (SELECT 1 FROM cgtb00077 x WHERE x.codigo_isr = v.codigo_isr);
GO
/* ---------------- 4) REVISION (no cambia nada) ---------------- */
-- a) rango del 41: debe existir con tipo_doc='FT', codigo_dgii='41', disponible='S'
-- (se crea en el mantenimiento de NCF, veprmt020, con los datos de la DGII)
SELECT tipo_doc, codigo_dgii, ncf_inicial, ncf_final, disponible, fecha_vencimiento, sucid
FROM vetb00071 WHERE codigo_dgii = '41';
SELECT * FROM vetb00073 WHERE codigo_dgii = '41';
-- b) cuenta(s) de ISR retenido: deben estar en el catalogo con retencion='SI' y su codigo_isr
-- (se marcan en el mantenimiento del catalogo, cgprmt001). La de ITBIS retenido se deja en NO.
SELECT cuenta_no, descripcion, retencion, codigo_isr
FROM cgtb00001 WHERE retencion = 'SI' OR descripcion LIKE '%RETEN%';
-- c) ambiente DGII de la empresa (test / certificacion / produccion)
SELECT nombre, rnc, ambienteDgii, id_dgii, id_municipio_dgii FROM companias;
GO
+817
View File
@@ -0,0 +1,817 @@
{
-----------------------------------------------------------------------------
MODULO : CPPRMT001_ECF
OBJETIVO : Compra electronica e-CF 41 (Comprobante de Compras) desde
cpprmt001 (Facturas de proveedores).
- Boton "Compra Electronica": trae el proximo e-NCF 41 del rango
(vetb00071/vetb00073, tipo_doc 'FT', codigo_dgii '41') y abre la
ventana cpfmwd041 donde se digita el NETO, el % de ISR, el tipo
de retencion ISR (606) y si lleva ITBIS. El resto se calcula solo:
subtotal = neto / (1 - %ISR)
ISR retenido = subtotal - neto
ITBIS (18%) = subtotal * 18% (si lleva ITBIS)
ITBIS retenido = 100% del ITBIS
total = subtotal + ITBIS
- El e-NCF se RESERVA al grabar (dentro de la transaccion), asi no
se pierden secuencias si cancelan.
- La retencion de ISR de la distribucion contable debe estar en una
cuenta marcada como retencion en el catalogo (cgtb00001.retencion).
- Al grabar: guarda el rastreo en cptb00041 y envia el XML del 41.
FECHA : Octubre 2026
-----------------------------------------------------------------------------
}
IMPORT util
GLOBALS "cpprgb000.4gl"
DEFINE wcp om.SaxDocumentHandler
-- estado de la compra electronica en curso
DEFINE e41 RECORD
activo BOOLEAN,
ncf41 VARCHAR(13),
nom41 VARCHAR(90),
rnc41 VARCHAR(11),
neto41 DECIMAL(12,2),
porc41 DECIMAL(5,2),
cisr41 SMALLINT,
itbis41 CHAR(1),
bs41 CHAR(1),
sub41 DECIMAL(12,2),
itb41 DECIMAL(12,2),
isr41 DECIMAL(12,2),
itbret41 DECIMAL(12,2),
total41 DECIMAL(12,2)
END RECORD
#-----------------------------------------------------------------------------
FUNCTION e41_reset()
INITIALIZE e41.* TO NULL
LET e41.activo = FALSE
END FUNCTION
FUNCTION e41_activo() RETURNS BOOLEAN
RETURN NVL(e41.activo, FALSE)
END FUNCTION
FUNCTION e41_ncf() RETURNS VARCHAR(13)
RETURN e41.ncf41
END FUNCTION
FUNCTION e41_neto() RETURNS DECIMAL(12,2)
RETURN e41.neto41
END FUNCTION
FUNCTION e41_itbis() RETURNS DECIMAL(12,2)
RETURN e41.itb41
END FUNCTION
FUNCTION e41_isr() RETURNS DECIMAL(12,2)
RETURN NVL(e41.isr41, 0)
END FUNCTION
#-----------------------------------------------------------------------------
# % de ISR permitidos: 0 = exento, 3 = servicios tecnicos,
# 15 = honorarios / profesionales / alquileres
#-----------------------------------------------------------------------------
FUNCTION porc_isr_valido41(pporc)
DEFINE pporc DECIMAL(5,2)
IF pporc IS NULL THEN
RETURN FALSE
END IF
RETURN (pporc = 0 OR pporc = 3 OR pporc = 15)
END FUNCTION
#-----------------------------------------------------------------------------
# Calcula los montos del 41 a partir del neto (lo que recibe el proveedor).
# El ISR se saca por diferencia para que el neto cuadre exacto al centavo.
#-----------------------------------------------------------------------------
FUNCTION calcula41(pneto, pporc_isr, plleva_itbis)
DEFINE pneto DECIMAL(12,2),
pporc_isr DECIMAL(5,2),
plleva_itbis CHAR(1),
xsubtotal, xitbis, xisr, xitbis_ret, xtotal DECIMAL(12,2)
LET pneto = NVL(pneto, 0)
LET pporc_isr = NVL(pporc_isr, 0)
LET xsubtotal = pneto / (1 - pporc_isr / 100) -- se redondea a 2 decimales
LET xisr = xsubtotal - pneto
IF plleva_itbis = 'S' THEN
LET xitbis = xsubtotal * 18 / 100
ELSE
LET xitbis = 0
END IF
LET xitbis_ret = xitbis -- se retiene el 100%
LET xtotal = xsubtotal + xitbis
RETURN xsubtotal, xitbis, xisr, xitbis_ret, xtotal
END FUNCTION
#-----------------------------------------------------------------------------
# Deja solo los digitos (cedula/RNC sin guiones ni espacios)
#-----------------------------------------------------------------------------
FUNCTION e41_solo_digitos(ptexto)
DEFINE ptexto, xres STRING,
i INT
LET xres = ""
FOR i = 1 TO ptexto.getLength()
IF ptexto.getCharAt(i) MATCHES "[0-9]" THEN
LET xres = xres.append(ptexto.getCharAt(i))
END IF
END FOR
IF xres.getLength() = 0 THEN
RETURN NULL
END IF
RETURN xres
END FUNCTION
#-----------------------------------------------------------------------------
# Proximo e-NCF 41 SIN reservarlo (solo para mostrarlo).
# Retorna NULL si no hay rango o se agoto.
#-----------------------------------------------------------------------------
FUNCTION e41_proximo_ncf() RETURNS VARCHAR(13)
DEFINE xinicial, xfinal, xult, xnuevo INT
SELECT MIN(a.ncf_inicial), MAX(a.ncf_final) INTO xinicial, xfinal
FROM vetb00071 a
WHERE a.tipo_doc = 'FT' AND a.codigo_dgii = '41' AND a.disponible = 'S'
IF xfinal IS NULL THEN
CALL fgl_winmessage("COMPRA ELECTRONICA",
"No hay rango disponible para el e-NCF 41 (vetb00071 tipo_doc FT, codigo 41).\nLlame a finanzas.","stop")
RETURN NULL
END IF
SELECT MAX(a.ncf) INTO xult FROM vetb00073 a
WHERE a.tipo_doc = 'FT' AND a.codigo_dgii = '41'
IF xult IS NULL OR xult < NVL(xinicial, 1) - 1 THEN
LET xult = NVL(xinicial, 1) - 1
END IF
LET xnuevo = xult + 1
IF xnuevo > xfinal THEN
CALL fgl_winmessage("COMPRA ELECTRONICA","Se agoto el rango del e-NCF 41. Llame a finanzas.","stop")
RETURN NULL
END IF
RETURN "E41" || (xnuevo USING "&&&&&&&&&&")
END FUNCTION
#-----------------------------------------------------------------------------
# Reserva el e-NCF 41 (se llama DENTRO de la transaccion de grabado).
# Si vetb00073 no tiene la fila FT/41 la crea desde ncf_inicial.
# Retorna NULL si no hay rango o se agoto.
#-----------------------------------------------------------------------------
FUNCTION e41_reserva_ncf() RETURNS VARCHAR(13)
DEFINE xinicial, xfinal, xnuevo INT
SELECT MIN(a.ncf_inicial), MAX(a.ncf_final) INTO xinicial, xfinal
FROM vetb00071 a
WHERE a.tipo_doc = 'FT' AND a.codigo_dgii = '41' AND a.disponible = 'S'
IF xfinal IS NULL THEN
CALL fgl_winmessage("COMPRA ELECTRONICA","No hay rango disponible para el e-NCF 41.","stop")
RETURN NULL
END IF
UPDATE vetb00073 SET ncf = ncf + 1, us_crea = usuarios, fech_crea = getdate()
WHERE tipo_doc = 'FT' AND codigo_dgii = '41'
IF STATUS < 0 THEN
CALL fgl_winmessage("COMPRA ELECTRONICA","Error reservando el e-NCF 41: "||SQLCA.sqlcode,"stop")
RETURN NULL
END IF
IF SQLCA.sqlerrd[3] = 0 THEN
LET xnuevo = NVL(xinicial, 1)
INSERT INTO vetb00073 (codigo_dgii, tipo_doc, ncf, sucid, us_crea, fech_crea)
VALUES ('41', 'FT', xnuevo, 1, usuarios, getdate())
IF STATUS < 0 THEN
CALL fgl_winmessage("COMPRA ELECTRONICA","Error creando el contador del e-NCF 41: "||SQLCA.sqlcode,"stop")
RETURN NULL
END IF
ELSE
SELECT MAX(a.ncf) INTO xnuevo FROM vetb00073 a
WHERE a.tipo_doc = 'FT' AND a.codigo_dgii = '41'
END IF
IF xnuevo > xfinal THEN
CALL fgl_winmessage("COMPRA ELECTRONICA","Se agoto el rango del e-NCF 41. Llame a finanzas.","stop")
RETURN NULL
END IF
LET e41.ncf41 = "E41" || (xnuevo USING "&&&&&&&&&&")
RETURN e41.ncf41
END FUNCTION
#-----------------------------------------------------------------------------
# TRUE si la cuenta esta marcada como retencion en el catalogo.
# Si tiene codigo de ISR y en la ventana no se escogio, se toma de la cuenta.
#-----------------------------------------------------------------------------
FUNCTION e41_cuenta_isr(pcuenta)
DEFINE pcuenta CHAR(8),
xret CHAR(2),
xcod SMALLINT
LET xret = NULL
LET xcod = NULL
SELECT a.retencion, a.codigo_isr INTO xret, xcod
FROM cgtb00001 a
WHERE a.cuenta_no = pcuenta
IF xret IS NULL OR UPSHIFT(xret) <> "SI" THEN
RETURN FALSE
END IF
IF e41.cisr41 IS NULL AND xcod IS NOT NULL THEN
LET e41.cisr41 = xcod
END IF
RETURN TRUE
END FUNCTION
#-----------------------------------------------------------------------------
# Llena el combo de tipos de retencion ISR (cgtb00077) de la ventana del 41
#-----------------------------------------------------------------------------
FUNCTION e41_carga_cisr()
DEFINE cb ui.ComboBox,
xcod SMALLINT,
xdes CHAR(50)
LET cb = ui.ComboBox.forName("formonly.cisr41")
IF cb IS NULL THEN
RETURN
END IF
CALL cb.clear()
DECLARE c_cisr41 CURSOR FOR
SELECT a.codigo_isr, a.descripcion FROM cgtb00077 a ORDER BY a.codigo_isr
FOREACH c_cisr41 INTO xcod, xdes
CALL cb.addItem(xcod, (xcod USING "<&") || " - " || xdes CLIPPED)
END FOREACH
END FUNCTION
#-----------------------------------------------------------------------------
FUNCTION e41_recalcula()
CALL calcula41(e41.neto41, e41.porc41, e41.itbis41)
RETURNING e41.sub41, e41.itb41, e41.isr41, e41.itbret41, e41.total41
DISPLAY e41.sub41, e41.itb41, e41.isr41, e41.itbret41, e41.total41
TO sub41, itb41, isr41, itbret41, total41
END FUNCTION
#-----------------------------------------------------------------------------
# Boton "Compra Electronica": valida el suplidor, muestra el proximo e-NCF
# y captura neto / % ISR / tipo ISR / ITBIS. Retorna TRUE si se acepto.
#-----------------------------------------------------------------------------
FUNCTION e41_captura(pcod_sp, pcod_sp_sec)
DEFINE pcod_sp, pcod_sp_sec SMALLINT,
xnom VARCHAR(90),
xrnc STRING,
xproximo VARCHAR(13),
xcodigo SMALLINT
-- tipo fiscal 41 en la lista de tipos NCF
LET xcodigo = NULL
SELECT a.codigo_fiscal INTO xcodigo FROM cgtb00074 a WHERE a.codigo_fiscal = 41
IF xcodigo IS NULL THEN
CALL fgl_winmessage("COMPRA ELECTRONICA",
"No existe el tipo NCF 41 en cgtb00074. Agreguelo antes de emitir.","stop")
RETURN FALSE
END IF
-- el proveedor va en el bloque Comprador: cedula (11) o RNC (9) obligatorio
SELECT a.nom_sp, a.rnc INTO xnom, xrnc FROM cotb00001 a
WHERE a.cod_sp = pcod_sp AND a.cod_sp_sec = pcod_sp_sec
LET xrnc = e41_solo_digitos(xrnc)
IF xrnc IS NULL OR (xrnc.getLength() <> 9 AND xrnc.getLength() <> 11) THEN
CALL fgl_winmessage("COMPRA ELECTRONICA",
"El suplidor "||pcod_sp||"-"||pcod_sp_sec||" no tiene cedula (11) o RNC (9) valido en el maestro de suplidores.\nCorrijalo antes de emitir el 41.","stop")
RETURN FALSE
END IF
LET xproximo = e41_proximo_ncf()
IF xproximo IS NULL THEN
RETURN FALSE
END IF
-- valores por defecto (si ya se habia capturado, se conservan)
IF NOT NVL(e41.activo, FALSE) THEN
INITIALIZE e41.* TO NULL
LET e41.porc41 = 3
LET e41.cisr41 = 3
LET e41.itbis41 = 'S'
LET e41.bs41 = '2'
END IF
LET e41.ncf41 = xproximo
LET e41.nom41 = xnom CLIPPED
LET e41.rnc41 = xrnc
OPEN WINDOW w_e41 WITH FORM "cpfmwd041"
ATTRIBUTES(STYLE="dialog", TEXT="Compra electronica (e-CF 41)")
CALL e41_carga_cisr()
LET int_flag = FALSE
INPUT BY NAME e41.neto41, e41.porc41, e41.cisr41, e41.itbis41, e41.bs41
WITHOUT DEFAULTS ATTRIBUTES(UNBUFFERED)
BEFORE INPUT
DISPLAY e41.ncf41, e41.nom41, e41.rnc41 TO ncf41, nom41, rnc41
CALL e41_recalcula()
ON CHANGE porc41
-- tipo de retencion sugerido segun el %
CASE e41.porc41
WHEN 3 LET e41.cisr41 = 3 -- otras rentas (servicios tecnicos)
WHEN 15 LET e41.cisr41 = 2 -- honorarios (alquiler = 1, escoger a mano)
WHEN 0 LET e41.cisr41 = NULL
END CASE
CALL e41_recalcula()
ON CHANGE itbis41
CALL e41_recalcula()
AFTER FIELD neto41
CALL e41_recalcula()
AFTER INPUT
IF NOT int_flag THEN
IF e41.neto41 IS NULL OR e41.neto41 <= 0 THEN
CALL fgl_winmessage("COMPRA ELECTRONICA","Digite el neto a pagar.","exclamation")
NEXT FIELD neto41
END IF
IF NOT porc_isr_valido41(e41.porc41) THEN
CALL fgl_winmessage("COMPRA ELECTRONICA","El % de ISR debe ser 0, 3 o 15.","exclamation")
NEXT FIELD porc41
END IF
IF e41.porc41 > 0 AND e41.cisr41 IS NULL THEN
CALL fgl_winmessage("COMPRA ELECTRONICA","Escoja el tipo de retencion ISR (formato 606).","exclamation")
NEXT FIELD cisr41
END IF
CALL e41_recalcula()
END IF
END INPUT
CLOSE WINDOW w_e41
IF int_flag THEN
LET int_flag = FALSE
RETURN FALSE
END IF
LET e41.activo = TRUE
RETURN TRUE
END FUNCTION
#-----------------------------------------------------------------------------
# Guarda el 41 en cptb00041 (dentro de la transaccion de grabado)
#-----------------------------------------------------------------------------
FUNCTION e41_guarda(pcod_sp, pcod_sp_sec, pnum_doc, pfecha)
DEFINE pcod_sp, pcod_sp_sec SMALLINT,
pnum_doc CHAR(13),
pfecha DATE
INSERT INTO cptb00041 (cod_sp, cod_sp_sec, num_doc, ncf, fecha, rnc, neto, porc_isr,
codigo_isr, lleva_itbis, bien_servicio, subtotal, itbis,
isr_retenido, itbis_retenido, total, us_crea, fech_crea)
VALUES (pcod_sp, pcod_sp_sec, pnum_doc, e41.ncf41, pfecha, e41.rnc41, e41.neto41,
e41.porc41, e41.cisr41, e41.itbis41, e41.bs41, e41.sub41, e41.itb41,
e41.isr41, e41.itbret41, e41.total41, usuarios, getdate())
IF STATUS < 0 THEN
CALL fgl_winmessage("COMPRA ELECTRONICA","Error guardando el e-CF 41 (cptb00041): "||SQLCA.sqlcode,"stop")
RETURN FALSE
END IF
RETURN TRUE
END FUNCTION
#-----------------------------------------------------------------------------
# Arma y envia el XML del 41 a la DGII (despues del COMMIT) y guarda la
# respuesta en cptb00041. Muestra el estado al usuario.
#-----------------------------------------------------------------------------
FUNCTION e41_envia(pcod_sp, pcod_sp_sec, pnum_doc, pfecha_orig, pfecha_proc, pdetalle)
DEFINE pcod_sp, pcod_sp_sec SMALLINT,
pnum_doc CHAR(13),
pfecha_orig, pfecha_proc DATE,
pdetalle CHAR(30)
DEFINE documento_encabezado RECORD
tipoEcf, eNcf, indicadorMontoGravado, tipoPago, fechaLimitePago, FormadePAgo, montoPago, FechaVencimientoSecuencia,
rncEmisor, razonSocialEmisor, direccionEmisor, Municipio, Provincia, telefonoEmisor,
correoEmisor, webSite, codigoVendedor, numeroFacturaInterna, numeroPedidoInterno,
fechaEmision, rncComprador, razonSocialComprador, montoGravadoTotal, montoGravadoI1,
montoGravadoI2, montoGravadoI3, montoExento, itbis1, itbis2, itbis3, totalItbis, totalItbis1,
totalItbis2, totalItbis3, montoTotal, tipoIngreso, terminoPago, TipoCuentaPago, NumeroCuentaPago, IdentificadorExtranjero,
contactoComprador, CorreoComprador, DireccionComprador, MunicipioComprador, ProvinciaComprador, FechaEntrega, FechaOrdenCompra,
NumeroOrdenCompra, CodigoInternoComprador,
nombreFile, IndicadorNotaCredito, NCFmodificado, codigoModificacion, fechaNCFmodificado STRING
END RECORD,
documento_Detalle DYNAMIC ARRAY OF RECORD
indicadorFacturacion, nombreItem, indicadorBienoServicio, cantidadItem, precioUnitarioItem,
montoItem STRING,
DescripcionItem VARCHAR(1000),
NumeroLinea INT
END RECORD,
ret41 DYNAMIC ARRAY OF RECORD
itbisRetenido DECIMAL(12,2),
isrRetenido DECIMAL(12,2)
END RECORD
DEFINE xrnc, xnombre, xdireccion VARCHAR(150),
xprov, xmuni VARCHAR(20),
xvence DATE,
xamb STRING,
phash, respuesta, xrespuesta, codigo, xhash STRING,
fechafirma DATETIME YEAR TO SECOND,
mensaje_trunc VARCHAR(2000),
idx INT
DEFINE Pok RECORD
trackId, ERROR, mensaje STRING
END RECORD
DEFINE p RECORD
trackid STRING,
codigo, estado, rnc, encf, secuenciaUtilizada, fechaRecepcion STRING,
mensajes DYNAMIC ARRAY OF RECORD
valor, codigo STRING
END RECORD
END RECORD
-- emisor
SELECT a.rnc, a.nombre, a.direccion, a.id_dgii, a.id_municipio_dgii
INTO xrnc, xnombre, xdireccion, xprov, xmuni
FROM companias a
SELECT MAX(a.fecha_vencimiento) INTO xvence FROM vetb00071 a
WHERE a.tipo_doc = 'FT' AND a.codigo_dgii = '41'
LET documento_encabezado.tipoEcf = "41"
LET documento_encabezado.eNcf = e41.ncf41
LET documento_encabezado.nombreFile = xrnc CLIPPED, e41.ncf41 CLIPPED, ".xml"
LET documento_encabezado.FechaVencimientoSecuencia = xvence USING "dd-mm-yyyy"
LET documento_encabezado.rncEmisor = xrnc CLIPPED
LET documento_encabezado.razonSocialEmisor = xnombre CLIPPED
LET documento_encabezado.direccionEmisor = xdireccion CLIPPED
LET documento_encabezado.Provincia = xprov CLIPPED
LET documento_encabezado.Municipio = xmuni CLIPPED
LET documento_encabezado.fechaEmision = pfecha_orig USING "dd-mm-yyyy"
-- va a cuentas por pagar: credito, vence en la fecha de proceso
LET documento_encabezado.tipoPago = '2'
LET documento_encabezado.fechaLimitePago = NVL(pfecha_proc, pfecha_orig) USING "dd-mm-yyyy"
LET documento_encabezado.FormadePAgo = '4'
-- Comprador = el proveedor
LET documento_encabezado.rncComprador = e41.rnc41
LET documento_encabezado.razonSocialComprador = e41.nom41
-- precios SIN ITBIS
LET documento_encabezado.indicadorMontoGravado = '0'
IF NVL(e41.itb41, 0) > 0 THEN
LET documento_encabezado.montoGravadoTotal = e41.sub41 USING "<<<<<<<<<<<<<&.&&"
LET documento_encabezado.montoGravadoI1 = e41.sub41 USING "<<<<<<<<<<<<<&.&&"
LET documento_encabezado.itbis1 = '18'
LET documento_encabezado.totalItbis = e41.itb41 USING "<<<<<<<<<<<<<&.&&"
LET documento_encabezado.totalItbis1 = e41.itb41 USING "<<<<<<<<<<<<<&.&&"
ELSE
LET documento_encabezado.montoExento = e41.sub41 USING "<<<<<<<<<<<<<&.&&"
END IF
LET documento_encabezado.montoTotal = e41.total41 USING "<<<<<<<<<<<<<&.&&"
LET documento_encabezado.montoPago = documento_encabezado.montoTotal
-- una linea con el concepto de la factura
IF NVL(e41.itb41, 0) > 0 THEN
LET documento_Detalle[1].indicadorFacturacion = 1
ELSE
LET documento_Detalle[1].indicadorFacturacion = 4
END IF
LET documento_Detalle[1].nombreItem = NVL(pdetalle CLIPPED, "COMPRA A PROVEEDOR INFORMAL")
LET documento_Detalle[1].indicadorBienoServicio = NVL(e41.bs41, '2')
LET documento_Detalle[1].cantidadItem = "1.00"
LET documento_Detalle[1].precioUnitarioItem = e41.sub41 USING "<<<<<<<<<<<<<&.&&"
LET documento_Detalle[1].montoItem = e41.sub41 USING "<<<<<<<<<<<<<&.&&"
LET ret41[1].itbisRetenido = NVL(e41.itbret41, 0)
LET ret41[1].isrRetenido = NVL(e41.isr41, 0)
CALL generafile41(documento_encabezado.*, documento_Detalle, ret41, 1, 1, 'adicionar')
RETURNING phash, respuesta, fechafirma, codigo
LET mensaje_trunc = respuesta
UPDATE cptb00041 SET hash = phash, ultima_respuesta = respuesta, fechafirmadigital = fechafirma
WHERE cod_sp = pcod_sp AND cod_sp_sec = pcod_sp_sec AND num_doc = pnum_doc
-- respuesta del envio
IF codigo = '200' THEN
TRY
CALL util.JSON.parse(respuesta, Pok)
CATCH
LET Pok.trackId = NULL
LET Pok.mensaje = 'ERROR EN PARSE'
END TRY
ELSE
LET Pok.trackId = NULL
LET Pok.mensaje = respuesta
END IF
-- estado en la DGII
LET p.estado = NULL
LET p.trackid = NULL
CALL p.mensajes.clear()
IF codigo = '200' THEN
LET xamb = ambiente()
CALL procesoEncf(' ', xamb.trim(), ' ', 0, 0, 'consultatrackid', respuesta)
RETURNING xhash, xrespuesta, codigo
TRY
CALL util.JSON.parse(xrespuesta, p)
CATCH
LET p.estado = 'SIN CONEXION'
LET p.mensajes[1].valor = 'NO SE PUDO CONSULTAR EL ESTADO EN LA DGII'
END TRY
END IF
IF p.estado = ' ' OR p.estado IS NULL THEN
LET p.estado = 'ERROR'
END IF
IF p.trackid IS NULL THEN
LET p.trackid = Pok.trackId
END IF
LET mensaje_trunc = NVL(Pok.mensaje, mensaje_trunc)
IF p.mensajes.getLength() > 0 THEN
LET mensaje_trunc = NULL
FOR idx = 1 TO p.mensajes.getLength()
IF p.mensajes[idx].valor IS NOT NULL THEN
IF mensaje_trunc IS NULL THEN
LET mensaje_trunc = p.mensajes[idx].valor
ELSE
LET mensaje_trunc = mensaje_trunc CLIPPED, " | ", p.mensajes[idx].valor
END IF
END IF
END FOR
END IF
UPDATE cptb00041 SET trackid = p.trackid, estado_dgii = p.estado, mensaje = mensaje_trunc
WHERE cod_sp = pcod_sp AND cod_sp_sec = pcod_sp_sec AND num_doc = pnum_doc
IF UPSHIFT(p.estado) MATCHES "*RECHAZ*" THEN
CALL fgl_winmessage("COMPRA ELECTRONICA RECHAZADA POR LA DGII",
"e-NCF "||e41.ncf41 CLIPPED||"\n\nMotivo: "||NVL(mensaje_trunc,"(sin mensaje)"),"stop")
ELSE
CALL fgl_winmessage("COMPRA ELECTRONICA",
"e-NCF "||e41.ncf41 CLIPPED||"\nEstado DGII: "||p.estado||"\n"||NVL(mensaje_trunc,""),"info")
END IF
END FUNCTION
#-----------------------------------------------------------------------------
# e-CF 41 COMPRAS: la empresa le compra a una persona sin RNC / sin NCF.
# Diferencias con el 43:
# - Lleva bloque Comprador = datos del PROVEEDOR (cedula y nombre),
# se pasan en documento_encabezado.rncComprador / razonSocialComprador.
# - Puede llevar ITBIS (IndicadorFacturacion 1/2/3 por linea, 4 = exento).
# - Lleva retenciones por linea y totales (ITBIS retenido e ISR retenido).
# ret41 va alineado por indice con documento_Detalle (linea k <-> ret41[k]).
# Los totales gravado/exento/ITBIS se toman de documento_encabezado tal como
# cpprmt006 ya los llena para generafile. MontoTotal = antes de retenciones.
# Confirmar orden/obligatoriedad de tags contra el XSD e-CF 41 en TesteCF.
#-----------------------------------------------------------------------------
FUNCTION generafile41(documento_encabezado, documento_Detalle, ret41, xsucid, xbodega, xoperacion)
DEFINE documento_encabezado RECORD
tipoEcf, eNcf, indicadorMontoGravado, tipoPago, fechaLimitePago, FormadePAgo, montoPago, FechaVencimientoSecuencia,
rncEmisor, razonSocialEmisor, direccionEmisor, Municipio, Provincia, telefonoEmisor,
correoEmisor, webSite, codigoVendedor, numeroFacturaInterna, numeroPedidoInterno,
fechaEmision, rncComprador, razonSocialComprador, montoGravadoTotal, montoGravadoI1,
montoGravadoI2, montoGravadoI3, montoExento, itbis1, itbis2, itbis3, totalItbis, totalItbis1,
totalItbis2, totalItbis3, montoTotal, tipoIngreso, terminoPago, TipoCuentaPago, NumeroCuentaPago, IdentificadorExtranjero,
contactoComprador, CorreoComprador, DireccionComprador, MunicipioComprador, ProvinciaComprador, FechaEntrega, FechaOrdenCompra,
NumeroOrdenCompra, CodigoInternoComprador,
nombreFile, IndicadorNotaCredito, NCFmodificado, codigoModificacion, fechaNCFmodificado STRING
END RECORD,
documento_Detalle DYNAMIC ARRAY OF RECORD
indicadorFacturacion, nombreItem, indicadorBienoServicio, cantidadItem, precioUnitarioItem,
montoItem STRING,
DescripcionItem VARCHAR(1000),
NumeroLinea INT
END RECORD,
ret41 DYNAMIC ARRAY OF RECORD
itbisRetenido DECIMAL(12,2),
isrRetenido DECIMAL(12,2)
END RECORD,
xoperacion VARCHAR(30),
xsucid, xbodega INT
DEFINE archivo, respuesta, codigo, phash, chFirma STRING,
a om.SaxAttributes,
fechaFirma DATETIME YEAR TO SECOND,
k, linea INTEGER,
itbisRet, isrRet, totItbisRet, totIsrRet DECIMAL(14,2),
xamb STRING
-- En el 41 el proveedor (cedula y nombre) es obligatorio
IF documento_encabezado.rncComprador IS NULL
OR documento_encabezado.razonSocialComprador IS NULL THEN
RETURN NULL, "El 41 requiere cedula y nombre del proveedor", NULL, "0"
END IF
LET archivo = fgl_getenv("RUTA_XML_ORIGINALES"), documento_encabezado.nombreFile
TRY
LET wcp = om.XmlWriter.createFileWriter(archivo)
CATCH
RETURN NULL, "No se pudo crear el XML del 41 (RUTA_XML_ORIGINALES)", NULL, "0"
END TRY
IF wcp IS NULL THEN
RETURN NULL, "No se pudo crear el XML del 41 (RUTA_XML_ORIGINALES)", NULL, "0"
END IF
LET a = om.SaxAttributes.create()
CALL wcp.startDocument()
CALL a.addAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema")
CALL wcp.startElement("ECF", a)
CALL a.clear()
#-------------------- Encabezado --------------------
CALL wcp.startElement("Encabezado", NULL)
CALL tagcp("Version", "1.0")
-- IdDoc (el 41 NO lleva TipoIngresos)
CALL wcp.startElement("IdDoc", NULL)
CALL tagcp("TipoeCF", "41")
CALL tagcp("eNCF", documento_encabezado.eNcf CLIPPED)
IF documento_encabezado.FechaVencimientoSecuencia IS NOT NULL THEN
CALL tagcp("FechaVencimientoSecuencia", documento_encabezado.FechaVencimientoSecuencia)
END IF
IF montocp(documento_encabezado.montoGravadoTotal) > 0 THEN
CALL tagcp("IndicadorMontoGravado", NVL(documento_encabezado.indicadorMontoGravado, "0"))
END IF
CALL tagcp("TipoPago", NVL(documento_encabezado.tipoPago, "1"))
IF documento_encabezado.tipoPago = "2" AND documento_encabezado.fechaLimitePago IS NOT NULL THEN
CALL tagcp("FechaLimitePago", documento_encabezado.fechaLimitePago)
END IF
CALL wcp.startElement("TablaFormasPago", NULL)
CALL wcp.startElement("FormaDePago", NULL)
CALL tagcp("FormaPago", NVL(documento_encabezado.FormadePAgo, "1"))
CALL tagcp("MontoPago", documento_encabezado.montoTotal)
CALL wcp.endElement("FormaDePago")
CALL wcp.endElement("TablaFormasPago")
CALL wcp.endElement("IdDoc")
-- Emisor (igual que el 43)
CALL wcp.startElement("Emisor", NULL)
CALL tagcp("RNCEmisor", documento_encabezado.rncEmisor)
CALL tagcp("RazonSocialEmisor", cortacp(documento_encabezado.razonSocialEmisor, 150))
CALL tagcp("NombreComercial", cortacp(documento_encabezado.razonSocialEmisor, 150))
CALL tagcp("DireccionEmisor", cortacp(documento_encabezado.direccionEmisor, 100))
IF codigo6cp(documento_encabezado.Municipio) IS NOT NULL THEN
CALL tagcp("Municipio", codigo6cp(documento_encabezado.Municipio))
END IF
IF codigo6cp(documento_encabezado.Provincia) IS NOT NULL THEN
CALL tagcp("Provincia", codigo6cp(documento_encabezado.Provincia))
END IF
IF documento_encabezado.correoEmisor IS NOT NULL THEN
CALL tagcp("CorreoEmisor", documento_encabezado.correoEmisor)
END IF
IF documento_encabezado.numeroFacturaInterna IS NOT NULL THEN
CALL tagcp("NumeroFacturaInterna", documento_encabezado.numeroFacturaInterna)
END IF
CALL tagcp("FechaEmision", documento_encabezado.fechaEmision)
CALL wcp.endElement("Emisor")
-- Comprador = el PROVEEDOR al que se le compra
CALL wcp.startElement("Comprador", NULL)
CALL tagcp("RNCComprador", documento_encabezado.rncComprador CLIPPED)
CALL tagcp("RazonSocialComprador", cortacp(documento_encabezado.razonSocialComprador, 150))
CALL wcp.endElement("Comprador")
-- Totales de retencion (se suman de las lineas que se van a enviar)
LET totItbisRet = 0
LET totIsrRet = 0
FOR k = 1 TO documento_Detalle.getLength()
IF documento_Detalle[k].nombreItem IS NULL
AND documento_Detalle[k].DescripcionItem IS NULL THEN
CONTINUE FOR
END IF
IF k <= ret41.getLength() THEN
LET totItbisRet = totItbisRet + NVL(ret41[k].itbisRetenido, 0)
LET totIsrRet = totIsrRet + NVL(ret41[k].isrRetenido, 0)
END IF
END FOR
-- Totales (solo se escriben los montos que aplican)
CALL wcp.startElement("Totales", NULL)
CALL tagcpmonto("MontoGravadoTotal", documento_encabezado.montoGravadoTotal)
CALL tagcpmonto("MontoGravadoI1", documento_encabezado.montoGravadoI1)
CALL tagcpmonto("MontoGravadoI2", documento_encabezado.montoGravadoI2)
CALL tagcpmonto("MontoGravadoI3", documento_encabezado.montoGravadoI3)
CALL tagcpmonto("MontoExento", documento_encabezado.montoExento)
IF montocp(documento_encabezado.montoGravadoI1) > 0 THEN
CALL tagcp("ITBIS1", NVL(documento_encabezado.itbis1, "18"))
END IF
IF montocp(documento_encabezado.montoGravadoI2) > 0 THEN
CALL tagcp("ITBIS2", NVL(documento_encabezado.itbis2, "16"))
END IF
IF montocp(documento_encabezado.montoGravadoI3) > 0 THEN
CALL tagcp("ITBIS3", "0")
END IF
IF montocp(documento_encabezado.montoGravadoTotal) > 0 THEN
CALL tagcp("TotalITBIS", NVL(documento_encabezado.totalItbis, "0.00"))
CALL tagcpmonto("TotalITBIS1", documento_encabezado.totalItbis1)
CALL tagcpmonto("TotalITBIS2", documento_encabezado.totalItbis2)
IF montocp(documento_encabezado.montoGravadoI3) > 0 THEN
CALL tagcp("TotalITBIS3", "0.00")
END IF
END IF
CALL tagcp("MontoTotal", documento_encabezado.montoTotal)
CALL tagcp("TotalITBISRetenido", totItbisRet USING "<<<<<<<<<<<<&.&&")
CALL tagcp("TotalISRRetencion", totIsrRet USING "<<<<<<<<<<<<&.&&")
CALL wcp.endElement("Totales")
CALL wcp.endElement("Encabezado")
#-------------------- DetallesItems --------------------
CALL wcp.startElement("DetallesItems", NULL)
LET linea = 0
FOR k = 1 TO documento_Detalle.getLength()
IF documento_Detalle[k].nombreItem IS NULL
AND documento_Detalle[k].DescripcionItem IS NULL THEN
CONTINUE FOR
END IF
LET linea = linea + 1
LET itbisRet = 0
LET isrRet = 0
IF k <= ret41.getLength() THEN
LET itbisRet = NVL(ret41[k].itbisRetenido, 0)
LET isrRet = NVL(ret41[k].isrRetenido, 0)
END IF
CALL wcp.startElement("Item", NULL)
CALL tagcp("NumeroLinea", linea USING "<<<<")
CALL tagcp("IndicadorFacturacion", NVL(documento_Detalle[k].indicadorFacturacion, "4"))
-- Retencion: en el 41 la empresa actua como agente de retencion
CALL wcp.startElement("Retencion", NULL)
CALL tagcp("IndicadorAgenteRetencionoPercepcion", "1")
CALL tagcp("MontoITBISRetenido", itbisRet USING "<<<<<<<<<<<<&.&&")
CALL tagcp("MontoISRRetenido", isrRet USING "<<<<<<<<<<<<&.&&")
CALL wcp.endElement("Retencion")
CALL tagcp("NombreItem",
NVL(documento_Detalle[k].nombreItem, documento_Detalle[k].DescripcionItem))
CALL tagcp("IndicadorBienoServicio", NVL(documento_Detalle[k].indicadorBienoServicio, "2"))
CALL tagcp("CantidadItem", NVL(documento_Detalle[k].cantidadItem, "1"))
CALL tagcp("PrecioUnitarioItem", documento_Detalle[k].precioUnitarioItem)
CALL tagcp("MontoItem", documento_Detalle[k].montoItem)
CALL wcp.endElement("Item")
END FOR
CALL wcp.endElement("DetallesItems")
#-------------------- Firma --------------------
LET fechaFirma = CURRENT
LET chFirma = util.Datetime.format(fechaFirma, "%d-%m-%Y %H:%M:%S")
CALL tagcp("FechaHoraFirma", chFirma)
CALL wcp.endElement("ECF")
CALL wcp.endDocument()
#-------------------- Firmar y enviar (igual que el 43) --------------------
-- ambiente DGII de la empresa (companias.ambienteDgii, funcion ambiente())
LET xamb = ambiente()
LET xamb = xamb.trim()
IF xamb IS NULL OR (xamb <> "test" AND xamb <> "certificacion" AND xamb <> "produccion") THEN
RETURN NULL, "companias.ambienteDgii debe ser test, certificacion o produccion. No se envio a la DGII.", fechaFirma, "0"
END IF
CALL procesoEncf(archivo, xamb, "normal", xsucid, xbodega, xoperacion, ' ')
RETURNING phash, respuesta, codigo
RETURN phash, respuesta, fechaFirma, codigo
END FUNCTION
#-----------------------------------------------------------------------------
# Convierte un monto STRING a decimal (NULL o vacio = 0)
FUNCTION montocp(valor STRING) RETURNS DECIMAL(14,2)
DEFINE n DECIMAL(14,2)
LET n = NULL
TRY
LET n = valor
CATCH
LET n = NULL
END TRY
RETURN NVL(n, 0)
END FUNCTION
#-----------------------------------------------------------------------------
# Recorta un texto al largo maximo que permite el XSD
FUNCTION cortacp(valor STRING, largo INTEGER) RETURNS STRING
LET valor = valor.trim()
IF valor.getLength() > largo THEN
LET valor = valor.subString(1, largo)
END IF
RETURN valor.trim()
END FUNCTION
#-----------------------------------------------------------------------------
# Provincia / Municipio DGII: codigo de 6 digitos con ceros a la izquierda
# (10100 -> 010100). NULL o 0 = no se envia.
FUNCTION codigo6cp(valor STRING) RETURNS STRING
DEFINE n INTEGER
LET n = NULL
TRY
LET n = valor
CATCH
LET n = NULL
END TRY
IF n IS NULL OR n = 0 THEN
RETURN NULL
END IF
RETURN n USING "&&&&&&"
END FUNCTION
#-----------------------------------------------------------------------------
# Escribe el tag solo si el monto es mayor que cero
FUNCTION tagcpmonto(nombre STRING, valor STRING)
IF montocp(valor) > 0 THEN
CALL tagcp(nombre, valor)
END IF
END FUNCTION
#-----------------------------------------------------------------------------
FUNCTION tagcp(nombre STRING, valor STRING)
CALL wcp.startElement(nombre, NULL)
CALL wcp.characters(valor)
CALL wcp.endElement(nombre)
END FUNCTION
+440 -440
View File
@@ -105,443 +105,443 @@ codigo21,35992
codigos,36089
codigos22,36182
companias,36283
correos,36838
cotb00001,36938
cotb00002,37473
cotb00003,37756
cotb00004,37941
cotb00005,38258
cotb00006,38472
cotb00008,38848
cotb00010,39342
cotb00011,39394
cotb00012,39871
cotb00013,40236
cotb00014,40574
cotb00015,41333
cotb00017,41818
cotb00018,42155
cotb00019,42348
cotb00022,42618
cotb00024,42820
cotb00025,43035
cotb00027,43510
cotb00028,43700
cotb00029,43721
cotb00030,44319
cotb00031,44473
cotb00033,44713
cotb00034,45282
cotb00036,45698
cotb00038,45888
cotizacion,46306
cotizacion_detalle,47153
country,47753
cptb00001,47798
cptb00002,48304
cptb00003,48588
cptb00005,49040
cptb00006,49492
cptb00007,49945
cttb00001,50046
cttb00002,50319
cttb00003,50493
cttb00004,51089
cttb00006,51167
cttb00007,51501
cttb00008,51692
cttb00009,52027
cttb00010,52374
cttb00011,52584
cttb00012,52870
cttb00013,53233
cttb00014,53653
cttb00015,53878
cttb00016,54181
cttb00017,54257
cttb00018,54847
cttb00021,55030
cttb00022,55231
cttb00023,55518
cttb00026,55811
cttb00027,56066
cttb00028,56212
cttb00029,56547
cttb00032,56782
cttb00033,57573
cttb00034,57703
cttb00036,57939
cttb00038,58305
cttb00039,58570
cttb00041,58690
cttb00042,58976
cttb000log1,59214
cttb000log2,59327
dbocodigos20,59809
dgii_rnc,59901
dgii_rnc3,60228
diatable,60460
dstb00001,60509
dstb00002,60936
dstb00003,61224
dstb00004,61412
dstb00005,61642
empleados,62048
emventas,62756
inrp00002,62862
intb00001,63111
intb00002,63465
intb00003,63933
intb00004,64327
intb00005,64721
intb00006,65038
intb00007,65796
intb00008,66003
intb00009,66372
intb00010,66471
intb00011,66562
intb00012,66961
intb00013,67369
intb00014,67732
intb00015,68034
intb00018,68405
intb00019,68872
intb00020,69384
intb00022,70239
intb00023,70657
intb00026,70837
intb00040,71172
intb00041,71532
intb00042,71916
intb00043,72263
intb00043_,72388
intb00043a,72509
intb00044,72633
inventory,72786
iptb00001,72836
iptb00002,73164
iptb00003,73905
iptb00004,74166
iptb00005,74589
iptb00006,75074
iptb00007,76109
iptb00008,76315
iptb00010,77097
iptb00011,77530
iptb00012,77929
iptb00013,78423
iptb00014,78653
iptb00015,78966
iptb00017,79053
iptb00019,79831
iptb00020,80014
iptb00021,80248
iptb00022,80432
iptb00024,80646
iptb00025,80873
iptb00026,81379
iptb00027,81483
iptb00028,81584
iptb00029,81709
iptb00030,81904
iptb00031,82097
iptb00032,82152
iptb00033,82234
iptb00034,83084
iptb00040,83477
iptb00041,83837
iptb00042,84221
iptb00043,84568
iptb00044,84619
iptb00045,84892
iptb00046,84980
iptb00047,85066
iptb00048,85150
iptb00049,85204
iptb025,85609
iptbexistencia,86028
ircodigos,86305
irtb00001,86430
irtb00002,86760
irtb00005,87236
irtb00006,87553
irtb00007,88247
irtb00008,88730
irtb00009,89241
irtb00010,89550
irtb00011,89743
irtb00012,90146
irtb00013,90556
irtb00014,90913
irtb00016,91094
irtb00017,91396
irtb00018,91767
irtb00027,91819
irtb00029,92264
irtb00030,92461
irtb00040,92656
irtb00041,93016
irtb00042,93400
istb00002,93747
istb00005,94316
istb00006,94619
istb00013,95303
item,95648
lajas,95881
lajas14,95966
lajas2,96059
lajas2_,96148
lineitem,96241
listaprecio,96377
localizacion,96648
mallas9,96743
marzo_,96836
mestable,96917
molduras23,97111
msgtable,97219
nc,97367
notb00001,97852
notb00002,97932
notb00003,98498
notb00005,98823
notb00006,99034
notb00007,99374
notb00008,99801
notb00009,100232
notb00010,100440
notb00011,100813
notb00012,101185
notb00013,101334
notb00014,101514
notb00015,101591
notb00016,101967
notb00017,102398
notb00018,102555
notb00019,102743
notb00020,102986
notb00021,103336
notb00023,103579
notb00033,103972
notb0019,104623
notb03,104857
notbcuenta,105146
notbingresos,105228
ntb00005,105285
oportunidades,105591
orders,106195
orderstatus,106850
pda5,106966
permisos,107370
prdtable,107484
precios,107757
preciosc,107969
product,108092
prordenlog,108220
prordenstatus,108525
prtb00001,108724
prtb00002,108817
prtb00003,109104
prtb00004,109394
prtb00005,109548
prtb00006,109730
prtb00007,110017
prtb00008,110484
prtb00009,110751
prtb00010,111024
prtb00011,111370
prtb00012,111688
prtb00013,112571
prtb00014,113246
prtb00015,113439
prtb00016,113716
prtb00017,113902
prtb00018,114124
prtb00019,114431
prtb00020,114557
prtb00021,114634
prtb00022,115276
prtb00023,115755
prtb00024,116014
prtb00025,116064
prtb00026,116338
prtb00027,116721
prtb00028,116907
prtb00029,117164
prtb00031,117484
prtb00032,117821
prttb00001,117950
prttb00002,118107
ptordenesgral,118188
ptventasgral,119500
ptventasgralh,121355
query,123177
ranking,123544
repitecodigo,123858
repitecodigotmp,124040
seg0000,124105
seg0001,124448
seg0003,125087
seg0004,125412
seg0005,125511
seg0006,125682
seg0007,125758
seg0008,125864
seqreg,125914
sheet1_,125963
signon,126428
sucursales,126478
supplier,126835
svtb00001,127041
svtb00002,128192
svtb00003,128314
svtb00004,128567
svtb00005,129235
svtb00006,129641
svtb00007,129728
tetb00003,129865
tetb00006,130087
tmp2iptb00012,130291
tmp3iptb00012,130857
tmp_kit,131423
tmpactualiza,131668
tmpaumento,131884
tmpcam,132014
tmpcctb01,132139
tmpclase,132787
tmpclase1,132840
tmpclasificacion,132900
tmpclientes,133134
tmpcod11,133557
tmpcod12,133624
tmpcodigorepetido,133691
tmpcodigos,133889
tmpcodigos1,133994
tmpcodsec,134181
tmpcostos,134235
tmpcostos1,134558
tmpcostosferia,134741
tmpdetallefact,135038
tmpduplicados,135301
tmpempresas,135478
tmpexcel,135807
tmpfacturas,135864
tmpfempleados,136272
tmpferia2,136421
tmpferia3,136668
tmpferia5,136877
tmpgrupo,137049
tmpinventario,137106
tmpinventariofisico,137423
tmpinvm,137825
tmpiptb00002,138107
tmpiptb00006,139069
tmpiptb00012,139985
tmpiptb00027,140533
tmpiptb012,140646
tmpmatprima,141158
tmpmedida,141295
tmpofertas,141352
tmpordenes,141509
tmpplanchas,141640
tmppreciosferia,141830
tmppreciosg1,142169
tmppreciosg2,142404
tmppreciosm1,142639
tmppreciosm2,142872
tmpproductos,143105
tmptipo,143252
tmptipocuentas,143306
tmpventas,143429
tmpventas43,143541
tmpvetb00002,143794
tmpvetb00003,144769
travertino,145221
userinfo,145352
usuarios,146442
vacaciones,146528
ventas,146908
vetb00001,147523
vetb00002,147707
vetb00003,148760
vetb00004,149240
vetb00005,149932
vetb00006,150270
vetb00007,150801
vetb00008,151015
vetb00009,151197
vetb00010,151382
vetb00011,151633
vetb00012,151982
vetb00013,152215
vetb00014,152681
vetb00015,153044
vetb00016,153500
vetb00018,153728
vetb00019,153930
vetb00020,154243
vetb00022,154470
vetb00023,154960
vetb00024,155207
vetb00025,155663
vetb00025b,156167
vetb00025c,156613
vetb00026,157059
vetb00027,157112
vetb00028,157546
vetb00029,157807
vetb00030,158202
vetb00031,158423
vetb00042,158698
vetb00044,159004
vetb00045,159307
vetb00048,159703
vetb00049,159885
vetb00050,160146
vetb00051,161450
vetb00052,162236
vetb00053,162697
vetb00060,162755
vetb00061,163058
vetb00071,163235
vetb00072,163580
vetb00075,163741
vetb00076,163861
vetb00084,164048
vetb00085,164099
vetb00086,164382
vetb00087,164590
vetb00088,165016
vetb00090,165302
vetb00091,165478
vetb00092,165982
vetb00093,166350
vetb00094,166522
vetb00095,166768
vetb00096,167075
viejo1,167173
vwanalisisventas,167347
vwanalitico,168187
vwanaliticoh,168917
vwclientesnocompran,169677
vwcobros,170013
vwcodigosnuevos,170561
vwcomisiones,171218
vwcompras,172308
vwconduces,172772
vwcontactosclientes,173454
vwdevoluciones,173695
vwestado,174488
vwestadoordenes,174655
vwipconteopda,175475
vwipprodterm,175953
vwmatprima,176727
vwprecios,177423
vwproduccion,177680
vwproduccionf,178510
vwproductos,179717
vwprovincias,180099
vwrepuestos,180921
vwseguimientoclientes,181622
vwvacaciones,183105
vwventas,184002
vwventasvendedor,185421
correos,36872
cotb00001,36972
cotb00002,37507
cotb00003,37790
cotb00004,37975
cotb00005,38292
cotb00006,38506
cotb00008,38882
cotb00010,39376
cotb00011,39428
cotb00012,39905
cotb00013,40270
cotb00014,40608
cotb00015,41367
cotb00017,41852
cotb00018,42189
cotb00019,42382
cotb00022,42652
cotb00024,42854
cotb00025,43069
cotb00027,43544
cotb00028,43734
cotb00029,43755
cotb00030,44353
cotb00031,44507
cotb00033,44747
cotb00034,45316
cotb00036,45732
cotb00038,45922
cotizacion,46340
cotizacion_detalle,47187
country,47787
cptb00001,47832
cptb00002,48338
cptb00003,48622
cptb00005,49074
cptb00006,49526
cptb00007,49979
cttb00001,50080
cttb00002,50353
cttb00003,50527
cttb00004,51123
cttb00006,51201
cttb00007,51535
cttb00008,51726
cttb00009,52061
cttb00010,52408
cttb00011,52618
cttb00012,52904
cttb00013,53267
cttb00014,53687
cttb00015,53912
cttb00016,54215
cttb00017,54291
cttb00018,54881
cttb00021,55064
cttb00022,55265
cttb00023,55552
cttb00026,55845
cttb00027,56100
cttb00028,56246
cttb00029,56581
cttb00032,56816
cttb00033,57607
cttb00034,57737
cttb00036,57973
cttb00038,58339
cttb00039,58604
cttb00041,58724
cttb00042,59010
cttb000log1,59248
cttb000log2,59361
dbocodigos20,59843
dgii_rnc,59935
dgii_rnc3,60262
diatable,60494
dstb00001,60543
dstb00002,60970
dstb00003,61258
dstb00004,61446
dstb00005,61676
empleados,62082
emventas,62790
inrp00002,62896
intb00001,63145
intb00002,63499
intb00003,63967
intb00004,64361
intb00005,64755
intb00006,65072
intb00007,65830
intb00008,66037
intb00009,66406
intb00010,66505
intb00011,66596
intb00012,66995
intb00013,67403
intb00014,67766
intb00015,68068
intb00018,68439
intb00019,68906
intb00020,69418
intb00022,70273
intb00023,70691
intb00026,70871
intb00040,71206
intb00041,71566
intb00042,71950
intb00043,72297
intb00043_,72422
intb00043a,72543
intb00044,72667
inventory,72820
iptb00001,72870
iptb00002,73198
iptb00003,73939
iptb00004,74200
iptb00005,74623
iptb00006,75108
iptb00007,76143
iptb00008,76349
iptb00010,77131
iptb00011,77564
iptb00012,77963
iptb00013,78457
iptb00014,78687
iptb00015,79000
iptb00017,79087
iptb00019,79865
iptb00020,80048
iptb00021,80282
iptb00022,80466
iptb00024,80680
iptb00025,80907
iptb00026,81413
iptb00027,81517
iptb00028,81618
iptb00029,81743
iptb00030,81938
iptb00031,82131
iptb00032,82186
iptb00033,82268
iptb00034,83118
iptb00040,83511
iptb00041,83871
iptb00042,84255
iptb00043,84602
iptb00044,84653
iptb00045,84926
iptb00046,85014
iptb00047,85100
iptb00048,85184
iptb00049,85238
iptb025,85643
iptbexistencia,86062
ircodigos,86339
irtb00001,86464
irtb00002,86794
irtb00005,87270
irtb00006,87587
irtb00007,88281
irtb00008,88764
irtb00009,89275
irtb00010,89584
irtb00011,89777
irtb00012,90180
irtb00013,90590
irtb00014,90947
irtb00016,91128
irtb00017,91430
irtb00018,91801
irtb00027,91853
irtb00029,92298
irtb00030,92495
irtb00040,92690
irtb00041,93050
irtb00042,93434
istb00002,93781
istb00005,94350
istb00006,94653
istb00013,95337
item,95682
lajas,95915
lajas14,96000
lajas2,96093
lajas2_,96182
lineitem,96275
listaprecio,96411
localizacion,96682
mallas9,96777
marzo_,96870
mestable,96951
molduras23,97145
msgtable,97253
nc,97401
notb00001,97886
notb00002,97966
notb00003,98532
notb00005,98857
notb00006,99068
notb00007,99408
notb00008,99835
notb00009,100266
notb00010,100474
notb00011,100847
notb00012,101219
notb00013,101368
notb00014,101548
notb00015,101625
notb00016,102001
notb00017,102432
notb00018,102589
notb00019,102777
notb00020,103020
notb00021,103370
notb00023,103613
notb00033,104006
notb0019,104657
notb03,104891
notbcuenta,105180
notbingresos,105262
ntb00005,105319
oportunidades,105625
orders,106229
orderstatus,106884
pda5,107000
permisos,107404
prdtable,107518
precios,107791
preciosc,108003
product,108126
prordenlog,108254
prordenstatus,108559
prtb00001,108758
prtb00002,108851
prtb00003,109138
prtb00004,109428
prtb00005,109582
prtb00006,109764
prtb00007,110051
prtb00008,110518
prtb00009,110785
prtb00010,111058
prtb00011,111404
prtb00012,111722
prtb00013,112605
prtb00014,113280
prtb00015,113473
prtb00016,113750
prtb00017,113936
prtb00018,114158
prtb00019,114465
prtb00020,114591
prtb00021,114668
prtb00022,115310
prtb00023,115789
prtb00024,116048
prtb00025,116098
prtb00026,116372
prtb00027,116755
prtb00028,116941
prtb00029,117198
prtb00031,117518
prtb00032,117855
prttb00001,117984
prttb00002,118141
ptordenesgral,118222
ptventasgral,119534
ptventasgralh,121389
query,123211
ranking,123578
repitecodigo,123892
repitecodigotmp,124074
seg0000,124139
seg0001,124482
seg0003,125121
seg0004,125446
seg0005,125545
seg0006,125716
seg0007,125792
seg0008,125898
seqreg,125948
sheet1_,125997
signon,126462
sucursales,126512
supplier,126869
svtb00001,127075
svtb00002,128226
svtb00003,128348
svtb00004,128601
svtb00005,129269
svtb00006,129675
svtb00007,129762
tetb00003,129899
tetb00006,130121
tmp2iptb00012,130325
tmp3iptb00012,130891
tmp_kit,131457
tmpactualiza,131702
tmpaumento,131918
tmpcam,132048
tmpcctb01,132173
tmpclase,132821
tmpclase1,132874
tmpclasificacion,132934
tmpclientes,133168
tmpcod11,133591
tmpcod12,133658
tmpcodigorepetido,133725
tmpcodigos,133923
tmpcodigos1,134028
tmpcodsec,134215
tmpcostos,134269
tmpcostos1,134592
tmpcostosferia,134775
tmpdetallefact,135072
tmpduplicados,135335
tmpempresas,135512
tmpexcel,135841
tmpfacturas,135898
tmpfempleados,136306
tmpferia2,136455
tmpferia3,136702
tmpferia5,136911
tmpgrupo,137083
tmpinventario,137140
tmpinventariofisico,137457
tmpinvm,137859
tmpiptb00002,138141
tmpiptb00006,139103
tmpiptb00012,140019
tmpiptb00027,140567
tmpiptb012,140680
tmpmatprima,141192
tmpmedida,141329
tmpofertas,141386
tmpordenes,141543
tmpplanchas,141674
tmppreciosferia,141864
tmppreciosg1,142203
tmppreciosg2,142438
tmppreciosm1,142673
tmppreciosm2,142906
tmpproductos,143139
tmptipo,143286
tmptipocuentas,143340
tmpventas,143463
tmpventas43,143575
tmpvetb00002,143828
tmpvetb00003,144803
travertino,145255
userinfo,145386
usuarios,146476
vacaciones,146562
ventas,146942
vetb00001,147557
vetb00002,147741
vetb00003,148794
vetb00004,149274
vetb00005,149966
vetb00006,150304
vetb00007,150835
vetb00008,151049
vetb00009,151231
vetb00010,151416
vetb00011,151667
vetb00012,152016
vetb00013,152249
vetb00014,152715
vetb00015,153078
vetb00016,153534
vetb00018,153762
vetb00019,153964
vetb00020,154277
vetb00022,154504
vetb00023,154994
vetb00024,155241
vetb00025,155697
vetb00025b,156201
vetb00025c,156647
vetb00026,157093
vetb00027,157146
vetb00028,157580
vetb00029,157841
vetb00030,158236
vetb00031,158457
vetb00042,158732
vetb00044,159038
vetb00045,159341
vetb00048,159737
vetb00049,159919
vetb00050,160180
vetb00051,161484
vetb00052,162270
vetb00053,162731
vetb00060,162789
vetb00061,163092
vetb00071,163269
vetb00072,163614
vetb00075,163775
vetb00076,163895
vetb00084,164082
vetb00085,164133
vetb00086,164416
vetb00087,164624
vetb00088,165050
vetb00090,165336
vetb00091,165512
vetb00092,166016
vetb00093,166384
vetb00094,166556
vetb00095,166802
vetb00096,167109
viejo1,167207
vwanalisisventas,167381
vwanalitico,168221
vwanaliticoh,168951
vwclientesnocompran,169711
vwcobros,170047
vwcodigosnuevos,170595
vwcomisiones,171252
vwcompras,172342
vwconduces,172806
vwcontactosclientes,173488
vwdevoluciones,173729
vwestado,174522
vwestadoordenes,174689
vwipconteopda,175509
vwipprodterm,175987
vwmatprima,176761
vwprecios,177457
vwproduccion,177714
vwproduccionf,178544
vwproductos,179751
vwprovincias,180133
vwrepuestos,180955
vwseguimientoclientes,181656
vwvacaciones,183139
vwventas,184036
vwventasvendedor,185455