Páginas filhas
  • FIS003 - Entry Adjustment Rule Technical Documentation

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Índice

CALCODLAN- Reading tables from routine FISA178 and FISA181 with CDA and CDV Table Array update

Objective and scope

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

Aviso
titleImportant

The fields below in the CDA and CDV are exclusive for operations with entry adjustment code performed by the Tax Configuration Tool.

Tables

  1. CDA 
    1. CDA_VLOUTR - Consider ICMS Value Others. 
    2. CDA_TXTDSC - Code for Complementary Description for block 0460 (Binding with CJA table).
    3. CDA_CODCPL - Code referring to the complementary message for block C195 and other similar (Binding with CJA table).
    4. CDA_CODMSG - Code referring to Complementary Description for block C197 and other similar (Binding with CJA table).
    5. CDA_REGCAL - Reference of the Calculation Rule Code used by the Tax Configuration Tool.
    6. CDA_OPBASE - Calculation base choice option according to CJA table binding.
    7. CDA_OPALIQ - Rate choice option according to the CJA table binding.
    8. CDA_IDMSG- ID field generated through the FWUID routine with CJL table binding, which stores the messages converted with the NPI formula.  
    9. CDA_AGRLAN - A field that identifies how to group the record for generating the Tax SPED File.
  2. CDV
    1. CDV_REGCAL - Reference of the Calculation Rule Code used by the Tax Configuration Tool.
    2. CDV_VLOUTR - Consider ICMS Value Others. 
    3. CDV_TXTDSC - Code for Complementary Description for block 0460 (Binding with CJA table).
    4. CDV_CODCPL - Code referring to the complementary message for block C195 and other similar (Binding with CJA table).
    5. CDV_CODMSG - Code referring to Complementary Description for block C197 and other similar (Binding with CJA table).
    6. CDV_OPBASE - Calculation base choice option according to CJA table binding.
    7. CDV_OPALIQ - Rate choice option according to the CJA table binding.
    8. CDV_IDMSG- ID field generated through the FWUID routine with CJL table binding, which stores the messages converted with the NPI formula. 
    9. CDV_AGRLAN - A field that identifies how to group the record for generating the Tax SPED File.


Dictionary

The structure is in the package 010120 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Livros Fiscais - Configuration ToolConfigurador/Codigo de Ajuste SPED Adjustment Code/DictionaryDicionario

The structure is in the package 010650 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/ Livors Livros Fiscais - Configuration ToolConfigurador/Codigo de Ajuste SPED Adjustment Code/Dicionario

...

Source Codes

Located in the Innovation branch:   $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Livros Fiscais - Configuration ToolConfigurador/Codigo de Ajuste SPED Adjustment Code

  1.  RetCodAp Function - Creating a query with JSON to read table CJ9 - Entry Adjustment Rule File Header, and CJA - Entry, Value, and Messages Code to write on Array aRegCal.
  2.  BusCodLan function - Receives JSON from the RETCODAP function - oJCodRef , which updates the aGrava array that, in Legacy, has 17 positions, and, upon receiving the information from the tax configuration tool, becomes 25 positions, below are the positions changed in the AGrava Array: 
    1. Wiki Markup
                    cCodLan    := Alltrim(aCodLan\[nI\]\[2\])  //CJA_CODLAN 
    2. Wiki Markup
                    nBasCal     := aTribgen\[nX\]\[TG_IT_BASE\]  //CJA_NFBASE 
    3. Wiki Markup
                    nAlqCal     := aTribgen\[nX\]\[TG_IT_ALIQUOTA\]    //CJA_NFALIQ
    4. Wiki Markup
                    cTpLanc     := Iif(Alltrim(aCodLan\[nI\]\[7\]) <> "03","2","1") //Treatment made for the correct recording of *IPI Entries.*
    5. Wiki Markup
                    cRegCalc   := aCodLan\[nI\]\[1\]   //cRegCal
    6. Wiki Markup
                    cCodVal     := Left(aCodLan\[nI\]\[5\],3)   //CJA_VALOR
    7. Wiki Markup
                    cCodValOu := Left(aCodLan\[nI\]\[6\],3)   //CJA_VLOUTR
    8.               NValor    := 0 //Conditional treatment according to the value received in the variable cCodVal
    9.               NValorOut := 0 //conditional treatment according to the value received in the variable cCodValOu
    10. Wiki Markup
      *              {*}cOpBase    := aCodLan\[nI\]\[3\]
    11. Wiki Markup
                    cOpAliq     := aCodLan\[nI\]\[4\]
    12. Wiki Markup
      *             * cCFOP        := aNfItem\[nZ\]\[IT_CF\
    13. Wiki Markup
                    cDescod     := aCodLan\[nI\]\[12\]
    14. Wiki Markup
                    cLivro         := aNFItem\[nZ\]\[IT_TS\]\[TS_NRLIVRO\]
    15. Wiki Markup
                    cCodDes    := aCodLan\[nI\]\[11\]   //CJA_TXTDSC
    16. Wiki Markup
                    cCodObs    := aCodLan\[nI\]\[10\]   //CJA_CODCPL
    17. Wiki Markup
                    cCodOLan  := aCodLan\[nI\]\[09\]   //CJA_CODMSG
    18. Wiki Markup
                    cGeracum  := aCodLan\[nI\]\[12\]   //CJA_GERMSG
    19.               cIFCOMP    := "CONFIG"
    20. Wiki Markup
                     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.

---------------------------------------------------------------------------------------------------------------------------

FISA170 - Routine with the concentration of all registrations of the tax engine.

A new option has been added to the Configuration Tool Tree.

  • Entry Adjustment Rule
    • Messages File
    • Entry Adjustment Rule

Objective and scope

This concentrates the Tree Menu, load routines, and Browser of the routines used in the tax configuration tool.

Sources

Source Codes

Located It is located in the Innovation Branch: $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configuration Tool/SPED Adjustment Code

Function

GetVerRls - Access Control to Improvements by Release.

Added the totvs.protheus.backoffice.fiscal.relatorioEstornocredito reversal conference report to Tree, in the Reports tab.

Tables added

CJ8 – Messages File

CJ9 - Adjustment Rules File

CJA -Adjustment Rule Entry Codes
---------------------------------------------------------------------------------------------------------------------------

FISA173- Generic Tax Calculation Function

New functions have been added to the Entry Adjustment Codes File: 

Function 

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.
---------------------------------------------------------------------------------------------------------------------------

FISA178 – Messages File

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.

Tables

CJ8 with the header information, with the information of fields and filters for building the message;

Dictionary

The structure is in the package 010120 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Tax Records - Configuration Tool/SPED Adjustment Code/Dictionary

...

Livros Fiscais - Configurador/Codigo de Ajuste SPED/Dicionario

Source Codes

Located in the Innovation branch: $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Tax Records - Configuration Tool/SPED Adjustment CodeLivros Fiscais - Configurador/Codigo de Ajuste SPED

Automatic Load

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.

Relationship

This field CJ8_TBCONF will be linked to the tax calculation rule in table F2B, Routine FISA160, in the F2B_RULE field.

Return

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.
---------------------------------------------------------------------------------------------------------------------------

FISA181 - Entry Adjustment Rule Registration

Objective and scope

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:

  • Link of Entry Code registered in TIO.
  • Link of Reflection Code for calculation rules, made in FISA072.
  • Linking of messages on table CCE (Complementary Information) or in the TIO File (Table SF4), field F4_CODOBSE (Note Code) 
    • C197 
    • C195
    • 0460

Tables

CJ9 with the information of the Entry Adjustment Rule File header, where we have the fields:

  1. CJ9_CODREG - Rule Code
  2. CJ9_DESCR - Adjustment Rule Description
  3. CJ9_VIGINI - Start Date of Rule Validity
  4. CJ9_VIGFIM - End Date of Rule Validity
  5. CJ9_ID - Which is related to Table CJA - Entry Adjustment Rule Items.

Image AddedImage Removed
CJA - Entry Rule - Items, where we will list which entry codes, calculation rule, validity, tab control, and messages will be used.      

  1. CJA_CODREG - Header Rule Code - To be related to Table CJ9
  2. CJA_REGCAL - Calculation Rule - We will have a standard query with Table F2B in which the user selects the calculation rule that matches the Adjustment Code rule. In this field, instead of having a calculation in the reflection register, they would create their own calculation.      
  3. CJA_CODTAB - Entry Table - In this field, find available 4 entry tables 5.1.1 (CDO), 5.2 (CDY), 5.3(CC6), and 5.3.4(CCK)
  4. CJA_CODLAN*  - Entry Code - The table selected in field CJA_CODLAN updates the standard query, returning the entry codes of each table.
  5. CJA_VIGINI - Entry Validity Start Date - The user enters the start date of entry code validity found in the TXT files downloaded from the website {+}http://sped.rfb.gov.br/+Image RemovedImage Added 
  6. CJA_VIGFIM* - Entry Validity End Date - The user enters the end date of entry code validity found in the TXT files downloaded from the website {+}http://sped.rfb.gov.br/+Image RemovedImage Added 
  7. CJA_NFBASE - Consider ICMS Base - This field offers 3 options - Value / Null / Zero, in case the calculation rule needs to consider the ICMS Base as Zero, Value, or NULL if it is necessary to record the |BLANK| content in SPED.
  8. CJA_NFALIQ - Consider Rate - This field offers 3 options - Value / Null / Zero, in case the calculation rule needs to consider the ICMS Rate as Zero, Value or NULL if it is necessary to record the |BLANK| content in SPED.
  9. CJA_VALOR - Consider ICMS Value - Use this field to control how the rule interprets ICMS value contents when you need to generate field 7 of record C197, whether it will be understood as Value. In this field, we have a standard query in CIN with Tax rule filter with field CJ9_REGCAL.
  10. CJA_VLOUTR - Consider Other ICMS Value - Use this field to control how the rule interprets ICMS value contents when you need to generate field 8 of record C197 whether it will be understood as Other. In this field, we have a standard query in CIN with Tax rule filter with field CJ9_REGCAL.
  11. CJA_CNTRL     State of operation           - In this field, we have 2 options to consider the entry code, by the source State or the target State. This field is related to the CJA_OPER field
  12. CJA_OPER      Type of operation         - This field defines in which types of operation the entry code should appear. There are 3 options: Incoming, Outgoing, and Return.
  13. CJA_CODMSG - Message Code - In this field, select the message pre-registered in routine FISA178 - Message Registration to be used in EFD ICMS IPI Record C197 field 3
  14. CJA_GERMSG - Message Type - This field controls how to generate the message for 01 - Entry Code by period, in which a message is generated for each entry code in the period, 02 - Entry Code + Invoice, if a single message is generated for Entry Code grouped by Invoice, or 03 - Entry Code + Product to detail the message for each product in the invoice.
  15. CJA_ID_CAB    Header ID         - This field will not be displayed in the Browser, but an ID will be recorded using the FWUUID ("CJA") function.                                                                                                                   
  16. CJA_CODCPL - Complement Text - In this field, select the message pre-registered in routine FISA178 - Message Registration to be used in EFD ICMS IPI Record C195 field 2 and field 3.    
  17. CJA_TXTDSC - Description Text - In this field, select the message pre-registered in routine FISA178 - Message Registration to be used in the Description field of the ICMS ISI EFD Record 0460.
  18. CJA_GUIA      Form Rule           - In this field, we will have the default query with table CJ4, where the user will select the form rule that fits the adjustment code rule.
  19. CJA_TITULO      Bill Rule                  - In this field, we will have the standard query with table FKK, where the user will select the bill rule that fits into the adjustment code rule.
  20. CJA_TITGUI    Group. Mode Form/Bill   - In this field, we define the Form/Bill grouping mode that should be generated through the routine. 01- By Document +Entry + Participant, or 02 - By Entry Code grouped by Participant

Dictionary

The structure is in the package 010120 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Tax Records - Configuration Tool/SPED Adjustment Code/DictionaryLivros Fiscais - Configurador/Codigo de Ajuste SPED/Dicionário

The structure is in the package 010650 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/ Tax Records - Configuration Tool/SPED Adjustment Code/Dictionary

...

Livros Fiscais - Configurador/Codigo de Ajuste SPED/Dicionário

Source Codes

Located in the Innovation branch: $/Protheus_Padrao/Fontes_Doc/Inovação/V12/ Tax Records - Configuration Tool/SPED Adjustment CodeLivros Fiscais - Configurador/Codigo de Ajuste SPED

Creation of the screen in MVC with TAB structure (Folders), was structured in 2 models - MASTER and GRID.

  1. MASTER - Table CJ8
    1. VIEW_CAB
  2. GRID - Table CJA
    1.  VIEW_LANC
      1. Fields:  CJA_CODTAB|CJA_CODLAN|CJA_VIGINI|CJA_VIGFIM|CJA_REGCAL|CJA_GUIA|CJA_TITULO|CJA_TITGUI|CJA_GERMSG|CJA_OPER|CJA_CNTRL
    2. VIEW_VLR
      1. Fields: CJA_CODLAN|CJA_NFBASE|CJA_NFALIQ|CJA_VALOR|CJA_VLOUTR
    3. VIEW_MSG
      1. Fields: CJA_CODLAN|CJA_CODMSG|CJA_CODCPL|CJA_TXTDSC
  3. Standard query and COMBOBOX functions and standard query
    1. XTabelaLanc - Field CJA_CODTAB
    2. X181ChgF3 - Field CJA_CODLAN
    3. CboxTpMsg - Field CJA_GERMSG
    4. XTpTITGUI - Field CJA_TITGUI
    5. CboxOper - Field CJA_OPER
    6. CboxUF - Field CJA_CNTRL
  4. Validation functions:
    1. VldCodigo function, where we handle not to repeat CJ9_CODREG. 
    2. Function VigIniFIM that checks whether the start date and end date already exist in the rules file.
    3. Fsa181MCpo which validates that the option of the CJA_CODTAB field has been changed, delete the contents of the CJA_CODLAN|CJA_VIGINI|CJA_VIGFIM fields
    4. ChangeLine, this function updates the GRID between tabs, identifying the row positions on the TAB and replicating the same position to the other tabs, so the user will know which row of the previous tab they is changing or viewing.

Relationship

  • F2B (F2B_REGRA), with the CJA_REGCAL field
  • CIN (CIN_CODIGO), with the fields CJA_VALOR and CJA_VLOUTR  
  • CJ8 (CJ8_CODREF)  with the fields CJA_CODCPL, CJA_CODMSG, and CJA_TXTDSC
  • CJ9 (CJ9_ID) with the CJA_ID_CAB field
  • CJ9 (CJ9_CODREG), with the CJA_CODREG field

Automation

  • Case
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Cases/FISCadMensagemTestCase.PRW
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Cases/FISCadRegraAjustTestCase.PRW
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Cases/FISCadTributoTestCase.PRW
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Cases/FISComRJArqCfgTestCase.PRW
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Cases/FISComRJArqCfgTestCase.PRW
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Cases/FISComRJArqCfgTestCase.PRW
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Cases/FISComRJArqCfgTestCase.PRW
  • Group
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Group/FISCadTestGroup.prw
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Group/FISComRJArqCfgTestGroup.prw
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Group/FISIndSPArqCfgTestGroup.prw
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Group/FISIndSpCfgMovTestGroup.prw
  • Suite
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Suites/FISCadTestSuite.prw
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Suites/FISComArqCfgTestSuite.prw
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Suites/FISIndArqCfgTestSuite.prw
    • $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Codigo de Ajuste SPED/Automaçao/Suites/FISIndCfgMovTestSuite.prw

---------------------------------------------------------------------------------------------------------------------------

FISXAPUR- Tax functions

Objective and scope

Separate, in the calculation, the values from the tax configuration tool versus entries via TIO (Legacy).

Modifications to meet IPI calculation 

  1. AdjustIPI function - This function receives the aCDAIPI array containing the data from the CDA table for the IPI adjustment entries, in which more than one position was added to the array through the contents of the cSPFGLEG variable.

...

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.

Modifications to meet ICMS calculation

  1. CkapurCDH 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 to the aDADIC array and later bringing it to the screen of the new calculation.

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.

---------------------------------------------------------------------------------------------------------------------------

FISXAPURA- Tax Functions


The FISXAPURA source code deals with the processing of ICMS and IPI calculation information when the multithread is active in the client scenario.

Modifications to meet IPI calculation

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.

Modifications to meet ICMS calculation

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.
---------------------------------------------------------------------------------------------------------------------------

FISXDESCR- Conversion of Messages with NPI Formula

Objective and Scope

This source code aims to convert references from MATXFIS() and other functions into indexes to be used in tax document texts.

Tables

CJL - Decoded Message Control, where we will store the converted messages according to the relationship of the Entry Adjustment Code Rule (CJA) message codes.      

    1. CJL_ID         Message ID  - We will relate it to that of CDA Table
    2. CJL_INDICE    Message Index - In the CDA, we have 3 fields available to set up a message for records C195, C197, and 0460. This field in the CJL serves to identify from which field the message originated. Example: CDA_CODCPL (C195) = Index 01, CDA_CODMSG (C197) = Index 02, and CDA_TXTDSC(0460) = Index 03
    3. CJL_CODMSG Message Code - The field that will store the message code configured in the CJA table and that also exists in CJ8.
    4. CJL_MENSG    Message Decoded - MEMO field with message converted.

...

Source Codes

Located in the Innovation branch: $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configuration Tool/SPED Adjustment Code
Functions

...


---------------------------------------------------------------------------------------------------------------------------

IMPXFIS - Tax Functions


  1. GFPMxFis function - Added the new fields of CJ9, CJA, CDA, and CDB using the lCdaCof variable for control.
    1. The lTribCon

...

    1. variable was created if I have any tribute calculation made by the configuration tool to call the RetCodAp function - loads the configuration tool's entry code table to a JSON And I also call BusCodLan.
    2. Added the CJM table - in which will be recorded the contents of the last incoming invoices that make up the PA building, and the outgoing invoice used to the PA.
    3. Added to GFFMxFis function the GETCOMPULTAQfunction - Search the data of MP its x PA structures, the FisDelCjm function, to delete the CJM when there is the cancellation of the outgoing invoice and the GETULTAQUI function to handle the recording of the CJM for products that do not have structure.  
  1. XFisCDA function - writes the CDA table according to the return of the aGrava array processing. For  

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. 

---------------------------------------------------------------------------------------------------------------------------

MATA017- Registration of additional information of the calculation

At the beginning of the source code, the variable lNewCDV was created to control the new fields of the CDV table.

  1. Function A017LAICMS - Receive the CDV_VLOUTR field when building the GETDADOS from the tax entry folder
  2. MontCols function - reposition the fields and add the CDV_VLOUTR.unmigrated-wiki-markup
  3. Function

    a017AjuICM

    -

    Adds

    to

    the

    object,

    depending

    on

    the

    logical

    return

    of

    the

    variable

    lNewCDV,

    the

    following

    fields:

    _IF lNewCdv        nRegCalc := aScan(

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

...


  1. Function a017GrvCDV - Responsible for recording the CDV table.It also makes the treatment referring to the new fields of the CDV according to the logical return of the lNewCDV variable.
  2. Function a017xLAICMS - Tax Entry Tab, add new fields if they exist:
    1.     aAdd(aYesFields,"CDV_VLOUTR")
    2.     aAdd(aYesFields,"CDV_TXTDSC")
    3.     aAdd(aYesFields,"CDV_CODCPL")
    4.     aAdd(aYesFields,"CDV_CODMSG")
    5.     aAdd(aYesFields,"CDV_REGCAL")
    6.     aAdd(aYesFields,"CDV_OPBASE")
    7.     aAdd(aYesFields,"CDV_OPALIQ")

    
---------------------------------------------------------------------------------------------------------------------------

MATA103 - Incoming Invoices


Aviso
titleImportant
On the official upload to the Master Branch, alignment with the Purchasing Team will be required to upload these changes.


  1. Function a103AjuICM - In this function, we update the Entry Code screen folder with the fields:
    1. CDA_VLOUTR
    2. CDA_TXTDSC
    3. CDA_CODCPL
    4. CDA_CODMSG
    5. CDA_REGCAL
    6. CDA_OPALIQ
    7. CDA_OPBASE
    8. CDA_AGRLANThe above fields are only displayed depending on the logical return of the lNewCDA variable.
  2. Function a103GrvCDA - Responsible for deleting and updating the references of the tax entries. We carry out the protections of the new fields to receive and carry out the recordings, updates, or deletions;

---------------------------------------------------------------------------------------------------------------------------

MATA103x-   Incoming document interface control and validation functions


Aviso
titleImportant
On the official upload to the Master Branch, alignment with the Purchasing Team will be required to upload these changes.


  1. Function a103xLAICMS -  Encapsulated the {"CDA_VLOUTR","CDA_TXTDSC","CDA_CODCPL","CDA_CODMSG"} fields in the aCmpsCDA array and update if, in the new fields, exist the array
    1.     aAdd(aCmpsCDA,"CDA_VLOUTR")
    2.     aAdd(aCmpsCDA,"CDA_TXTDSC")
    3.     aAdd(aCmpsCDA,"CDA_CODCPL")
    4.     aAdd(aCmpsCDA,"CDA_CODMSG");

In this function, we check if the array has 25 positions and record the new positions.

---------------------------------------------------------------------------------------------------------------------------

MATA920 - Manual Sales Invoices Output

  1. Function a920LAICMS - Building of the Getdados of the tax entry folder.Encapsulated the {"CDA_NUMITE","CDA_CODLAN","CDA_BASE","CDA_ALIQ","CDA_VALUE","CDA_IFCOMP"} fields in the aCpCDA array and update if the new fields in the array exist:

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    
---------------------------------------------------------------------------------------------------------------------------

MATA953 – ICMS Calculation

Objective

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.

Functions

  1. Function A953Processa - For the tax configuration field, statements of the variables that will be used throughout the source code have been added.
  2. Function a953Apura - This function distributes the return of the arrays aCDAIC, aCDAST, aCDADiffal, aCDADE to the folders of the ICMS calculation screen.

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.

---------------------------------------------------------------------------------------------------------------------------

MATN410B- Tax calculation function contained in the sales order


  1. A410LAICMS function - Tax Entries Folder in the Sales Order (Financial Sheet)
    1. Validates if the CDA_VLOUTR field exists before adding it to the Folder
    2. LGerAlp, the control will bring the fields to the screen.

---------------------------------------------------------------------------------------------------------------------------

MATXDEF.CH - Include used in the routines IMPXFIS, MATXFIS, among others.

For the tax configuration tool, some definitions were added for FieldPos, tables, generic tax reference, and message reference.

FieldPos

#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

Tables

#DEFINE AI_CJ3    

...

49

#DEFINE AI_CJA    

...

50

#DEFINE AI_CJL     51

Generic Tax Reference

#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

Message reference

#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
---------------------------------------------------------------------------------------------------------------------------

MATXFIS - Tax Functions

A program responsible for calculating fiscal and financial taxes.

...

---------------------------------------------------------------------------------------------------------------------------

SPEDFISCAL - ICMS/IPI EFD file generation routine

Objective and Scope


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.

Functions

Creation of the static variable: oJRetCda

  1. Block E Function - Added the "@aStructCDA" parameter to the call.
  2. SPDE520530 function - Added the treatment to the entry type 3 - CONFIG to be able to correctly bring the Parent and Child records of blocks E530 and E531.
  3. RegE531 Function - Added a condition that checks the configuration tool entries for building block E531.unmigrated-wiki-markup
  4. *C195C197 * * function * - Added a treatment to separate the entries coming from Legacy X Tax Configuration Tool. _

    If

    !aLanCDA

    \

    [nX,24

    \

    ]

    //

    Legacy        If aLanCDA\

    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


---------------------------------------------------------------------------------------------------------------------------

SPEDXDEF.CH - Include used in the SPEDFISCAL and SPEDXFUN routines

Some definitions for FieldPos, tables, and branches have been added to the Tax Configuration Tool.

FieldPos

#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

Tables

#DEFINE AI_CJA

...

64

#DEFINE AI_CJ8

...

65

#DEFINE AI_CJ9

...

66

#DEFINE AI_CJL 67

Branches

#DEFINE PFIL_CJA

...

111

#DEFINE PFIL_CJ8

...

112

#DEFINE PFIL_CJ9

...

113

#DEFINE PFIL_CJL 114


---------------------------------------------------------------------------------------------------------------------------

...

SPEDXFUN - Tax functions for SPEDFISCAL


Objective and Scope


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.

Functions


  1. SPLancCDA Function - Configuration Tool message control variables have been added:

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.

---------------------------------------------------------------------------------------------------------------------------

CONFXFIS - Focus all the functions and rules of the tax configuration tool


Objective and Scope 

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   

    1. CJM_FILIAL        System branch
    2. CJM_DOCORI    Source document      
    3. CJM_SERORI      Source Series             
    4. CJM_PRDORI   Source Invoice Product        
    5. CJM_DTORIG   Source Doc Data          
    6. CJM_LOTORI      Product Batch            
    7. CJM_UM            Measurement Unit        
    8. CJM_SEGUM      Second Measurement Unit
    9. CJM_QTSEGU     Second Measurement Unit
    10. CJM_DOCSAI     Outgoing Doc No.            
    11. CJM_SERSAI    Outgoing Invoice No.     
    12. CJM_QTDSAI     Outgoing Invoice Item Qty.
    13. CJM_CLIFOR      Customer/Supplier       
    14. CJM_LOJA          Cust/Supp Store Code  
    15. CJM_ICMEST      St Cred Reversal ICMS Val.
    16. CJM_PERIOD      Year/Month of Processing
    17. CJM_PRDFIM     Final Product Code        
    18. CJM_PRCOMP   Component Product Code
    19. CJM_QTESTR     Production Quantity      
    20. CJM_FORNEC    Supp/Customer Code  
    21. CJM_LOJAEN     Inflow Supp/Cust Store
    22. CJM_ITEFIM       Item Code           
    23. CJM_PRDINT     Intermediary Product
    24. CJM_ICMUNT    Unit ICMS of calculation memory

Dictionary

The structure is in package 010843 - $/Protheus_Padrao/Fontes_Doc/Inovação/V12/Livors Fiscais - Configurador/Cod_Lanc_Estrutura_Prod/Dicionario

Functions

  1.  Function Static Function ValOperPri, - Added the new operand: VLR_ICMS_ULT_AQUI_ESTRUTURA, which will be responsible for returning the value of the ICMS calculated per Item of the Incoming Invoice of the material used for manufacturing the PA that will be sold. Added to the aPesqEstr STATIC to receive product data of structure, structure quantity, and quantity sold.Added logical references to identify the use of the operands necessary for the composition of the reversal value, both for products with structure and for products for resale.
  2. GetCompUltAq Function - With the intelligence of tracking the PA product in the sale order, search, in SD1 and SG1, the product structure that originated the production of the PA, recover the unit value of the ICMS of the Last Acquisition to compose the Total ICMS Value which will be bound by the Entry Code of the Credit Reversal.

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;


--------------------------------------------------------------------------------------------------------------------------------------

FISCOMPFOR - Focus all the functions that create and manipulate the formula component of the tax configuration tool

Objective and Scope: 

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.

Functions:

  1. FormOperPri function - New option triggered in the aCarga array: add

aadd(aCarga,{"Valor do ICMS (Last Product Structure Acquisition)"         ,"VLR_ICMS_ULT_AQUI_ESTRUTURA"})

---------------------------------------------------------------------------------------------------------------------------------------

backoffice.fiscal.configurador.relatorioEstornocredito- Checking Report of the Calculation of ICMS Reversal for Products with Structure and Resale

Objective and Scope: 

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 operatives, 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.

Functions:

This report was developed in TLPP

  1. relatorioEstornocredito - Builds the TRCELL structure to map the Outgoing Invoices and their Entries that originated the Reversal Value
  2. ReportPrint - Queries with CJM and CDA to relate the fields that will be used in printing
  3. seletorFilial - the function responsible for opening the Branches selection screen.

...