Páginas filhas
  • Accounts Payable Clearing - FINA340 - Financials - P12

Versões comparadas

Chave

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

Índice
maxLevel2
minLevel2excludeIMPORTANT!
stylecircle

Informações
titleNote
This routine was adjusted to comply with the General Personal Data Protection Law (LGPD law No. 13.70), so that some fields containing data regarded as sensitive and/or personal are blurred, becoming illegible.

...

Bloco de código
languagejava
themeMidnight
titleExample of Automatic Routine
collapsetrue
#INCLUDE "Protheus.ch"
#INCLUDE "RWMAKE.CH"
#INCLUDE "TBICONN.CH"

Static __COMPAUT := Nil

User Function CMPAUTOMA()
	Local lRet := .F.
	Local cQry := ""
	Local aTipos := {"NF ", "PA ", "NDF"}
	Local cTblTmp := ""
	Local aNF := {}
	Local aPA_NDF := {}
	Local aContabil := {}
	Local bBlock := Nil
	Local aEstorno := {}
	Local nSldComp := 0
	Local nTaxaPA := 0
	Local nTaxaNF := 0
	Local nHdl := 0
	Local nOperacao := 0

	If __COMPAUT == Nil

		cQry := "SELECT E2_TIPO TIPO, R_E_C_N_O_ R_E_C_N_O FROM " + RetSqlName("SE2") + " "
		cQry += "WHERE E2_SALDO > 0 AND E2_TIPO IN (?) "
		cQry += "ORDER BY E2_TIPO" 
		cQry := ChangeQuery(cQry)
	__COMPAUT := FWPreparedStatement():New(cQry)
	EndIf

	__COMPAUT:SetIn(1, aTipos)
	cQry := __COMPAUT:GetFixQuery()
	cTblTmp := MpSysOpenQuery(cQry)

	While (cTblTmp)->(!Eof())
		If (cTblTmp)->TIPO $ MVPAGANT+"|"+MV_CPNEG
			Aadd(aPA_NDF, (cTblTmp)->R_E_C_N_O) 
		Else
			Aadd(aNF, (cTblTmp)->R_E_C_N_O)
		EndIf 

		(cTblTmp)->(DbSkip()) 
		lRet := .T.
	EndDo 

	(cTblTmp)->(DbCloseArea())
	cTblTmp := ""

	If lRet
		Pergunte("AFI340", .F.)
		lContabiliza := MV_PAR11 == 1
		lAglutina := MV_PAR08 == 1
		lDigita := MV_PAR09 == 1

		lRet := FinCmpAut(aNF, aPA_NDF, aContabil, bBlock, aEstorno, nSldComp, dDatabase, nTaxaPA ,nTaxaNF, nHdl, nOperacao)

		If lRet

			Alert("Compensation successful")

		Else

			Alert("An error occurred in the compensation process")

		EndIf

	EndIf
	
Return
Informações
titleNote

To use the Automatic Accounts Payable Clearing process, call the function: FinCmpAut. Clearing can be carried out from N to N: N advances/returns (PA or NDF) for N bills (NF, DP, etc.) or vice versa.

Automatic Accounts Payable Clearing

...

Use this operation to clear bills payable: 

 - Clearing bills from a supplier/store with advances from the same supplier/store

 - Clearing bills from a given supplier with advances from the same supplier regardless of the bill receivable store

 - Clear a bill from a given supplier with advances from several suppliers, in which case a supplier range or all suppliers can be established. Then, the bill can be cleared with any advance bill from the same supplier pending in the bill file, irrespective of the supplier for this bill.

...

Deck of Cards
idParameters
effectTypefade
Card
defaulttrue
id1
labelQuestions (F12)
effectTypefade

Question

Description

Consider store?

This field indicates whether to consider the store of the supplier when filtering records to be cleared. Thus, if you select "No", all "PA" bills from all stores are displayed for confirmation of clearing. If you select "Yes", only "PA" bills from the main bill store are considered. 

Consider Supplier?

Select option "Original" to consider same supplier of bill in clearing, or "Others" to clear bills between different suppliers. 

From Supplier?

Enter the initial code of the range of suppliers to be considered in clearing

To Supplier ?

Enter the final code of the range of stores to be considered in clearing

Cons. branches below?

Enter "Yes" to consider branches of your system, or "No" to consider only the branch you logged on. This question no longer affects the clearing process. Use button Branches to select the branches to be considered when selecting bills to be cleared.

From Branch?

Enter the initial code of the range of branches to be considered in clearing. This question no longer affects the clearing process. Use button Branches to select the branches to be considered when selecting bills to be cleared.

To Branch ?

Enter the final code of the range of branches to be considered in clearing. This question no longer affects the clearing process. Use button Branches to select the branches to be considered when selecting bills to be cleared.

Group Entries?

Enter "YES" to group the accounting entries generated through clearing in a single entry 

Display Entries?

Enter "YES" to display onscreen the accounting entries generated through clearing, otherwise "NO" 

Clear Bills? 

Enter option "Regular" for clearing to consider bills of type NF, PA, NDF, or "Tax" to consider TX and TXA generated tax bills.

Accounts online?

Enter "YES" to book online the entries related to accounts payable clearing, otherwise "NO". 

Clear transferred?

Enter "Yes" to allow clearing of bills transferred to bank (Bordereau), otherwise "No"

Clear tax balance?

Define not to zero TX balance when clearing between taxes, leaving the submission of DARF and tax payment pending, the feature of this question is only applied when
the question Clear Bills? = "Taxes"

Consider ps of tax. of PA?

Define, when clearing between regular NF x PA bills, if taxes of type TXA of PA have postings, whether these values are used to clear the balance of TX of NF, the feature of this question is only applied when
the question Clear Bills? = "Regular"
 

Card
id2
labelParameters (SX6)
effectTypefade

Parameter

Description 

Default

MV_CTBFLAG

Enter whether to select booking flags of the offline routines in the accounting entry transaction - SIGACTB.  

.F.

MV_BX10925

Define when withholding of PIS COFINS and CSLL taxes are processed: 1 = At Posting or 2 = At Issue  

1

MV_PABRUTO

Define, at PA generation with taxes, whether 1 = Generate a PA with gross value. 2 = Generate a PA with net value (system default).  

2

MV_LIBCHEQ

Option for release of bank balance when checks are generated before write-off.  

S

MV_PAPRIME

It defines whether, at PA generation with taxes, the INSS and ISS taxes are provisioned in the net PA. 1=Yes 2=No (default)  

2

MV_CTLIPAG

Control postings payable through filled out release date. If .T., the system checks whether field E2_DATALIB is filled out, otherwise it does not control them 

.F.

MV_VLMINPG

Minimum value to post the bill, even if field E2_DATALIB is not filled out and the content of parameter MV_CTLIPAG is .T.  

0

MV_IMPADT

Define the use of IRRF generation in advance payable  


MV_SOLNCP

Define the use of Credit Note request routine  

.F.

MV_MUNIC

Identifies the code of the finance department of the municipality for ISS collection.  

MUNIC

MV_MCUSTO

Currency used to check the credit limit entered in the customer register.  

2

MV_COMSEIC

Enable integration of service purchase order for Easy Siscoserv.  

.F.

MV_ESS0012

Enable integration of Incoming Document from SIGACOM to SIGAESS.  

.F.

MV_ESS0013

Enable integration of bills generated in SIGAFIN by SIGACOM for SIGAESS.  

.F.

MV_ESS0022

Enable SIGAEIC x SIGAESS Integration

.F.

MV_JURXFIN

Enable integration between modules SIGAFIN - Financials and SIGAPFS - Legal. Disabled by default.  


MV_PCOINTE

It indicates whether the integration of Planning and Budget Control processes with Entries/Locks processes is active (1=Yes / 2=No).

2

MV_BXDTFIN

To not allow postings dated before the date set in parameter MV_DATAFIM (1=Allow, 2=Do not Allow)  

2

MV_UNIAO

Identify the code given to the Federal Revenue for payment of Income Tax.  

UNION

MV_ESTADO

Acronym of the state of the company using the System, to calculate the ICMS (7, 12 or 18%).  

SP

MV_PISNAT

Nature for bills related to PIS.

PIS

MV_COFINS

Nature for bills related to COFINS.

COFINS

MV_CSLL

Nature for bills related to CSLL.

CSLL

MV_IRF

Nature for bills related to IRF.

IRF

MV_ISS

Nature for bills related to ISS.

ISS

MV_BP10925

Define whether to consider the gross value of partial posting or the net value plus taxes. (1=Gross Val./2=Net Val.)

1

MV_COMPCP

It indicates whether in an Invoice clearance with a PA, the taxes are proportionated.  

.F.

MV_MRETISS

ISS withholding mode in acquisition of services. 1 = when issuing main bill; 2 = when posting main bill  

1

MV_CPIMPAT

Indicate whether to clear taxes due automatically. 1 - Automatic; 2 - Manual  

2

MV_AG10925

Enter whether to combine CCP taxes in one bill only when the three taxes occur in the same bill.  

2

MV_FINVDOC

Activate control of required documents in routines for releasing bill payable postings/transactions? ("1" = Yes / "2" = No)  

2

MV_CMTXCON

Indicate whether to generate indexation for bills with rate contracted at CP clearing. T = Generate CM / F = Do Not Generate CM  

.F.

MV_CALCCM

Indicate whether to calculate indexation. Valid: "S" - calculate it or "N" - do not calculate it.  

S

MV_TXPRCON

Define whether to use the rate entered in clearing in entire process. T = Rt in Process, F = Individual Rt

.F.

05. ACCOUNTING

The booking of processes applied to an accounts payable clearing via Financials module is done through the standard entries below:

...

SE

...

Taxable Event

...

ON

...

OFF (CTBAFIN)

...

589

...

Cancellation of clearing of accounts payable bills

...

X

...

X

...

597

...

Clearing of accounts payable 

...

X

...

X

Options to set parameters MV_PABRUTO, MV_BP10925, MV_PAPRIME 

When parameter MV_PABRUTO, is equal to 2 (Net), when you generate bills of type PA (advance payment), the generation with net value is maintained, in which the tax values that can be withheld at addition are deducted.

For example, when you clear a bill of type INVOICE with a PA, given that both withhold taxes at posting, for coherent values you should set the parameters below as follows:

  • MV_COMPCP= .T. - Indicate whether in an Invoice clearance with a PA, the taxes are proportionated.
  • MV_BP10925 = 2 - Consider the Net Value in Partial Posting, deducting taxes.
  • MV_PAPRIME = 1 - Consider tax provisioning for net PA. 

When parameter MV_PABRUTO is equal to 1 (Gross), when you generate bills of type PA, it is generated with gross value, not deducting the tax values that can be withheld at addition. Then you must clear an Invoice with a PA by the gross value, setting parameters as follows:  

  • MV_PABRUTO = 1 - Gross and MV_BX10925 = 1 Tax at posting or MV_BX10925=2 Tax at issue
  • MV_BP10925 = 1 - Consider the Gross Value in Partial Posting, without deducting taxes.
  • MV_PAPRIME = 2 - Do not consider tax provisioning for net PA.


Aviso
titleImportant

If you do not configure the system with one of these two options, upon reversal, the bill of type PA may acquire the status partially cleared.

Informações
titleNote
Parameter MV_COMPCP has no effect if parameter MV_PABRUTO is set to 1. You need to set these parameters whether bills have taxes or not.
Informações
titleNatures

The clearing between Invoice x PA, from the invoice as well as from the PA, is not allowed if parameter MV_PABRUTO is set to 2 (Net) and the natures are different.

However, we recommend using the same financial nature for Invoice and PA bills, to make sure the tax values generated do not diverge.

05. ACCOUNTING

The booking of processes applied to an accounts payable clearing via Financials module is done through the standard entries below:

SE

Taxable Event

ON

OFF (CTBAFIN)

589

Cancellation of clearing of accounts payable bills

X

X

597

Clearing of accounts payable 

X

X


Card documentos
InformacaoThe booking of clearing will always be made based on the data of the Cleared Bill and it can be any type of obligation: NF, TX, DP, etc. as long as the transfer (SE5) has the following classification: E5_TIPODOC = 'CP' and E5_MOTBX = 'CMP'
TituloIMPORTANT!

Booking Variables

Totvs custom tabs box
tabsOnline,Offline,Example
idsonline,offline,example
Totvs custom tabs box items
defaultyes
referenciaonline

The following list of variables to configure Standardized Entry 597 (Accounts Payable Clearing) for online booking of Payable Clearing (FINA340):

VALOR - Stores the value cleared
VALOR2 - Addition Value
VALOR3 - Deduction Value
VALOR4 - Variation of Adjustment for Inflation
VLRINSTR - Stores the value cleared
nSldReal - Stores the value cleared in the corresponding currency of bill
ABATIMENTO - Deduction Values
REGVALOR - Recno of current record
STRLCTPAD - Key of main bill + document number

These variables are fed with data from the record that originated the clearing. Whereas for records selected for clearing, the booking is made by SE5. 

In online booking, you cannot change the booking branch. The booking occurs at the branch selected.


Example:

Select NF1 and click Clear.

On the screen for selecting bills to be cleared, select PA1 and PA2.

When booking online, the NF1 information will be in the booking variables. Whereas the clearing data of each PA will have their respective SE5 records selected.


Reversal Variables:

VALUE - Stores the value cleared
VLRINSTR - Stores the value cleared

Totvs custom tabs box items
defaultno
referenciaoffline

When we force the selection of bills to be cleared, the booking brings both bills (example: Invoice x PA), booking the value of both bills, which may cause a double entry.

The variables available for offline booking (CTBAFIN):

VALOR - Stores the value cleared
VALOR2 - Addition Value
VALOR3 - Deduction Value
REGVALOR - RECNO of current record
STRLCTPAD - Key of main bill + document number

These variables are fed with data from the record that originated the clearing. Whereas for records selected for clearing, the booking is made by SE5.

Totvs custom tabs box items
defaultno
referenciaexample

Example: LP597

In field CT5_HIST, enter: U_HIST597()

Create the following function:


Bloco de código
languagejava
themeMidnight
firstline1
linenumberstrue
User function HIST597()
    Local aSaveSE5 := SE5->(GetArea())
    Local aSaveSE2 := SE2->(GetArea())
    Local xRet := Nil

    If REGVALOR <> 0
        SE2->(dbGoto(REGVALOR))
        xRet:= "TESTE TIPO: "+ SE2->E2_TIPO + " RECNO: "+ ALLTRIM(STR(SE2->(RECNO())))
    Else
        xRet:= "TESTE TIPO: "+ SE5->E5_TIPO + " TIPODOC: "+SE5->E5_TIPODOC + " RECNO: "+ ALLTRIM(STR(SE5->(RECNO())))
    Endif

    RestArea(aSaveSE2)
    RestArea(aSaveSE5)
Return(xRet)

Card documentos
InformacaoThe booking of clearing will always be made based on the data of the Cleared Bill and it can be any type of obligation: NF, TX, DP, etc. as long as the transfer (SE5) has the following classification: E5_TIPODOC = 'CP' and E5_MOTBX = 'CMP'
TituloIMPORTANT!

Informações
titleInformation

Booking of DIC type

The booking of DIC type generated by clearing can be done by LP 510 - Addition of Bill Payable, because it is generated through the FINA050 (Accounts Payable) automatic routine.


Booking of taxes generated when clearing.

LP 597 - Clearing Payable itself can book taxes generated by clearing, through variables: NPIS340, NCOF340, NCSL340, NIRF340, NISS340.

In the other cases, the booking remains unchanged, as documented below:

Booking Variables FINA340

NIRF340, NISS340.


See Also:

Booking of CR/CP Clearings

06. TABLES

  • SE2 - Accounts Payable Register 
  • SE5 - Checks Register 
  • SED - Natures Register
  • SA2 - Suppliers Register
  • FK2 - Postings Payable
  • FK3 - Calculated Taxes
  • FK4 - Withheld Taxes
  • FK5 - Bank Transactions
  • FK6 - Accessory Values
  • FK7 - Auxiliary Table  
  • FKA - Transaction Tracking

...

Deck of Cards
idDIC - Cleared Taxes Difference
effectTypefade
Card
id3
labelAccumulated DIC
effectTypefade
Aviso
titleAttention

The process described refers only to the net scenario:

MV_PABRUTO = 2 (Net)

MV_COMPCP = .T.

MV_BP10925 = 2

MV_PAPRIME = 1


For gross scenario, clearings occur without generation of accumulated DIC.


Accumulated DIC

When clearing a NF that has withholding in posting with multiple advance payments not configured for withholding, a single bill of type DIC is generated for the last cleared PA. The DIC will have the accumulated value of the difference of calculated taxes of the other PAs.


Example: Clearing between one 3 PAs without withholding X 1 NF with withholding

NF of BRL 1,000.00

With PCC in posting (4.65%) = BRL 46.50

Total Net Value = BRL 1,000.00 (value of NF) - BRL 46.50 (taxes in posting) = BRL 953.50

NF balance = BRL 1,000.00 


PA 1 of BRL 300.00

Without taxes

Net Value = BRL 300.00

PA balance = BRL 300.00


PA 2 of BRL 300.00

Without taxes

Net Value = BRL 300.00

PA balance = BRL 300.00


PA 3 of BRL 300.00

Without taxes

Net Value = BRL 300.00

PA balance = BRL 300.00


The routine performs the clearing calculation internally in three parts, as if it was clearing each PA separately, generating the DIC only in the last clearing.
 

1st clearing - Clear NF x PA:

NF balance = BRL 1,000.00 (NF balance) - BRL 13.95 (PCC generated in clearing) - BRL 286.05 (cleared value) = 700.00

Transaction: BRL 300.00

Generated the taxes configured in posting, in example, PCC in value of BRL 13.95 with calculation base of BRL 300.00

PA balance = 300.00 (PA balance) - 300.00 (cleared value) = 0.00

Value related to Difference of calculated tax: 13.95

*Important

As previously mentioned, the DIC is not generated at this time.


2nd clearing - Clear NF x PA:

NF balance = BRL 700.00 (NF balance) - BRL 13.95 (PCC generated in clearing) - BRL 286.05 (cleared value) = 400.00

Transaction: BRL 300.00

Generated the taxes configured in posting, in example, PCC in value of BRL 13.95 with calculation base of BRL 300.00

PA balance = 300.00 (PA balance) - 300.00 (cleared value) = 0.00

Value related to difference of calculated tax: 13.95

*Important

As previously mentioned, the DIC is not generated at this time.


3rd clearing - Clear NF x PA:

NF balance = BRL 400.00 (NF balance) - BRL 13.95 (PCC generated in clearing) - BRL 286.05 (cleared value) = 100.00

Transaction: BRL 300.00

Generated the taxes configured in posting, in example, PCC in value of BRL 13.95 with calculation base of BRL 300.00

PA balance = 300.00 (PA balance) - 300.00 (cleared value) = 0.00

Value related to Difference of calculated tax: 13.95


Aviso
titleImportant

The DIC is only generated at this time. In accumulated value of 41.85.


Generated DIC value = 13.95 (DIC calculated in 1st clearing) + 13.95 (DIC calculated in 2nd clearing) + 13.95 (DIC calculated in 3rd clearing) = 41.85

Card
id2
labelTotal clearing without DIC generation
effectTypefade
Aviso
titleAttention

The process described refers only to the net scenario:

MV_PABRUTO = 2 (Net)

MV_COMPCP = .T.

MV_BP10925 = 2

MV_PAPRIME = 1

Total clearing without DIC generation

When clearing a NF that has withholding with PAs without withholding, in which the net value of NF is the total of PAs, the routine does not generate DIC.


Example: Total clearing between one 2 PAs without tax X NF with taxes

NF of BRL 1,000.00

With PCC in Posting (4.65%) = BRL 46.50

Total Net Value = BRL 1,000.00 (value of NF) - BRL 46.50 (taxes in posting) = BRL 953.50

NF balance = BRL 1,000.00 


PA of BRL 500.00

Without taxes

Net Value = BRL 500.00

PA balance = BRL 500.00


PA of BRL 453.50

Without taxes

Net Value = BRL 453.50

PA balance = BRL 453.50


Clear 1 NF x 2 PAs

Notice the net value of invoice is equal to the sum of PAs, thus no additional value was paid to the supplier:

The withholdings set to be calculated in posting will be generated. In the example, PCC in the value of BRL 23.25 related to the first clearing.

The withholdings set to be calculated in posting will be generated. In the example, PCC in the value of BRL 23.25 related to the second clearing.

NF balance = BRL 1,000.00 (NF balance) - BRL 23.25 (PCC Generated in 1st clearing) - BRL 23.25 (PCC Generated in 2nd clearing) - BRL 500,00 (cleared value of 1st PA) - BRL 453.50 (cleared value of 2nd PA)

1st PA balance = 500.00 (PA balance) - 500.00 (cleared value) = 0.00

PA balance = 453.50 (PA balance) - 453.00 (cleared value) = 0.00

We have no DIC generation

Example: Reversal of 2nd clearing (2nd PA).

When reversing 2nd clearing (2nd PA):

The withholdings generated will be deleted upon clearing. In the example, PCC in the value of BRL 23.25

NF balance = 500.00

PA balance = 453.50

The system evaluates the clearings previous to the last one reversed and identifies whether a new DIC generation is needed.

Generated DIC value = 23.25 (DIC calculated in 1st clearing) = 23.25

The DIC bill generated refers to the last clearing. In the above example it would be the 1st PA in the value of 500.


Aviso
titleAttention

For clearings done individually (1 PA x 1 NF), the system generates an independent DIC, that is, one DIC for each clearing. No accumulated DIC will be generated

Card
id1
labelDIC Booking
effectTypefade

DIC Booking

You can book the addition of a DIC type bill through LP 510 (Accounts Payable - Addition of Bills).

You can book the deletion of a DIC type bill through LP 515 (Accounts Payable - Deletion of Bills).

Note: To book the LPs 510 and 515, the question: Book Online of routine Accounts payable (FINA050) must be set to Yes.

Card
id1
labelDIC generation at time of reversal
effectTypefade
Aviso
titleAttention

The process described refers only to the net scenario:

MV_PABRUTO = 2 (Net)

MV_COMPCP = .T.

MV_BP10925 = 2

MV_PAPRIME = 1

Process of DIC generation at time of reversal


For clearances with more than one bill, you can only revert/delete by clearing order. From the last clearing to the first, any different order of this routine will display a warning blocking the process.

When you reverse/delete the last clearing, the routine also deletes the DIC-type bill. After this process, a new DIC related to previous clearings is generated based on the last cleared PA if needed.


Example: Reversal of 3rd clearing

NF balance = BRL 100.00 (NF balance) + BRL 13.95 (PCC generated in clearing) + BRL 286.05 (compensated value) = 400.00
Transaction: BRL 300.00

Withholdings generated by clearing will be deleted. In example, PCC in value of BRL 13.95 with calculation base of BRL 300.00

Deletion of DIC generated by clearing with value of BRL 41.85 (accumulated DIC).

PA balance = 0.00 (PA balance) + 300.00 (cleared value) = 300.00

The system evaluates the clearings previous to the last one reversed and identifies whether a new DIC generation is needed.

Generated DIC value = 13.95 (DIC calculated in 1st clearing) + 13.95 (DIC calculated in 2nd clearing) = 27.90
At this point, a new DIC-type bill is generated related to the first and second clearing.


Example: Reversal of 2nd clearing

NF balance = BRL 400.00 (NF balance) + BRL 13.95 (PCC generated in clearing) + BRL 286.05 (compensated value) = 700.00

Transaction: BRL 300.00

Withholdings generated by clearing will be deleted. In example, PCC in value of BRL 13.95 with calculation base of BRL 300.00

Deletion of DIC generated by reversal with value of BRL 27.90 (accumulated DIC)

PA balance = 0.00 (PA balance) + 300.00 (cleared value) = 300.00

The system evaluates the clearings previous to the last one reversed and identifies whether a new DIC generation is needed.

Generated DIC value = 13.95 (DIC calculated in 1st clearing) = 13.95

At this point, a new DIC bill related to the last clearing is generated. In the example above, it would be the 1st PA with the value of 300.

09. MORE INFORMATION


Informações
titleNOTITSEL in reversal of clearing

Upon opening the wizard NOTITSEL in reversal of clearing, validate field E5_FILORIG in clearing records and also check fields of key (Prefix+number+installment+type+supplier+store) of tables SE2 and SE5. Fields must have corresponding sizes in both tables.



Deck of Cards
idSee Also
effectTypefade
Card
id1
labelSee Also
effectTypefade