This source code concentrates the features related to the building of the aGrava Array focused on the configurations made through the routine of the tax configuration tool for later recording in the CDA and/or CDV table
Important
The fields below in the CDA and CDV are exclusive for operations with entry adjustment code performed by the Tax Configuration Tool.
The structure is in the package 010120 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livros Fiscais - Configurador/Codigo de Ajuste SPED/Dicionario
The structure is in the package 010650 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livros Fiscais - Configurador/Codigo de Ajuste SPED/Dicionario
Located in the Innovation branch: $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livros Fiscais - Configurador/Codigo de Ajuste SPED
cCodLan := Alltrim(aCodLan[nI][2]) //CJA_CODLAN
nBasCal := aTribgen[nX][TG_IT_BASE] //CJA_NFBASE
nAlqCal := aTribgen[nX][TG_IT_ALIQUOTA] //CJA_NFALIQ
cTpLanc := Iif(Alltrim(aCodLan[nI][7]) <> "03","2","1") //Treatment made for the correct recording of IPI Entries.
cRegCalc := aCodLan[nI][1] //cRegCal
cCodVal := Left(aCodLan[nI][5],3) //CJA_VALOR
cCodValOu := Left(aCodLan[nI][6],3) //CJA_VLOUTR
cOpBase := aCodLan[nI][3]
cOpAliq := aCodLan[nI][4]
cCFOP := aNfItem[nZ][IT_CF]
cDescod := aCodLan[nI][12]
cLivro := aNFItem[nZ][IT_TS][TS_NRLIVRO]
cCodDes := aCodLan[nI][11] //CJA_TXTDSC
cCodObs := aCodLan[nI][10] //CJA_CODCPL
cCodOLan := aCodLan[nI][09] //CJA_CODMSG
cGeracum := aCodLan[nI][12] //CJA_GERMSG
CCMPOrig := Pertence(1,2,3,4) //conditional treatment according to the contents of the array *aCodLan [nl][7] considering the dynamics for IPI calculation. After the above treatment, the aGrava array has this configuration:
aAdd(aGrava, {;
cItem,; //1 - Item
cCodLan,; //2 - Entry Code
"1",; //3 - System
nBasCal,; //4 - Calculation Base
nAlqCal,; //5 - Rate
nValor,; //6 - Value Calculated
cSeq,; //7 - Sequence
cIFCOMP,; //8 - Complementary Information
cTpLanc,; //9 - Type of Entry Utility
"",; //10- Value recording in ICMS or OTHER
cCmp0460,; //11-Complement for Record 0460
cCodRefl,; //12-Reflex Code
cGeraGNRE,; //13 - Generate GNRE
cCMPOrig,; //14 - CC7 Source Field
cCFOP,; //15 - CFOP
cLivro,; //16 - Record
cDescod,; //17 - Code Description
cCodDes,; //18 - Block 0460 message description
cCodObs,; //19 - Block X195 message description
cCodOLan,; //20 - Block X197 message description
nValOut,; //21 - ICMS Other value
cRegCalc,; //22 - Calculation Rule Code
cOpBase,; //23 - Calculation Base Choice Option
cOpAliq,; //24 - Rate Choice Option
cGerAcum }) //25 - Indicate whether to generate how records will be grouped.
3. ExecCja Function - Field protection control.
---------------------------------------------------------------------------------------------------------------------------
A new option has been added to the Configuration Tool Tree.
This concentrates the Tree Menu, load routines, and Browser of the routines used in the tax configuration tool.
Located in the Innovation Branch: $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configuration Tool/SPED Adjustment Code
GetVerRls - Access Control to Improvements by Release.
Added the totvs.protheus.backoffice.fiscal.relatorioEstornocredito reversal conference report to Tree, in the Reports tab.
CJ8 – Messages File
CJ9 - Adjustment Rules File
CJA -Adjustment Rule Entry Codes
---------------------------------------------------------------------------------------------------------------------------
New functions have been added to the Entry Adjustment Codes File:
GravaGNRE - records the Collection Form in table SF6 according to the settings made in the Tax Configuration Tool.
DelGuia - Deletes the Collection Form from table SF6 generated by the tax configuration tool.
DelTit - Performs the deletion of the Financial Bill from the table SE2 generated by the tax configuration tool.
---------------------------------------------------------------------------------------------------------------------------
Objective and scope
The purpose of this routine is to create a messages file based on the rules by Tax, Generic Tax, Invoice data, and files. Choosing one of these forms of registration allows you to select what should be entered into the formula of the message.
CJ8 with the header information, with the information of fields and filters for building the message;
The structure is in the package 010120 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livros Fiscais - Configurador/Codigo de Ajuste SPED/Dicionario
Located in the Innovation branch: $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livros Fiscais - Configurador/Codigo de Ajuste SPED
In field CJ8_TPREGR (Rule Type), selecting Taxes enables, in field CJ8_TRIFIL (Rule to be queried), the 3 spheres (State, Federal, and Municipal), and, by selecting one of the options for query, the field CJ8_REGTRA (Tax) is filters the query by Rule Type;
If Rule Type is equal to Generic Taxes, field CJ8_TBCONF (Generic Tax) is enabled with the query in table F2B (Tax Rules).
If, in field CJ8_TPREGR (Rule Type), you select Invoice Data, then, in field CJ8_TRIFIL (Rule to be queried), the options Invoice Header and Items' Data are enabled. By selecting one of the options, the field CJ8_CONSUL (Value to be Added to Formula) displays information such as Invoice Type, Operation Type, Item Number, Value of Goods, etc.
After selecting the previous information, you may add the content selected in field CJ8_CONSUL (Value to be Added to the Formula) to field CJ8_MENSG (Message Composition) by clicking the Add button. After the addition, just click Validate Message.
This field CJ8_TBCONF will be linked to the tax calculation rule in table F2B, Routine FISA160, in the F2B_RULE field.
This routine stores the message in a MEMO field with the NPI formula in which it will be converted at the time of invoice processing through the FISXDESCR routine, and stored in the CJL table.
---------------------------------------------------------------------------------------------------------------------------
Use this routine to register the Entry Adjustment Codes, linking it to a Tax Document Rule to be created by the user in accordance with its bookkeeping, hence stating the entry code information when the document is generated.
Thus, with this register, we unify:
CJ9 with the information of the Entry Adjustment Rule File header, where we have the fields:
CJA - Entry Rule - Items, where we will list which entry codes, calculation rule, validity, tab control, and messages will be used.
The structure is in the package 010120 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livros Fiscais - Configurador/Codigo de Ajuste SPED/Dicionário
The structure is in the package 010650 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livros Fiscais - Configurador/Codigo de Ajuste SPED/Dicionário
Located in the Innovation branch: $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livros Fiscais - Configurador/Codigo de Ajuste SPED
Creation of the screen in MVC with TAB structure (Folders), was structured in 2 models - MASTER and GRID.
---------------------------------------------------------------------------------------------------------------------------
Separate, in the calculation, the values from the tax configuration tool versus entries via TIO (Legacy).
The cSPFGLEG variable concatenates the CDA_CODLAN+CDA_IFCOMP fields to create a comparison "key" between what is released from the tax configurator versus entries via TIO (legacy).
A change is also made to aScan using the new array position for record comparison, resulting in the correct separation of records according to the source of the entry.
2. CkApurCDP function - This function has as one of the objectives to verify the previous calculation and also check manual entries of a possible reprocessing of the calculation, loading the information into the aDADIC array and then bringing it to the screen of the new calculation.
A change was made so that the entries coming from the tax configuration tool were not loaded into the aDADIC array in order to avoid duplication of the entry in the calculation, since the automatic records are redone with each new calculation.
3. ViewResumo function - A function responsible for displaying the grid with the calculation on the screen.
A treatment was made to present, in the column "Entry Type", the information "CONFIG" for the entries coming from the tax configuration tool, facilitating the visualization of the records.
4. LoadApur function - a function that loads the values to the aGetApur array to be displayed on the screen.
In this routine, a condition exists that works with the aCDAIPI array in which the RWaGetApur function is called, where the adjustment entry codes are checked again. In the initial scenario, calling this function regroups the contents of the aCDAIPI array, causing the above modifications to be voided.
To maintain the proposed changes, it was necessary to create a treatment so that the last parameter requested in the RWaGetApur function would carry the code "3" created especially to identify that the type of entry is from the tax configuration tool:
//Includes Calculation Settings loaded from CDA
If lUsaSped .And. lCmpPcLanc
For nX := 1 to len(aCDAIPI)
If SUBSTR(aCDAIPI[nX][6],4,6) == "CONFIG" //len(aCDAIPI[nX][6]) > 3
RWaGetApur(aCDAIPI[nX][2],aCDAIPI[nX][4],.T.,aCDAIPI[nX]
[3],aCDAIPI[nX][6],'3',"","3") //'1-AUTOMATICO','2-MANUAL', '3- CONFIG'
else
RWaGetApur(aCDAIPI[nX][2],aCDAIPI[nX][4],.T.,aCDAIPI[nX]
[3],aCDAIPI[nX][6],'3',"","1") //'1-AUTOMATICO','2-MANUAL
Endif
Next nX
Endif
Also, in parameter 5 of the RWaGetApur function call, the new position of the aCDAIPI array is used.
5. RWaGetApur function - a function that totals the values in the aGetApur array that will be displayed on the screen to the user.
A tractive was done in the nPosLinha variable to verify and compare the cTipoAj variable with the corresponding position of the array. With this change, it was possible to correctly total the records.
Since the content of parameter 5 of the RWaGetApur function that receives the IPI adjustment entry code was changed, an additional treatment was required using the SUBSTR() function.
For the tax configuration tool, the GerGuiTit() function call was added to generate the tabs and bills of the configuration tool. Some validations have also been changed so that the ICMS releases of the tax configuration tool were not loaded to the aDadIC array in order to avoid duplication of the entry in the calculation, since the automatic records are redone with each new calculation.
2. CkLancCDA function - This function checks for entries in the CDA table and generates the arrays according to each ICMS variation, so that, at the end, they are displayed correctly in the ICMS calculation columns.
A protection has been created in the function for previous entries and also a treatment for when content exists in the "Others" column.
In the aLanc array, a new position was created to store the information from the CDA_REGCAL field so that it can distinguish what is a configuration tool entry versus a legacy entry. With this information, it was possible to perform the segregation of the values of the entry codes in the calculation screen.The Arrays that were treated at the source are: aCDADifal, aCDAST, aCDAIC, and aCDADE (Special Debits).
3. LoadX3Apur function - Added the new fields from the CDA and CJA tables for routine protection.
---------------------------------------------------------------------------------------------------------------------------
The FISXAPURA source code deals with the processing of ICMS and IPI calculation information when the multithread is active in the client scenario.
Just as in the FISXAPUR source code, a new position was added to the aCDAIPI array on calls from it within the FISXAPURA source code.
Just as in the FISXAPUR source code, a new position was added to the aCDADifal, aCDAST, aCDAIC, and aCDADE arrays in its calls within the FISXAPURA source.
---------------------------------------------------------------------------------------------------------------------------
This source code aims to convert references from MATXFIS() and other functions into indexes to be used in tax document texts.
CJL - Decoded Message Control, where we will store the converted messages according to the relationship of the Entry Adjustment Code Rule (CJA) message codes.
Located in the Innovation branch: $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configuration Tool/SPED Adjustment Code
Functions
---------------------------------------------------------------------------------------------------------------------------
For the tax configuration tool, the variables lCpoCDV and lCdaCof were added with the field protections for previous releases, in addition to recording the new fields.
4. xFisAtuSF3 function - Responsible for updating tax record tables based on an incoming or outgoing invoice.
The GETULTAQUI function was added to treat the operands of last acquisition related to the reversal of ICMS for products that do not have structure, which it will write to the CJM table.
Added the GETCOMPULTAQ function to treat the last acquisition operand for products that have structure to record the calculation memory in the CJM table, checking all components and any level that make up the configured product structure.
In the function call, 2 new parameters were added, which will be used in the FISXDAGR function which is called at the end of this function.
At the end of the function, the FISDELCJM function was added to delete the CJM records when an invoice is canceled.
4. Function xMaFisAjIt - function responsible for reprocessing the return of the aGrava array.
Added RetCodAP and BusCodLan calls when tax configuration tool entries exist.
---------------------------------------------------------------------------------------------------------------------------
At the beginning of the source code, the variable lNewCDV was created to control the new fields of the CDV table.
Function a017AjuICM - Adds to the object, depending on the logical return of the variable lNewCDV, the following fields:
IF lNewCdv
nRegCalc := aScan( oLancCDV:aHeader, {|aX| aX[2] == "CDV_REGCAL" } ) nValOut := aScan( oLancCDV:aHeader, {|aX| aX[2] == "CDV_VLOUTR" } ) nCodObs := aScan( oLancCDV:aHeader, {|aX| aX[2] == "CDV_CODMSG" } ) nCodOLan := aScan( oLancCDV:aHeader, {|aX| aX[2] == "CDV_CODCPL" } ) nCodDes := aScan( oLancCDV:aHeader, {|aX| aX[2] == "CDV_TXTDSC" } ) nOpBase := aScan( oLancCDV:aHeader, {|aX| aX[2] == "CDV_OPBASE" } ) nOpAliq := aScan( oLancCDV:aHeader, {|aX| aX[2] == "CDV_OPALIQ" } ) nAgrLan := aScan( oLancCDV:aHeader, {|aX| aX[2] == "CDV_AGRLAN" } )
Endif
IF lNewCdv .and. Len(aGrava[nI]) > 17
oLancCDV:aCols[nR,nCodDes] := aGrava[nI,18] // oLancCDV:aCols[nR,nCodObs] := aGrava[nI,19] // oLancCDV:aCols[nR,nCodOLan] := aGrava[nI,20] // oLancCDV:aCols[nR,nRegCalc] := aGrava[nI,22] // oLancCDV:aCols[nR,nValOut] := aGrava[nI,21] // oLancCDV:aCols[nR,nOpBase] := aGrava[nI,23] // oLancCDV:aCols[nR,nOpAliq] := aGrava[nI,24] // oLancCDV:aCols[nR,nAgrLan] := aGrava[nI,25] //
Endif
---------------------------------------------------------------------------------------------------------------------------
Important
---------------------------------------------------------------------------------------------------------------------------
Important
In this function, we check if the array has 25 positions and record the new positions.
---------------------------------------------------------------------------------------------------------------------------
If CDA->(FieldPos("CDA_VLOUTR")) > 0 .And. CDA→
(FieldPos("CDA_TXTDSC")) > 0 .And. CDA->(FieldPos("CDA_CODCPL")) > 0
.And. CDA->(FieldPos("CDA_CODMSG")) > 0
.And. CDA->(FieldPos("CDA_AGRLAN")) > 0
aAdd(aCpCDA,"CDA_VLOUTR")
aAdd(aCpCDA,"CDA_TXTDSC")
aAdd(aCpCDA,"CDA_CODCPL")
aAdd(aCpCDA,"CDA_CODMSG")
aAdd(aCpCDA,"CDA_AGRLAN")
Endif
---------------------------------------------------------------------------------------------------------------------------
The MATA953 source code deals with the processing and recording of the ICMS calculation as a whole. For the tax configuration tool, some conditions were added to be able to correctly bring the information.
A treatment was placed with the aCont array referring to the sequence of the entry codes displayed on the screen.
A condition that compares CDA entry types was added to properly segregate in screen building according to the type of each ICMS tax.
3. DetCodLan Function - Displays the breakdown of invoice that have written the entry code to the CDA table.
Added a treatment to add the CDA_VLOUTR field to the query.
4. ApurDifal Function - Added a treatment when the entry type is equal to "CF", in which it is an entry referring to the tax configuration tool.
5. EstruCLan function - Treatment in the array to add the CDA_VLOUTR field if it exists.
6. Function a953TpLanc - Added the return for the "CF" entry type referring to the tax configuration tool.
7. Function a953TotSubApur- totalizes inputs and outputs when it is necessary to generate Block 1920 of the Tax Sped.For the tax configuration tool, the treatment for the CDA_VLOUTR field was added.
8. RetCodCDA function - Creates a JSON with all the entry codes registered in the CJA table filtered by period + branch.
9. PosTitDel function - Creates a JSON with all the bills generated by the MATA953 calculation to delete bills bound in the FISA181 routine.
10. GerGuiTit function - A function that generates Form and Bill of the adjustment codes released in the configuration tool via FISA181.
---------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------
For the tax configuration tool, some definitions were added for FieldPos, tables, generic tax reference, and message reference.
#DEFINE FP_CFC_FCPBSR 1049
#DEFINE FP_CD2_PSCFST 1050
#DEFINE FP_CD2_VFCPDI 1051
#DEFINE FP_CD2_VFCPEF 1052
#DEFINE FP_CFC_FCPAJT 1053
#DEFINE FP_CD2_FCPAJT 1054
#DEFINE FP_CDA_REGCAL 1055
#DEFINE FP_CDA_VLOUTR 1056
#DEFINE FP_CDA_CODMSG 1057
#DEFINE FP_CDA_CODCPL 1058
#DEFINE FP_CDA_TXTDSC 1059
#DEFINE FP_CDA_OPBASE 1060
#DEFINE FP_CDA_OPALIQ 1061
#DEFINE FP_CDV_REGCAL 1062
#DEFINE FP_CDV_VLOUTR 1063
#DEFINE FP_CDV_CODMSG 1064
#DEFINE FP_CDV_CODCPL 1065
#DEFINE FP_CDV_TXTDSC 1066
#DEFINE FP_CDV_OPBASE 1067
#DEFINE FP_CDV_OPALIQ 1068
#DEFINE FP_CJA_FILIAL 1069
#DEFINE FP_CJA_ID 1070
#DEFINE FP_CJA_CODREG 1071
#DEFINE FP_CJA_ID_CAB 1072
#DEFINE FP_CJA_REGCAL 1073
#DEFINE FP_CJA_CODTAB 1074
#DEFINE FP_CJA_CODTAB 1075
#DEFINE FP_CJA_CODLAN 1076
#DEFINE FP_CJA_VIGINI 1077
#DEFINE FP_CJA_VIGFIM 1078
#DEFINE FP_CJA_NFBASE 1079
#DEFINE FP_CJA_NFALIQ 1080
#DEFINE FP_CJA_VALOR 1081
#DEFINE FP_CJA_VLOUTR 1082
#DEFINE FP_CJA_GRGUIA 1083
#DEFINE FP_CJA_CODCPL 1084
#DEFINE FP_CJA_CODMSG 1085
#DEFINE FP_CJA_TXTDSC 1086
#DEFINE FP_CJA_GERMSG 1087
#DEFINE FP_CJ9_FILIAL 1088
#DEFINE FP_CJ9_ID 1089
#DEFINE FP_CJ9_CODREG 1090
#DEFINE FP_CJ9_DESCR 1091
#DEFINE FP_CJ9_VIGINI 1092
#DEFINE FP_CJ9_VIGFIM 1093
#DEFINE FP_CJA_GUIA 1094
#DEFINE FP_CJA_TITULO 1095
#DEFINE FP_CJA_TITGUI 1096
#DEFINE FP_CDA_AGRLAN 1097
#DEFINE FP_CDV_AGRLAN 1098
#DEFINE AI_CJ3 49
#DEFINE AI_CJA 50
#DEFINE AI_CJL 51
#DEFINE TG_IT_VL_MAX 34 //Maximum Manual Tax Value
#DEFINE TG_IT_VL_MIN 35 //Minimum Manual Tax Value
#DEFINE TG_IT_OPR_MAX 36 //Limit Operator for Maximum Tax Value
#DEFINE TG_IT_OPR_MIN 37 //Limit Operator for Minimum Tax Value
#DEFINE MSG_CHAVE 1
#DEFINE MSG_INDICADOR 2
#DEFINE MSG_TIPO 3
#DEFINE MSG_REFERENCIA 4
#DEFINE MSG_VAL_REF 5
#DEFINE MSG_LSOMA 6
---------------------------------------------------------------------------------------------------------------------------
A program responsible for calculating fiscal and financial taxes.
---------------------------------------------------------------------------------------------------------------------------
The objective is that the configurations made in the tax configurator are predominant before the legacy.
Within the SPEDFISCAL source, many points exist that change the aLancCDA and aLancCDA2 arrays so that some legacy legislation is met.
Creation of the static variable: oJRetCda
If !aLanCDA[nX,24] // Legacy
If aLanCDA[nX,1]$"SP90090104/SP90090278"
nPos := aScan(aRegC197,{|x| x[1] == nPosC195 .And. x[3]==aLanCDA[nX,1] .And. x[4]==aLanCDA[nX][2] })
Else
nPos := aScan(aRegC197,{|x| x[1] == nPosC195 .And. x[5]==cCodItem .And. x[3]==aLanCDA[nX,1] })
EndIf
Else
If aLanCDA[nX,23] == "01"
nPos := aScan(aRegC197,{|x| x[1] == nPosC195 .And. x[3]==aLanCDA[nX,1] }) ElseIf aLanCDA[nX,23] == "02"
nPos := aScan(aRegC197,{|x| x[1] == nPosC195 .And. x[3]==aLanCDA[nX,1] .And. x[4]==aLanCDA[nX][2] })
Elseif aLanCDA[nX,23] == "03"
nPos := aScan(aRegC197,{|x| x[1] == nPosC195 .And. x[5]==cCodItem .And. x[3]==aLanCDA[nX,1] })
Else
nPos := aScan(aRegC197,{|x| x[1] == nPosC195 .And. x[5]==cCodItem .And. x[3]==aLanCDA[nX,1] })
Endif
Endif
5. RegE115 function - Added the treatment to separate the entries coming from Legacy X Tax Configuration Tool.It uses the variable "lNewCDV" and also uses the "RetQCDV" function that is in the SPEDXFUN source.
6. SPDAPICMS function - uses the "TempCDA" function that is in the SPEDXFUN source code.It also makes the treatment to separate the entries that come from the Legacy X Tax Configuration Tool.The records contemplated by the changes in this function are: E111, E113, E220, and E240.
7. Grupo1900 Function - Added the parameter "@aStructCDA" to the function call.Added a treatment to separate the entries coming from Legacy X Tax Configuration Tool.Use of the RetQCDV function to generate Record 1925.
8. AP1900ICM Function - Added the "@aStructCDA" parameter to the function call.
Added a treatment to separate the entries coming from Legacy X Tax Configuration Tool.
The records contemplated by the modifications are: 1921, 1923.
9. D195D197 function - Added a treatment to separate the entries coming from Legacy X Tax Configuration Tool.
If !aLanCDA[nX][24]
If aLanCDA[nX,1]$"SP90090104/SP90090278"
nPos := aScan(aRegD197,{|x| x[1] == nPosD195 .And. x[3]==aLanCDA[nX,1] .And. x[4]==aLanCDA[nX][2] })
Else
nPos := aScan(aRegD197,{|x| x[1] == nPosD195 .And. x[5]==cCodItem .And. x[3]==aLanCDA[nX,1] })
EndIf
Else
If aLanCDA[nX,23] == "01"
nPos := aScan(aRegD197,{|x| x[1] == nPosD195 .And. x[3]==aLanCDA[nX,1] })
ElseIf aLanCDA[nX,23] == "02"
nPos := aScan(aRegD197,{|x| x[1] == nPosD195 .And. x[3]==aLanCDA[nX,1] .And. x[4]==aLanCDA[nX][2] })
Elseif aLanCDA[nX,23] == "03"
nPos := aScan(aRegD197,{|x| x[1] == nPosD195 .And. x[5]==cCodItem .And. x[3]==aLanCDA[nX,1] })
Else
nPos := aScan(aRegD197,{|x| x[1] == nPosD195 .And. x[5]==cCodItem .And. x[3]==aLanCDA[nX,1] })
Endif
Endif
---------------------------------------------------------------------------------------------------------------------------
Some definitions for FieldPos, tables, and branches have been added to the Tax Configuration Tool.
#DEFINE FP_CDA_TXTDSC 243
#DEFINE FP_CDA_CODCPL 244
#DEFINE FP_CDA_CODMSG 245
#DEFINE FP_CDA_VLOUTR 246
#DEFINE FP_CDA_REGCAL 247
#DEFINE FP_CDA_OPBASE 248
#DEFINE FP_CDA_OPALIQ 249
#DEFINE FP_CDA_IDMSG 250
#DEFINE FP_CDV_TXTDSC 251
#DEFINE FP_CDV_CODCPL 252
#DEFINE FP_CDV_CODMSG 253
#DEFINE FP_CDV_VLOUTR 254
#DEFINE FP_CDV_REGCAL 255
#DEFINE FP_CDV_OPBASE 256
#DEFINE FP_CDV_OPALIQ 257
#DEFINE FP_CDV_IDMSG 258
#DEFINE FP_CJ8_CODREF 259
#DEFINE FP_CJ8_DESC 260
#DEFINE FP_CJ8_MENSG 261
#DEFINE FP_CJL_ID 262
#DEFINE FP_CJL_INDICE 263
#DEFINE FP_CJL_CODMSG 264
#DEFINE FP_CJL_MENSG 265
#DEFINE FP_CDA_AGRLAN 266
#DEFINE AI_CJA 64
#DEFINE AI_CJ8 65
#DEFINE AI_CJ9 66
#DEFINE AI_CJL 67
#DEFINE PFIL_CJA 111
#DEFINE PFIL_CJ8 112
#DEFINE PFIL_CJ9 113
#DEFINE PFIL_CJL 114
---------------------------------------------------------------------------------------------------------------------------
The objective is that the messages registered through the routine of the tax configuration tool be reflected in the functions of the SPEDXFUN source code so that they are later recorded in the EFD ICMS/IPI file.We will also make the control regarding how the user of the tax configuration tool grouped the adjustment entry codes.
Local lMsgCjl := .F.
Local cMsgCjl := ""
Local lProcCDA := .F.
Local cAgrup := ""
A new parameter was added to the call of the SPEDFFiltro function.
SPEDFFiltro(1,"CDA",lMsgCjl)
After the return of the SPEDFFilter function query, the message field for blocks C195, C197, 0460 is performed, in addition to changing the building as a whole of the aLancIT and aLancCDA2 arrays that are used to build the SPEDFISCAL file for the blocks that use the CDA table.
It also deals with how the aLancIT or aLancCDA2 arrays will be grouped according to the contents of the CDA_AGRLAN field.
New positions are added to the aLancIT and aLancCDA2 arrays.
A new position is added to the aInfE531 array to treat the block for IPI calculation.
2. SPEDFFilter function - Responsible for returning the data with the CDA table information bound to other tables.For the tax configuration tool, along with an entry protection, the new fields of the CDA and also the CJL table were added. Also a treatment with the logic variable lMsgCjl.
3. RetQCDV function - A new function to return the complementary description to the E115 record if it is not filled in.
4. TempCDA function - A new function that returns an object with the entry codes that are in the CDA for the period of the calculation.
---------------------------------------------------------------------------------------------------------------------------
Create an operand to identify the last acquisition of raw materials that were used in the production of the finished product using the product structure flow with → Production Order → Production Allocation → Production Point.
Make a sale to a Public Agency of the PA product with CST 40 exempt bookkeeping, where I use a Credit Reversal entry code to bring the value of the ICMS of the last purchase invoice of MP
Calculation Memory:
PA100 - Quantity sold = 5
Product structure to produce:
MP100 - Quantity 6
MP102 - Quantity 0.3
MP103 - Quantity 1
Purchase Invoice x Quantity
Purchase | Quantity | ICMS Total | Unit ICMS |
---|---|---|---|
MP100 | 200 | 1200 | 6 |
MP101 | 50 | 300 | 6 |
MP102 | 40 | 960 | 24 |
ICMS Credit Reversal
Raw material | (ICMS unit * Sales quantity)*Production quantity | Reversal value |
---|---|---|
MP100 | (6*6)*5 | 180 |
MP101 | (6*0.3)*5 | 9 |
MP102 | (24*1)*5 | 120 |
TOTAL | 309 |
Table
CJM - Prod Str icms Rev Track
Dictionary
The structure is in package 010843 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Cod_Lanc_Estrutura_Prod/Dicionario
The return of this query will map the Last Acquisition Incoming Invoice and write to the variable nIcmsEst := (((value of MP Incoming Invoice ICMS / MP QTY acquired)* QTy used in production) * quantity sold.
The value of the nIcmsEst will be displayed in the financial sheet in the Entry Code tab, which has been properly configured in routine FISA181 with a Tax Rule.
In this function, we also have the recording of the Last Incoming Invoice regarding MP acquisitions that were used in the production of the sold PA, in addition to the information of the Outgoing Invoice and the value of the Reversal ICMS that will be used. This information will be registered in CJM table.
3. GravaCJM Function - Receives an array treated within the GetCompultaq function to write the data to the CJM table using the FWBulk() method as a basis.
4. GetUltAq function - Refactoring the query to TCgenQry2, and new fields have also been added to use in CJM recording.Also, treatments were added to the function to record the CJM by calling the GravaCJM function.
5. FISDELCJM Function - This function was created so that, at the time of deletion of the Outgoing Invoice, the content recorded for that Outgoing Invoice is deleted;
--------------------------------------------------------------------------------------------------------------------------------------
Adding a new operating option for the customer to recover the value of the ICMS for the purchase of raw materials used in finished production, which will be sold in exempted operations entitled to Refund this initial value via Entry Code.
aadd(aCarga,{"Valor do ICMS (Last Product Structure Acquisition)" ,"VLR_ICMS_ULT_AQUI_ESTRUTURA"})
---------------------------------------------------------------------------------------------------------------------------------------
Generating a Checking Report based on what was recorded in the CJM - ICMS Reversal Control - Operating from Last Acquisition by Structure or PA for Resale.
By using the operatives below, we will track the Incoming Invoices that give rise to the purchase of Products for resale and the raw materials that were used in product structure in SG1.
QUANTIDADE_ULT_AQUI
ICMS_ULT_AQUI
BASE_ICMS_ULT_AQUI
ALQ_ICMS_ULT_AQUI
VLR_ICMS_ULT_AQUI_ESTRUTURA
After finding the last entries, we perform calculations to generate a Reversal ICMS value that will be recorded in the CJM
This Report aims to read this table and bring data for checking.
This report was developed in TLPP