Accounts payable are commitments represented by the purchase of goods, services, salaries, taxes, leasing, loans, contributions, machinery, inputs for production, and more.
The Accounts Payable routine of the Microsiga Protheus system controls all documents, also called bills, that the company pays and which can be: trade notes, checks, promissory notes, prepayments, advance payments, invoices, etc. The data registered contribute to decision making on all company commitments that involve the disbursement of resources, being also attributed to the following criteria:
The types of bills identify the amount pertaining to a determined income or expense. You must define them in table 05 (Bill Types) of the Configurator module or in the Bill Types routine. |
You can add a bill to the portfolio payable manually (by personally typing bills) or automatically (from incoming invoices, provided that the Purchases and/or Stock and Costs modules are integrated with the Financial module).
To automatically generate the bill, the Purchases and/or Stock and Costs modules must be deployed and integrated, because the process depends on the receipt of incoming documents and purchase orders.
To configure installments alphabetically, set the content of parameter MV_1DUP to the letter A. Yet, to divide installments numerically, select option 1. |
Grouping the bills by nature generates results in a structured and organized manner (reports), which is a powerful management tool.
Use the breakdown option to generate multiple bills from a single bill, all with the same value (installment) or the value divided by the number of installments (total).
Invoicing, when integrated, generates bills payable through the Commission Update routine. These bills are displayed by default with option COM. Set parameter MV_3DUPREF to define their prefix.
The system tracks the suppliers history details like maximum balance, average and maximum arrears and control of balances payable as value due, overdue and others.
When paying bills, the system offers company X bank features, such as automatic payments and printing checks. You can post bills payable either manually or automatically, by unit or by batches received from banks.
You can control bills regarded for cash flow purposes, because when you add accounts payable, the system updates this flow and makes accounting entries through parameter settings and standardized entries.
Study the chart below to become acquainted with the features of this routine:
Before you start the addition process, press key [F12\] to set routine parameters, following these criteria:
Field: | Description |
Display Acctg. Entry? | Select Yes or No to indicate whether to display accounting entry when booking online. Yes. |
Book Prov. Bills? | Select Yes or No to indicate whether to book provisional bills. No. |
Ent. accts in apportionment? | Select Yes or No whether to display fields for entry of debit and credit accounts in bill apportionment. Yes. |
Online Booking? | Select Yes or No to indicate whether to book transactions online; that is, one at a time (adding a bill, posting, generating a check, deleting, etc.) or offline, with all entries not made online are booked in one batch process. No. |
Gen. check f/ Adv.? | Select Yes or No to indicate whether to generate check for advance payment bills. Thus, the system enables field Check when you add the advance payment and when you enter its number, the bank transaction occurs. Yes. |
Apportion value? | Enter value for accounts payable apportionment. It offers options Gross (bill value plus taxes) and Net (value without taxes). Gross. |
Group Accounting Entry? | Select Yes or No to indicate whether to group accounting entries of apportionment in a single line, if accounts, cost center, item and value class are the same in the entries. No. |
Display apportionment deletion? | Select Yes or No to display apportionment screen when deleting the bill. Yes. |
Bank Trans. w/out check? | Enter whether to generate bank transaction when field Gen. Check f/ Adv. is filled out with option No. It offers these options:
Example: No. |
Gen. apportionment? | For situations involving multiple natures, enter whether to generate apportionment as nature/cost center. For tax values, it is applied only if value apportionment option is filled out as net. It offers options Bill and Bill/Taxes. Bill. |
Add Apportionment of a bill from a module other than Financials. | Select the bill and go to option Edit, access tab Accounting and find the field Apportionment (E2_RATEIO). When you select Yes or No, the apportionment screen is displayed. No. Note: The bill cannot be booked for this situation. |
In the main page of the routine, the following options are available:
|
General Data
Field: | Description |
Prefix: | To identify a set of bills that belong to the same group or branch. Once you enter the prefix, it becomes an integral part of the access key to the bill. |
Bill No.: | Enter bill number. |
Installment: | Enter bill installment. The system allows you to control the breakdowns of a bill. |
Type: | Classify the bill by its purpose. The types are registered in table 05 (Bill Types) of module Configurator or in routine Bill Types. If needed, you can use the Standard Query feature to select the bill and fill out the field.
|
Nature: | Identify the origin of the nature of the bill and use this item for consolidation, as well as to control the budget. If needed, you can use the Standard Query feature to select the nature of the bill and fill out the field. |
Supplier: | Enter supplier code. If needed, you can use the Standard Query feature to select the registered supplier and fill out the field. |
Store: | Enter the code of the supplier's store. |
Supplier Name | Display the name of the supplier. This is automatically filled out in accordance with the content of field Supplier. |
Issue Dt.: | Date of bill issue. |
Due date: | Enter the nominal due date of bill also taking any possible postponements into account. |
Actual Due Date: | Actual due date of bill automatically calculated from the date entered in field Due Date. |
Bill Value: | Original value of the bill in currency. |
History: | Use this field to add a short note about the bill. |
Balance: | In this field, the system keeps the updated balance of the bill value after each transaction you make. |
Currency: | Code of the currency used in the bill. Currency 1 = default domestic currency and currencies 2 to 5 in accordance with criteria set in parameters MV_MOEDA2, MV_MOEDA3, MV_MOEDA4 and MV_MOEDA5 through the Configurator module. |
Vl. BRL: | Value of bill stated in currency. |
Currency Rate: | If you enter a rate, it is used as conversion base at the time of posting; otherwise, the rate contracted or the currency date on day of posting is used. |
Appr. Code: | Approver code of bill following simple approval rules or fixed fund competence. If needed, you can use the Standard Query feature to select the approver of the bill and fill out the field. |
Taxes
The fields of this folder are automatically filled out in accordance with the instructions registered in routines Nature and Supplier (here tax withholding follows the business rule attributed to the supplier).
The field contents can also come from routines that involve integrated processes, such as the TIO and Product registers.
Note
You can adjust the values that are automatically filled out; however, they interfere in the calculation of the bill for payment.
Field: | Description |
ISS: | The content of this field refers to service tax and is automatically calculated by the system following this priority:
|
IRRF: | Field IRRF (Income Tax Withheld by Tax Authorities) is automatically calculated in accordance with the priorities set for Natural Person and Legal Entity.
|
Data of the main bill BRL 7,300.00 (BRL 10,000.00) | |
IRRF - BRL 2,700.00. | |
Bill issue date - 9/1/2015. | |
Bill due date - 10/12/2015. |
Data of TX bill from generated IRRF |
Main value of bill BRL 2,700.00. |
Bill due date 10/10/2015. |
Due Date - V
Data of the main bill BRL 7,300.00 (BRL 10,000.00) |
IRRF - BRL 2,700.00. |
Bill issue date - 9/1/2015. |
Bill due date - 10/12/2015. |
Data of TX bill from generated IRRF |
Main value of bill BRL 2,700.00. |
Bill due date 11/10/2015. |
Booking - C
Data of the main bill BRL 7,300.00 (BRL 10,000.00) |
IRRF - BRL 2,700.00. |
Bill issue date - 9/1/2015. |
Bill due date - 10/12/2015. |
Booking date - 9/1/2015. |
Data of TX bill from generated IRRF |
Main value of bill BRL 2,700.00. |
Bill due date 10/10/2015. |
Note
If you do not create parameter MV_VCTIRPF, the system maintains the same process to generate the IRRF, in accordance with parameter MV_VENCIRF, for Natural Persons as well as for Legal Entities.
MV_TMSVDEP: calculates the IRRF of Natural Persons when issuing accounts payable bills, considering the number of dependents; thus, the bill generation deducts from the IRRF the value per dependent defined by the Federal Revenue Service.
Legal Entity Supplier
The system checks the fields Calculate IRRF and IRRF Perc. found in the Natures register, as well as the content of parameter MV_ALIQIRF.
Example:
Rate set to 3% in parameter MV_ALIQIRF and a nature that calculates IRRF with a percentage of 8%. When you add bill of BRL 1,000.00, the system fills out field IRRF with the value of BRL 80.00 (with reference to the Natures register).
Note
IR calculation and withholding for Legal Entities, pursuant to article 724, item II from RIR, approved by Decree No. 3,000/99
The withholding of taxes by tax authorities occurs only for incomes that integrate the calculation base of taxes owed by Legal Entities the taxing of which is based on taxable income, presumed profit or estimated profit.
It is understood that the IR-Fonte generator factor related to services rendered by Legal Entities to other Legal Entities is on daily basis; therefore, you must add invoices from the same supplier on the same day for limitation purposes, and not add invoices the generator factors of which occur in different days.
Thus, if in the month more than one payment is made or incomes are credited to the same Legal Entity, the tax is calculated on the value of each factor and, if the minimum value of BRL 10.00 is not reached, exemption of tax withholding is granted, even if the tax amount calculated in the month on the sum of these incomes surpasses this limit.
Example:
Description | Values |
Invoice No. 100. | BRL 550.00 |
Invoice No. 120. | BRL 650.00 |
Total payable on 09/10/15. | BRL 1,200.00 |
IRRF to be withheld (BRL 1,200.00 x 1.5%). | BRL 18.00 |
Net value payable to supplier (with IR withholding) | BRL 1,182.00 |
The system calculates the IRRF in accordance with the Progressive Table for Legal Entity Supplier in the case of freelance business agents that only mediate business trades done by third parties.
To perform the calculation, you must associate a Supplier (Legal Entity) and fill out field IRRF Sch. with option Yes when adding a bill of accounts payable.
Besides the Progressive Table, you must also set some influential parameters:
MV_VENCIRF and MV_MP447: IRRF withholding when generating bills payable with the parameter, in accordance with Provisional Measure 447/2008.
The due dates of generated tax bills (IRRF and INSS) are calculated up to the twentieth day of the following month.
Example:
Tax | Parameter Config. | Issue of original bill | Original Bill Maturity | Original Bill Actual Due Date | Due Date |
IRRF | Issue (MV_VENCIRF) | 11/21/15 | 12/20/2015 | 12/22/2015 | 12/19/2015 |
IRRF | Due date (MV_VENCIRF) | 11/21/15 | 12/20/2015 | 12/22/2015 | 01/20/2015 |
Note
The parameter MV_MP447 is only taken into account in calculation of due date for IRRF and INSS if the occurrence date on the bill (Issue Date or Due Date) starts on 11/1/15. In the example, both the issue date and due date are considered in this parameter.
MV_VENCCRC: exclusive process to generate IRRF taxes pursuant to article 34 of Law No. 10,833.
The Federal Public Administration entities, pursuant to article 34 of law No. 10,833, are required to withhold Income Tax, CSLL, COFINS and PIS/PASEP on bills payable.
To meet the demands of this legislation, you must configure the parameter MV_VENCCRC with default content equal to 6147#6175#6188#8739#8767#6190.
Example:
Data of the main bill BRL 9,850.00 (BRL 10,000.00) |
IRRF - BRL 150.00. |
Bill issue date - 9/1/2015. |
Bill due date - 09/19/2015. |
Data of TX bill from generated IRRF |
Main value of bill BRL 150.00. |
Bill due date 10/13/2015. |
Note
If you do not create the parameter MV_VENCCRC, the system maintains its default process defined in parameter MV_VENCIRF, pursuant to article 70 of law 11,196 from 11/21/2005. As exemplified and in accordance with parameter MV_VENCIRF, the IRRF bill due date is 10/10/15.
|
INSS: | This field pertains the Contribution to the National Institute of Social Security. The system automatically fills it out when a bill payable is added, following these criteria: |
MV_VENCIRF and MV_MP447: INSS withholding when generating bills payable, in accordance with Provisional Measure 447/2008.
The due dates of generated tax bills (IRRF and INSS) are calculated up to the twentieth day of the following month:
Example:
Tax | Parameter Configuration | Original bill issue | Original bill due date | Original bill actual due date | Due date |
INSS | Issue (MV_VENCINS) | 11/21/15 | 12/20/2015 | 12/22/2015 | 12/19/2015 |
INSS | Due date (MV_VENCINS) | 11/21/15 | 12/20/2015 | 12/22/2015 | 01/20/2015 |
Note
The parameter MV_MP447 is only taken into account in calculation of due date for IRRF and INSS if the occurrence date on the bill (Issue Date or Due Date) starts on 11/1/15. In the example, both the issue date and due date are considered in this parameter.|
Generate DIRF: | Enter whether the bill is used for DIRF generation in integration with Payroll. Fill out this field by selecting between options: 1-Yes and 2-No. |
Withholding Code: | Use this field to make the exclusive codes for tax withholdings more flexible, when you add an invoice through modules Purchases or Financials with the withholding of PIS, COFINS or CSLL taxes and fields PIS Withh., COF. Withh. Code, or CSL Withh. Code are filled out; thus, the data are saved in the Parent trade note, ignoring the codes that are currently preset in the system, which are: |
Bill withholds the three taxes: PIS, COFINS and CSLL.
Main value | BRL 6,000.00 |
PIS | BRL 39.00 |
COFINS | BRL 180.00 |
CSLL | BRL 60.00 |
Withholding Code | 5952 |
Bill collects only PIS tax:
Main value | BRL 6,000.00 |
PIS | BRL 39.00 |
COFINS | BRL 0.00 |
CSLL | BRL 0.00 |
Withholding Code | 5979 |
Bill collects only COFINS tax:
Main value | BRL 6,000.00 |
PIS | BRL 0.00 |
COFINS | BRL 180.00 |
CSLL | BRL 0.00 |
Withholding Code | 5960 |
Bill collects only CSLL tax:
Main value | BRL 6,000.00 |
PIS | BRL 0.00 |
COFINS | BRL 0.00 |
CSLL | BRL 60.00 |
Withholding Code | 5987 |
Addition of a bill payable with fields PIS Withh. Code = 3770 / COF Withh. Code = 5960 / CSL Withh. Code = 5987 filled out:
Main value | BRL 6,000.00 |
PIS | BRL 39.00 |
COFINS | BRL 180.00 |
CSLL | BRL 60.00 |
Withholding Code | 3770 |
COFINS.Withh.Code | 5960 |
CSL.Withh.Code | 5987 |
SEST/SENAT: | The calculation of SEST/SENAT (Transportation Social Service / Transport Learning National Service) payment amounts, which the Financials module can generate when the Transportation Management module is not in use. |
COFINS: | Contribution value for Social Security Financing calculated on the gross revenue of companies. |
PIS/PASEP: | Value that corresponds to the 1% rate levied on payroll. |
CSLL: | Value that corresponds to the Social Contribution rate on profits in accordance with the activities performed. |
PCC Base: | Base value used to calculate the tax. |
ISS Due Date: | Due Date of ISS generated when adding the Incoming Invoice. |
Serv. Ac. Val.: | Value of service received within the month, in accordance with Municipal Law No. 1,802, dated 26 of December of 1969, of Sao Bernardo do Campo - SP. |
DCTF Variat.: | Enter the variation for the revenue code in accordance with the Codes Table in DCTF. |
DCTF Per.: | Enter the periodicity of the revenue code used in DCTF. |
A: for annual periodicity.|
ISS Withh. Form.: | Enter the condition to be applied in calculation of ISSQN withholding (Service Tax of Any Nature) for this bill, which can consider the minimum value for withholding or always withhold it. Fill out this field with one of these options: |
Apply Min. Val.: | Define whether the values of PIS/COFINS withholding entered in bill payable must respect the minimum withholding value of BRL 5,000.00, introduced in Law 10,925 or withhold it regardless of the value. Fill out this field with one of these options: |
FETHAB Inst.: | Installment number of FETHAB (State Fund for Transport and Housing). |
FETHAB Val.: | Bill value of FETHAB (State Fund for Transport and Housing). |
ISS Rate Code: | This field remains enabled when the ISS rate is registered through routine ISS Multiple Rates, thus allowing the selection of an ISS rate for the bill payable. If you do not fill out this field, the rate used in bill payable is the rate set in parameter MV_ALIQISS. |
IRPF Base: | Tax calculation base (when only this field is enabled) or IRRF Calculation base when other tax base fields are enabled. Thus, it defines whether the IRPF calculation is reduced, meeting the cases mentioned in the Normative Instruction SRF No. 15 from February 6, 2001. |
Nature Register: nature that calculates income tax and that has reduced base.
Note
Legal Grounds
Normative Instruction SRF No. 15 dated February 6, 2001
Art. 12. Real estate rentals paid by Legal Entity are not part of the calculation base for income tax levy purposes:
I - Value of taxes (IPTU), rates, and emoluments levied on the asset that produces income;
II - Rent paid by the rental of sublet real estate;
III - Expenses paid for collection (bank bill) or receipt;
IV - Condominium expenses.
§ 1st The charges above can only be deleted from the rental value when burden has been exclusively to the landlord.
§ 2nd When rent is paid by real estate offices, legal representative, or by any person chosen by the landlord, the payment date considered is that one in which the tenant made the payment, regardless of when it goes to the beneficiary.
§ 3rd Compensation by advance termination or contract termination is considered taxed income for the beneficiary.|
INSS Withh. Code: | Code of INSS withholding. |
DARF ID: | DARF identification (Federal Revenues Collection Document). |
INSS Prov.: | This field stores the INSS provisioning for bills of type PA (Advance Payment) in accordance with the settings of parameters MV_PABRUTO=2 and MV_PAPRIME=2. |
FABOV Inst.: | Installment of tax FABOV (Cattle Raising Development Fund). |
FABOV Val.: | Value of tax FABOV (Cattle Raising Development Fund). |
FACS Inst.: | Installment of tax FACS (Soy Culture Development Fund). |
FACS Val.: | Value of tax FACS (Soy Culture Development Fund). |
Administration
Field: | Description |
Delinq. Fee: | In this field, enter the value to be added to the bill for each day of payment arrears. For calculation purposes, the system takes consecutive days into account and this field has priority on field Interest Perc. at bill posting. |
Bill value received: 1,005.00.|
Interest Perc.: | In this field, enter the interest percentage to be levied per day on the original bill value for payment arrears. For calculation purposes, the system uses consecutive days. |
Value received: 1,050.00.|
Addition: | Added value applied to bill. It is added at the time of posting, even if the bill is paid until the due date, with a fixed addition value known at the time of deployment. |
Cash flow: | In this field, define whether the bill must be considered in cash flow; that is, in the control of the financial transaction pertaining the inflows and outflows of financial resources. The options available for its completion are: |
N - No.|
Breakdown: | This field allows you to generate several bills with different due dates, from a single addition. Use this resource for expenses with fixed due dates (such as rental payments). |
After cancellation, when the default procedure of cumulativeness for withholding taxes is not followed.
Note
You can delete bills with breakdowns in the Accounts Receivable routine.|
Approver: | Approver required for bill payment. You can use it in the workflow process. |
Reduction: | This field defines a reduction value applied to the bill. When entered in the posting payable (regardless of posting date), the system reduces the value entered in this field from the value of the bill. |
Mult. Natures: | Use this field to define whether to classify bills in multiple natures. To enable this field while adding a bill payable, set parameter MV_MULNATP to T. |
509 - Cancellation of apportionment by cost center of distribution in multiple natures.
These standard entries are available for online (508, 509) or offline (508) accounting and must be used together with standard entry 510 (addition of accounts payable bills).
Distributions of values by multiple natures that do not use apportionment by cost center are booked as additions (standard entry 510).
Distributions that use apportionment by cost center are booked by the aforementioned entries (however, standard entry 508 is not executed if standard entry 510 does not exist).
You must book bills payable using the same standard entry for bill addition/deletion. Simply enter the value to be booked in the Standard Entry register. If you do not follow this procedure, the value booked may become duplicated.
Note
When you add bills payable with apportionment via automatic routine, set parameter MV_RATAUTO to .T. to display the multi-nature apportionment screen.|
Rate Currency indexation rate Currency: | Field that contains the last rate used in indexation calculation for bills with currency other than 1. |
Has Docs: | Define whether the bill has linked documents that aim to block bills payable that do not present required documents. |
Bank
Field: | Description |
Bearer: | Code of bearer used for identifying the collection agent in charge of collecting the bill. |
Payment Mod.: | Expected payment modality. |
Sched. date: | Date scheduled for bill clearing. |
Typ. Field: | Data related to the typable field of bill. |
Sup. branch: | Bank branch of supplier payment of bill payable. |
DV branch: | Verification digit of bank branch of supplier payment of bill payable. |
Sup. account: | Bank account of supplier payment of bill payable. |
DV account: | Verification digit of bank account of supplier payment of bill payable. |
Sup. bank: | Bank of supplier payment of bill payable. |
Paymt Method: | Enter the preferred payment method for supplier. |
Accounting
Field: | Description |
Apportionment: | Enter whether the bill value must be apportioned in various cost centers by selecting one of the options S - Yes and N - No. |
512 - Deletion of accounts payable bill with apportionment. \\ \\ You must check the configuration of fields activated by pressing *\[F12\]{*}, as they determine the value used in the apportionment (gross or net), grouping of entries, ledger account data, etc. \\ Note \\ Apportionments entered for the accounts payable process have an internal control as a single entry key through field *Seq. It.* (not displayed onscreen), in which the apportionment rows are automatically and sequentially numbered as items. \\ Set parameter *MV_INTPMS* to apportion accounts payable by project.| |
Ledger acct: | Define the ledger account in which to manually create the ledger entry in budget plans related to accounts payable. |
Daily seq.: | Sequential code of journal for accounting. |
Journal code: | Code of journal to be used for transaction. |
Cost c.: | Cost Center used in the accounts payable process. |
Others
Field: | Description |
Proj. Apport.: | Indicator of apportionment of Projects (linked to PMS - Project Management). Select option 1 - Yes or 2 - No to fill out the content of this field. |
Budg. Code: | Represents the code of budget plan and the request is validated in this plan in relation to budgeted and executed. The system always uses the content of this plan with the default plan set in parameter MV_PLAPAD; however, you can also enter the desired plan to make the purchase and, consequently, the reserve of the values preset in this plan. |
Contract No.: | Code of contract. |
Cont. ver.: | Code of contract revision. |
Spreadsh. No.: | Code of contract spreadsheet. |
Sched. No.: | Code of financial schedule of contract. |
Installment No.: | Installment of financial schedule. |
RDA Code: | Code of service network related to routine Service Networks of module Health Care Plan. |
Contr. Bonus: | Value of contract bonuses deducted in financial bill. |
Contr. Withh.: | Value of contract withholding deducted in financial bill. |
Contr. Fine: | Value of contract fines deducted in financial bill. |
Contr. Discount: | Value of contract discounts deducted in financial bill. |
Ref. proc.: | Number of referenced process related to bill. This information is used when generating SPED, PIS and COFINS. |
Process tp.: | Define the type of process related to bill. This information is used when generating SPED, PIS and COFINS. |
Carrier code: | Code of freight carrier responsible for generating the bill. |
Carrier name: | Name of freight carrier responsible for generating the bill. |
Serv. tp.: | Type of service rendered. |
FAMAD Vl.: | Value of tax FAMAD (Timber Development Fund). |
FUMIPEQ Vl.: | Value of FUMIPEQ (Municipal Stimulus Fund for Micro and Small Businesses). |
FAMAD Inst.: | Installment of FAMAD (Timber Development Fund). |
FUMIPEQ Inst.: | Installment of FUMIPEQ (Municipal Stimulus Fund for Micro and Small Businesses). |
INSS Withh.: | Refers to the INSS value withheld when bills are generated by the Transportation Management module through field INSS Withheld in routine Trip Complement when the vehicle fleet refers to a third party or associated; however, when owned the field is not enabled. Values entered in field INSS Withheld refer to transport services rendered by the driver in other carriers. This value is added to the INSS value calculated in relation with the freight to be received in the teamster contract, considering the settings of parameter MV_LIMINSS. |
CNO Code: | Enter the code related to national works register. |
CNPJ (EIN): | CNPJ (EIN) of INSS (Brazilian Social Security) withholder. |
\\ *Addition* Expandir origem #INCLUDE "Protheus.ch" USER FUNCTION FIN050INC() LOCAL aArray := \{\} \\ PRIVATE lMsErroAuto := .F. \\ //Structure for PA ( Advance Payment ) aArray := \{ \{ "E2_PREFIXO" , "PAG" , NIL \},; \{ "E2_NUM" , "0001" , NIL \},; \{ "E2_TIPO" , "PA" , NIL \},; \{ "E2_NATUREZ" , "001" , NIL \},; \{ "E2_FORNECE" , "0001" , NIL \},; \{ "E2_EMISSAO" , CtoD("17/02/2012"), NIL \},; \{ "E2_VENCTO" , CtoD("17/02/2012"), NIL \},; \{ "E2_VENCREA" , CtoD("17/02/2012"), NIL \},; \{ "E2_VALOR" , 5000 , NIL \},; \{ "AUTBANCO" , "001", NIL \},; \{ "AUTAGENCIA" , "1234", NIL \},; \{ "AUTCONTA" , "123456", NIL \} \} \\ //Structure for other bills aArray := \{ \{ "E2_PREFIXO" , "PAG" , NIL \},; \{ "E2_NUM" , "0001" , NIL \},; \{ "E2_TIPO" , "NF" , NIL \},; \{ "E2_NATUREZ" , "001" , NIL \},; \{ "E2_FORNECE" , "0001" , NIL \},; \{ "E2_EMISSAO" , CtoD("17/02/2012"), NIL \},; \{ "E2_VENCTO" , CtoD("17/02/2012"), NIL \},; \{ "E2_VENCREA" , CtoD("17/02/2012"), NIL \},; \{ "E2_VALOR" , 5000 , NIL \} \} \\ MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aArray,, 3) // 3 - Inclusion, 4 - Edition, 5 - Deletion \\ \\ If lMsErroAuto MostraErro() Else Alert("Bill included successfully") Endif \\ Return *Editing* Expandir origem #INCLUDE "Protheus.ch" USER FUNCTION FIN050ALT() LOCAL aArray := \{\} \\ PRIVATE lMsErroAuto := .F. \\ aArray := \{ \{ "E2_PREFIXO" , "PAG" , NIL \},; \{ "E2_NUM" , "0001" , NIL \},; \{ "E2_VALOR" , 2000 , NIL \} \} \\ DbSelectArea("SE2") DbSetOrder(1) DbSeek(xFilial("SE2")+"PAG"+"0001 "+" "+"NF") //Edition must have SE2 record positioned \\ MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aArray,, 4) // 3 - Inclusion, 4 - Edition, 5 - Deletion \\ If lMsErroAuto MostraErro() Else Alert("Bill edited successfully") Endif \\ Return *Deletion* Expandir origem #INCLUDE "Protheus.ch" USER FUNCTION FIN050EXC() LOCAL aArray := \{\} \\ PRIVATE lMsErroAuto := .F. \\ DbSelectArea("SE2") DbSetOrder(1) DbSeek(xFilial("SE2")+"PAG"+"0001 "+" "+"NF") //Deletion must have SE2 record positioned \\ aArray := \{ \{ "E2_PREFIXO" , SE2->E2_PREFIXO , NIL \},; \{ "E2_NUM" , SE2->E2_NUM , NIL \} \} \\ MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aArray,, 5) // 3 - Inclusion, 4 - Edition, 5 - Deletion \\ If lMsErroAuto MostraErro() Else Alert("Bill deleted successfully") Endif \\ Return \\ *Addition with VA (Accessory Values)* Expandir origem #INCLUDE "Protheus.ch" USER FUNCTION FIN050VA() LOCAL aArray := \{\} LOCAL nOpc := 3 // 3-Addition, 4 Editing \\ // Accessory value data. LOCAL aVAAut := \{\} LOCAL cValAce1 := "000001" // Va Code LOCAL nValAce1 := 200 // Va Code LOCAL cValAce2 := "000012" LOCAL nValAce2 := 4 \\ PRIVATE lMsErroAuto := .F. \\ aArray := \{ \{ "E2_PREFIXO" , "PAG" , NIL \},; \{ "E2_NUM" , "0001" , NIL \},; \{ "E2_TIPO" , "NF" , NIL \},; \{ "E2_NATUREZ" , "001" , NIL \},; \{ "E2_FORNECE" , "0001" , NIL \},; \{ "E2_EMISSAO" , CtoD("17/02/2012"), NIL \},; \{ "E2_VENCTO" , CtoD("17/02/2012"), NIL \},; \{ "E2_VENCREA" , CtoD("17/02/2012"), NIL \},; \{ "E2_VALOR" , 5000 , NIL \} \} \\ // Array with accessory value aAdd(aVAAut, \{cValAce1, nValAce1\}) aAdd(aVAAut, \{cValAce2, nValAce2\}) \\ MsExecAuto( \{ |a,b,c,d,e,f,g,h,i,j,k,l| FINA050(a, b, c, d, e, f, g, h, i, j, k, l)\}, aArray,, nOpc,,,,,,,,, aVAAut) \\ If lMsErroAuto MostraErro() Else If nOpc == 3 Alert("Bill successfully added!") Else Alert("Bill edited successfully") EndIf Endif \\ Return *Addition with PA with check* Expandir origem #INCLUDE "Protheus.ch" USER FUNCTION FIN050INCPA() LOCAL aArray := \{\} \\ PRIVATE lMsErroAuto := .F. \\ aArray := \{ \{ "E2_PREFIXO", "PAG" , NIL \},; \{ "E2_NUM" , "0001" , NIL \},; \{ "E2_TIPO" , "PA" , NIL \},; \{ "E2_NATUREZ" , "001" , NIL \},; \{ "E2_FORNECE" , "0001" , NIL \},; \{ "E2_EMISSAO" , CtoD("17/02/2012"), NIL \},; \{ "E2_VENCTO" , CtoD("17/02/2012"), NIL \},; \{ "E2_VENCREA" , CtoD("17/02/2012"), NIL \},; \{ "E2_VALOR" , 5000 , NIL \},; \{ "AUTBANCO" , "FIN" , NIL \},; \{ "AUTAGENCIA" , "00015" , NIL \},; \{ "AUTCONTA" , "0000000001" , NIL \},; \{ "AUTMOED" , "1" , NIL \},; \{ "AUTCHEQUE" , "124569" , NIL \}\} \\ MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aArray,, 3) // 3 - Addition \\ If lMsErroAuto MostraErro() Else Alert("Bill successfully added") Endif \\ Return *Addition with project apportionment (PMS)* Expandir origem USER FUNCTION F050IPMS() Local cPref := "FIN" Local cNum := "210408001" Local cPar := "1" Local cTipo := "NF" Local cNaturez := "FGRV01" Local cFornec := "FGRV04" Local cLoja := "01" Local nValor := 1000 Local aGrvSe2 := \{\} Local aInfProj := \{\} Local aInfAFR := \{\} \\ PRIVATE lMsErroAuto := .F. \\ PREPARE COMPANY ENVIRONMENT "T1" BRANCH "D MG 01 " MODULE "FIN" TABLES "SE2","SE5","SA2","AFR","AF9","AF8" \\ aAdd(aInfAFR, \{"AFR_PROJET", PadR("PMSU000023", TamSX3("AF9_PROJET")\[1\]), Nil\}) aAdd(aInfAFR, \{"AFR_TAREFA", "01.02", Nil\}) aAdd(aInfAFR, \{"AFR_TIPOD", PadR("0004", TamSx3("AFR_TIPOD")\[1\]), Nil\}) aAdd(aInfAFR, \{"AFR_VALOR1", nValor, Nil\}) aAdd(aInfAFR, \{"AFR_REVISA", StrZero(4, TamSX3("AFR_REVISA")\[1\]), Nil\}) aAdd(aInfAFR, \{"AFR_PREFIX", cPref, Nil\}) aAdd(aInfAFR, \{"AFR_NUM", cNum, Nil\}) aAdd(aInfAFR, \{"AFR_PARCEL", cPar, Nil\}) aAdd(aInfAFR, \{"AFR_TIPO", cTipo, Nil\}) aAdd(aInfAFR, \{"AFR_FORNEC", cFornec, Nil\}) aAdd(aInfAFR, \{"AFR_LOJA", cLoja, Nil\}) aAdd(aInfAFR, \{"AFR_DATA", Date(), Nil\}) aAdd(aInfAFR, \{"AFR_VENREA", Date(), Nil\}) aAdd(aInfProj, aInfAFR) \\ aGrvSe2 := \{ \{ "E2_PREFIXO" , cPref , NIL \},; \{ "E2_NUM" , cNum , NIL \},; \{ "E2_TIPO" , cTipo , NIL \},; \{ "E2_NATUREZ" , cNaturez , NIL \},; \{ "E2_FORNECE" , cFornec , NIL \},; \{ "E2_LOJA" , cLoja , NIL \},; \{ "E2_EMISSAO" , Date() , NIL \},; \{ "E2_VENCTO" , Date() , NIL \},; \{ "E2_VENCREA" , Date() , NIL \},; \{ "E2_VALOR" , nValor , NIL \},; \{ "E2_PROJPMS" , "2" , NIL \},; \{ "E2_HIST" , "Project Addition" , NIL \},; \{"AUTRATAFR" , aInfProj ,Nil \} \} \\ MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aGrvSe2,, 3) // 3 - Addition, 4 - Editing, 5 - Deletion \\ If lMsErroAuto MostraErro() Else Conout("Bill successfully added!") Endif \\ Return *Bills payable withholding code* Expandir origem #INCLUDE "Protheus.ch" \\ /*When there is any type of operation involving the entry of value in field E2_CODRET, you need to use function SetFuName("FINA050") before running MSExecAuto(), because a validation exists in X3_VALID -(EXISTCPO("SX5","37"+M->E2_CODRET) .AND. Iif(FUNNAME() $ "FINA050|FINA750",FA050Natur(),.T.)) of this field that will only calculate the tax by withholding code if FunName() is found in "FINA050".*/ \\ USER FUNCTION F050CODRET() LOCAL aArray := \{\} \\ PRIVATE lMsErroAuto := .F. \\ //Structure for other bills aArray := \{ \{ "E2_PREFIXO" , "PAG" , NIL \},; \{ "E2_NUM" , "0001" , NIL \},; \{ "E2_TIPO" , "NF" , NIL \},; \{ "E2_NATUREZ" , "001" , NIL \},; \{ "E2_FORNECE" , "0001" , NIL \},; \{ "E2_EMISSAO" , CtoD("17/02/2012"), NIL \},; \{ "E2_VENCTO" , CtoD("17/02/2012"), NIL \},; \{ "E2_VENCREA" , CtoD("17/02/2012"), NIL \},; \{ "E2_VALOR" , 5000 , NIL \},; \{ "E2_DIRF" , "1", NIL \},; \{ "E2_CODRET" , "3208" , NIL \}\} \\ SetFunName("FINA050") MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aArray,, 3) // 3 - Addition, 4 - Editing, 5 - Deletion \\ \\ If lMsErroAuto MostraErro() Else Alert("Bill successfully added") Endif \\ Return |