@netoalmanca/advpl-sensei 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/changelog-generator.md +63 -0
- package/agents/code-generator.md +215 -0
- package/agents/code-reviewer.md +145 -0
- package/agents/debugger.md +83 -0
- package/agents/doc-generator.md +67 -0
- package/agents/docs-reference.md +86 -0
- package/agents/migrator.md +84 -0
- package/agents/process-consultant.md +97 -0
- package/agents/refactorer.md +75 -0
- package/agents/sx-configurator.md +67 -0
- package/commands/changelog.md +66 -0
- package/commands/diagnose.md +67 -0
- package/commands/docs.md +81 -0
- package/commands/document.md +67 -0
- package/commands/explain.md +60 -0
- package/commands/generate.md +111 -0
- package/commands/migrate.md +81 -0
- package/commands/process.md +111 -0
- package/commands/refactor.md +65 -0
- package/commands/review.md +60 -0
- package/commands/sxgen.md +98 -0
- package/commands/test.md +103 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +143 -0
- package/dist/index.js.map +1 -0
- package/package.json +30 -0
- package/skills/advpl-code-generation/SKILL.md +163 -0
- package/skills/advpl-code-generation/patterns-fwformbrowse.md +485 -0
- package/skills/advpl-code-generation/patterns-jobs.md +519 -0
- package/skills/advpl-code-generation/patterns-mvc.md +765 -0
- package/skills/advpl-code-generation/patterns-pontos-entrada.md +708 -0
- package/skills/advpl-code-generation/patterns-rest.md +974 -0
- package/skills/advpl-code-generation/patterns-soap.md +639 -0
- package/skills/advpl-code-generation/patterns-treport.md +481 -0
- package/skills/advpl-code-generation/patterns-workflow.md +779 -0
- package/skills/advpl-code-generation/templates-classes.md +1096 -0
- package/skills/advpl-code-review/SKILL.md +72 -0
- package/skills/advpl-code-review/rules-best-practices.md +444 -0
- package/skills/advpl-code-review/rules-modernization.md +290 -0
- package/skills/advpl-code-review/rules-performance.md +333 -0
- package/skills/advpl-code-review/rules-security.md +302 -0
- package/skills/advpl-debugging/SKILL.md +265 -0
- package/skills/advpl-debugging/common-errors.md +1124 -0
- package/skills/advpl-debugging/performance-tips.md +768 -0
- package/skills/advpl-refactoring/SKILL.md +139 -0
- package/skills/advpl-to-tlpp-migration/SKILL.md +293 -0
- package/skills/advpl-to-tlpp-migration/migration-checklist.md +122 -0
- package/skills/advpl-to-tlpp-migration/migration-rules.md +265 -0
- package/skills/changelog-patterns/SKILL.md +99 -0
- package/skills/code-explanation/SKILL.md +66 -0
- package/skills/documentation-patterns/SKILL.md +172 -0
- package/skills/embedded-sql/SKILL.md +379 -0
- package/skills/probat-testing/SKILL.md +226 -0
- package/skills/probat-testing/patterns-unit-tests.md +614 -0
- package/skills/protheus-business/SKILL.md +92 -0
- package/skills/protheus-business/modulo-compras.md +780 -0
- package/skills/protheus-business/modulo-contabilidade.md +874 -0
- package/skills/protheus-business/modulo-estoque.md +876 -0
- package/skills/protheus-business/modulo-faturamento.md +800 -0
- package/skills/protheus-business/modulo-financeiro.md +1015 -0
- package/skills/protheus-business/modulo-fiscal.md +749 -0
- package/skills/protheus-business/modulo-manutencao.md +848 -0
- package/skills/protheus-business/modulo-pcp.md +743 -0
- package/skills/protheus-reference/SKILL.md +119 -0
- package/skills/protheus-reference/native-functions.md +7029 -0
- package/skills/protheus-reference/rest-api-reference.md +1758 -0
- package/skills/protheus-reference/restricted-functions.md +265 -0
- package/skills/protheus-reference/sx-dictionary.md +854 -0
- package/skills/sx-configuration/SKILL.md +184 -0
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
# Protheus Entry Points (Pontos de Entrada)
|
|
2
|
+
|
|
3
|
+
Reference for the most commonly used entry points in TOTVS Protheus, organized by module.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## IMPORTANT: Always Search TDN First
|
|
8
|
+
|
|
9
|
+
**Before generating code for ANY entry point, you MUST search the TDN (TOTVS Developer Network) for the official documentation of that specific entry point.**
|
|
10
|
+
|
|
11
|
+
The examples in this file cover only the most common entry points. There are **hundreds** of entry points in Protheus, each with its own specific PARAMIXB parameters and expected return type. Using wrong parameters or return types will cause runtime errors or unexpected behavior.
|
|
12
|
+
|
|
13
|
+
**Mandatory steps:**
|
|
14
|
+
1. Use `WebSearch` to find: `"ENTRY_POINT_NAME site:tdn.totvs.com"`
|
|
15
|
+
2. Use `WebFetch` to read the TDN page found
|
|
16
|
+
3. Extract from the page:
|
|
17
|
+
- **PARAMIXB** — parameter positions, types, and descriptions
|
|
18
|
+
- **Expected return** — type and meaning (Logical, Array, Character, Nil, etc.)
|
|
19
|
+
- **Calling routine** — which standard program triggers this entry point
|
|
20
|
+
- **When it fires** — at what moment in the standard flow
|
|
21
|
+
- **Caveats** — version-specific behavior or known limitations
|
|
22
|
+
4. Use this information to generate accurate code
|
|
23
|
+
|
|
24
|
+
If the TDN page is not found or is incomplete, inform the user and generate code based on the local reference below, clearly noting that the parameters should be validated.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 1. What are Entry Points
|
|
29
|
+
|
|
30
|
+
Entry points (Pontos de Entrada) are predefined hooks in Protheus standard source code where custom logic can be injected without modifying the original source. When the standard code reaches a specific point, it checks if a User Function with the expected name exists; if so, it calls that function.
|
|
31
|
+
|
|
32
|
+
Key characteristics:
|
|
33
|
+
- Entry points are **User Functions** with a **fixed name** defined by TOTVS.
|
|
34
|
+
- They receive parameters through the `PARAMIXB` array (and sometimes `PARAMIXE`).
|
|
35
|
+
- They return values that influence the standard flow (e.g., `.T.`/`.F.` for validation, arrays for additional data).
|
|
36
|
+
- They are the **official** way to customize Protheus behavior.
|
|
37
|
+
- They are discovered at runtime via the function dictionary.
|
|
38
|
+
|
|
39
|
+
### How PARAMIXB Works
|
|
40
|
+
|
|
41
|
+
```advpl
|
|
42
|
+
// PARAMIXB is a Private array available inside the entry point
|
|
43
|
+
// It contains parameters passed by the standard source code
|
|
44
|
+
|
|
45
|
+
User Function MT100LOK()
|
|
46
|
+
Local lRet := .T.
|
|
47
|
+
Local xParam1 := PARAMIXB[1] // First parameter
|
|
48
|
+
Local xParam2 := PARAMIXB[2] // Second parameter (if exists)
|
|
49
|
+
Return lRet
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Always check the number of elements in `PARAMIXB` before accessing positions to avoid array-out-of-bounds errors:
|
|
53
|
+
|
|
54
|
+
```advpl
|
|
55
|
+
If Len(PARAMIXB) >= 2
|
|
56
|
+
Local xParam2 := PARAMIXB[2]
|
|
57
|
+
EndIf
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 2. Entry Point Structure
|
|
63
|
+
|
|
64
|
+
Standard template for any entry point:
|
|
65
|
+
|
|
66
|
+
```advpl
|
|
67
|
+
#Include "TOTVS.CH"
|
|
68
|
+
|
|
69
|
+
/*/{Protheus.doc} ENTRY_POINT_NAME
|
|
70
|
+
Descricao do ponto de entrada
|
|
71
|
+
@type User Function
|
|
72
|
+
@author Autor
|
|
73
|
+
@since 01/01/2026
|
|
74
|
+
@version 1.0
|
|
75
|
+
@param PARAMIXB, Array, Parametros recebidos do ponto de entrada
|
|
76
|
+
@return xRet, Tipo, Descricao do retorno esperado
|
|
77
|
+
@see https://tdn.totvs.com/display/public/PROT/ENTRY_POINT_NAME
|
|
78
|
+
/*/
|
|
79
|
+
User Function ENTRY_POINT_NAME()
|
|
80
|
+
Local lRet := .T.
|
|
81
|
+
Local aArea := GetArea()
|
|
82
|
+
|
|
83
|
+
// Logica do ponto de entrada
|
|
84
|
+
|
|
85
|
+
RestArea(aArea)
|
|
86
|
+
Return lRet
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 3. Compras Module
|
|
92
|
+
|
|
93
|
+
### MT120LOK - Validacao de Inclusao do Pedido de Compra
|
|
94
|
+
|
|
95
|
+
**Purpose:** Validates the purchase order during inclusion/alteration. Called when the user confirms the operation.
|
|
96
|
+
|
|
97
|
+
**PARAMIXB:**
|
|
98
|
+
| Position | Type | Description |
|
|
99
|
+
|----------|------|-------------|
|
|
100
|
+
| 1 | Character | Operation type: "I" (include), "A" (alter), "E" (delete) |
|
|
101
|
+
|
|
102
|
+
**Return:** Logical - `.T.` allows the operation, `.F.` blocks it.
|
|
103
|
+
|
|
104
|
+
```advpl
|
|
105
|
+
#Include "TOTVS.CH"
|
|
106
|
+
|
|
107
|
+
/*/{Protheus.doc} MT120LOK
|
|
108
|
+
Validacao do pedido de compra
|
|
109
|
+
@type User Function
|
|
110
|
+
@author Autor
|
|
111
|
+
@since 01/01/2026
|
|
112
|
+
@version 1.0
|
|
113
|
+
/*/
|
|
114
|
+
User Function MT120LOK()
|
|
115
|
+
Local lRet := .T.
|
|
116
|
+
Local cOper := PARAMIXB[1]
|
|
117
|
+
|
|
118
|
+
If cOper == "I" // Inclusao
|
|
119
|
+
// Valida se o fornecedor esta ativo
|
|
120
|
+
If Posicione("SA2", 1, xFilial("SA2") + M->C7_FORNECE + M->C7_LOJA, "A2_MSBLQL") == "1"
|
|
121
|
+
MsgAlert("Fornecedor bloqueado. Pedido nao permitido.")
|
|
122
|
+
lRet := .F.
|
|
123
|
+
EndIf
|
|
124
|
+
EndIf
|
|
125
|
+
|
|
126
|
+
Return lRet
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### MT120CAN - Cancelamento de Pedido de Compra
|
|
132
|
+
|
|
133
|
+
**Purpose:** Executed when a purchase order is being cancelled. Allows custom logic before/after cancellation.
|
|
134
|
+
|
|
135
|
+
**PARAMIXB:**
|
|
136
|
+
| Position | Type | Description |
|
|
137
|
+
|----------|------|-------------|
|
|
138
|
+
| 1 | Character | Purchase order number (C7_NUM) |
|
|
139
|
+
|
|
140
|
+
**Return:** Logical - `.T.` allows cancellation, `.F.` blocks it.
|
|
141
|
+
|
|
142
|
+
```advpl
|
|
143
|
+
#Include "TOTVS.CH"
|
|
144
|
+
|
|
145
|
+
/*/{Protheus.doc} MT120CAN
|
|
146
|
+
Tratamento no cancelamento do pedido de compra
|
|
147
|
+
@type User Function
|
|
148
|
+
@author Autor
|
|
149
|
+
@since 01/01/2026
|
|
150
|
+
@version 1.0
|
|
151
|
+
/*/
|
|
152
|
+
User Function MT120CAN()
|
|
153
|
+
Local lRet := .T.
|
|
154
|
+
Local cNumPC := PARAMIXB[1]
|
|
155
|
+
|
|
156
|
+
// Verifica se existem notas fiscais vinculadas
|
|
157
|
+
DbSelectArea("SD1")
|
|
158
|
+
DbSetOrder(1)
|
|
159
|
+
If DbSeek(xFilial("SD1") + cNumPC)
|
|
160
|
+
MsgAlert("Pedido possui notas fiscais vinculadas. Cancelamento bloqueado.")
|
|
161
|
+
lRet := .F.
|
|
162
|
+
EndIf
|
|
163
|
+
|
|
164
|
+
Return lRet
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### A120GRVC - Gravacao do Pedido de Compra
|
|
170
|
+
|
|
171
|
+
**Purpose:** Executed after the purchase order is committed to the database. Used for post-processing.
|
|
172
|
+
|
|
173
|
+
**PARAMIXB:**
|
|
174
|
+
| Position | Type | Description |
|
|
175
|
+
|----------|------|-------------|
|
|
176
|
+
| 1 | Character | Operation type: "I" (include), "A" (alter) |
|
|
177
|
+
| 2 | Character | Purchase order number (C7_NUM) |
|
|
178
|
+
|
|
179
|
+
**Return:** Nil (no return value expected).
|
|
180
|
+
|
|
181
|
+
```advpl
|
|
182
|
+
#Include "TOTVS.CH"
|
|
183
|
+
|
|
184
|
+
/*/{Protheus.doc} A120GRVC
|
|
185
|
+
Pos-gravacao do pedido de compra
|
|
186
|
+
@type User Function
|
|
187
|
+
@author Autor
|
|
188
|
+
@since 01/01/2026
|
|
189
|
+
@version 1.0
|
|
190
|
+
/*/
|
|
191
|
+
User Function A120GRVC()
|
|
192
|
+
Local cOper := PARAMIXB[1]
|
|
193
|
+
Local cNumPC := PARAMIXB[2]
|
|
194
|
+
Local aArea := GetArea()
|
|
195
|
+
|
|
196
|
+
If cOper == "I"
|
|
197
|
+
// Enviar notificacao de novo pedido
|
|
198
|
+
Conout("Novo pedido de compra incluido: " + cNumPC)
|
|
199
|
+
EndIf
|
|
200
|
+
|
|
201
|
+
RestArea(aArea)
|
|
202
|
+
Return Nil
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 4. Faturamento Module
|
|
208
|
+
|
|
209
|
+
### MT100LOK - Validacao de Nota Fiscal
|
|
210
|
+
|
|
211
|
+
**Purpose:** Validates the invoice (nota fiscal) during inclusion. Called when the user confirms the invoice.
|
|
212
|
+
|
|
213
|
+
**PARAMIXB:**
|
|
214
|
+
| Position | Type | Description |
|
|
215
|
+
|----------|------|-------------|
|
|
216
|
+
| 1 | Character | Invoice type: "N" (normal), "D" (devolucao), "B" (beneficiamento) |
|
|
217
|
+
| 2 | Character | Invoice number |
|
|
218
|
+
|
|
219
|
+
**Return:** Logical - `.T.` allows, `.F.` blocks.
|
|
220
|
+
|
|
221
|
+
```advpl
|
|
222
|
+
#Include "TOTVS.CH"
|
|
223
|
+
|
|
224
|
+
/*/{Protheus.doc} MT100LOK
|
|
225
|
+
Validacao da nota fiscal de saida
|
|
226
|
+
@type User Function
|
|
227
|
+
@author Autor
|
|
228
|
+
@since 01/01/2026
|
|
229
|
+
@version 1.0
|
|
230
|
+
/*/
|
|
231
|
+
User Function MT100LOK()
|
|
232
|
+
Local lRet := .T.
|
|
233
|
+
Local cTipo := PARAMIXB[1]
|
|
234
|
+
Local cNota := PARAMIXB[2]
|
|
235
|
+
|
|
236
|
+
If cTipo == "N"
|
|
237
|
+
// Validacao customizada para notas normais
|
|
238
|
+
If Empty(M->F2_TRANSP)
|
|
239
|
+
MsgAlert("Transportadora e obrigatoria para notas de saida.")
|
|
240
|
+
lRet := .F.
|
|
241
|
+
EndIf
|
|
242
|
+
EndIf
|
|
243
|
+
|
|
244
|
+
Return lRet
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### SF2100I - Pos-inclusao de Nota Fiscal de Saida
|
|
250
|
+
|
|
251
|
+
**Purpose:** Executed after the output invoice (SF2) is fully committed. Used for integrations and post-processing.
|
|
252
|
+
|
|
253
|
+
**PARAMIXB:**
|
|
254
|
+
| Position | Type | Description |
|
|
255
|
+
|----------|------|-------------|
|
|
256
|
+
| 1 | Character | Invoice number (F2_DOC) |
|
|
257
|
+
| 2 | Character | Invoice series (F2_SERIE) |
|
|
258
|
+
| 3 | Character | Customer code (F2_CLIENTE) |
|
|
259
|
+
| 4 | Character | Customer store (F2_LOJA) |
|
|
260
|
+
|
|
261
|
+
**Return:** Nil.
|
|
262
|
+
|
|
263
|
+
```advpl
|
|
264
|
+
#Include "TOTVS.CH"
|
|
265
|
+
|
|
266
|
+
/*/{Protheus.doc} SF2100I
|
|
267
|
+
Pos-inclusao da nota fiscal de saida
|
|
268
|
+
@type User Function
|
|
269
|
+
@author Autor
|
|
270
|
+
@since 01/01/2026
|
|
271
|
+
@version 1.0
|
|
272
|
+
/*/
|
|
273
|
+
User Function SF2100I()
|
|
274
|
+
Local cNota := PARAMIXB[1]
|
|
275
|
+
Local cSerie := PARAMIXB[2]
|
|
276
|
+
Local cCliente := PARAMIXB[3]
|
|
277
|
+
Local cLoja := PARAMIXB[4]
|
|
278
|
+
Local aArea := GetArea()
|
|
279
|
+
|
|
280
|
+
// Exemplo: registrar log de faturamento
|
|
281
|
+
Conout("NF Saida incluida: " + cNota + "/" + cSerie + " - Cliente: " + cCliente + "/" + cLoja)
|
|
282
|
+
|
|
283
|
+
// Exemplo: disparar integracao
|
|
284
|
+
// u_IntegracaoNF(cNota, cSerie)
|
|
285
|
+
|
|
286
|
+
RestArea(aArea)
|
|
287
|
+
Return Nil
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
### A103MENU - Menu Adicional no Faturamento
|
|
293
|
+
|
|
294
|
+
**Purpose:** Adds custom menu options to the invoicing screen.
|
|
295
|
+
|
|
296
|
+
**PARAMIXB:** Not applicable (no parameters).
|
|
297
|
+
|
|
298
|
+
**Return:** Array of menu options `{cTitle, cFunction, nReserved, nOperation}`.
|
|
299
|
+
|
|
300
|
+
```advpl
|
|
301
|
+
#Include "TOTVS.CH"
|
|
302
|
+
|
|
303
|
+
/*/{Protheus.doc} A103MENU
|
|
304
|
+
Adiciona opcoes de menu no faturamento
|
|
305
|
+
@type User Function
|
|
306
|
+
@author Autor
|
|
307
|
+
@since 01/01/2026
|
|
308
|
+
@version 1.0
|
|
309
|
+
/*/
|
|
310
|
+
User Function A103MENU()
|
|
311
|
+
Local aMenu := {}
|
|
312
|
+
|
|
313
|
+
aAdd(aMenu, {"Relatorio Custom", "u_RelFat()", 0, 6})
|
|
314
|
+
aAdd(aMenu, {"Enviar Email NF", "u_EnvEmail()", 0, 7})
|
|
315
|
+
|
|
316
|
+
Return aMenu
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
### MA410BUT - Botoes Adicionais no Pedido de Venda
|
|
322
|
+
|
|
323
|
+
**Purpose:** Adds custom buttons to the sales order toolbar.
|
|
324
|
+
|
|
325
|
+
**PARAMIXB:** Not applicable.
|
|
326
|
+
|
|
327
|
+
**Return:** Array of button definitions `{nType, {bAction}, cTooltip, cBitmap}`.
|
|
328
|
+
|
|
329
|
+
```advpl
|
|
330
|
+
#Include "TOTVS.CH"
|
|
331
|
+
|
|
332
|
+
/*/{Protheus.doc} MA410BUT
|
|
333
|
+
Botoes adicionais no pedido de venda
|
|
334
|
+
@type User Function
|
|
335
|
+
@author Autor
|
|
336
|
+
@since 01/01/2026
|
|
337
|
+
@version 1.0
|
|
338
|
+
/*/
|
|
339
|
+
User Function MA410BUT()
|
|
340
|
+
Local aButtons := {}
|
|
341
|
+
|
|
342
|
+
aAdd(aButtons, {1, {|| u_ConsEstoq()}, "Consulta Estoque", "MAGIC_BMP"})
|
|
343
|
+
aAdd(aButtons, {1, {|| u_HistCliente()}, "Historico do Cliente", "LUPA"})
|
|
344
|
+
|
|
345
|
+
Return aButtons
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
### MA410LOK - Validacao do Pedido de Venda
|
|
351
|
+
|
|
352
|
+
**Purpose:** Validates the sales order upon confirmation. Called after standard validations.
|
|
353
|
+
|
|
354
|
+
**PARAMIXB:**
|
|
355
|
+
| Position | Type | Description |
|
|
356
|
+
|----------|------|-------------|
|
|
357
|
+
| 1 | Character | Operation type |
|
|
358
|
+
|
|
359
|
+
**Return:** Logical - `.T.` allows, `.F.` blocks.
|
|
360
|
+
|
|
361
|
+
```advpl
|
|
362
|
+
#Include "TOTVS.CH"
|
|
363
|
+
|
|
364
|
+
/*/{Protheus.doc} MA410LOK
|
|
365
|
+
Validacao do pedido de venda
|
|
366
|
+
@type User Function
|
|
367
|
+
@author Autor
|
|
368
|
+
@since 01/01/2026
|
|
369
|
+
@version 1.0
|
|
370
|
+
/*/
|
|
371
|
+
User Function MA410LOK()
|
|
372
|
+
Local lRet := .T.
|
|
373
|
+
Local nI := 0
|
|
374
|
+
Local nQtd := 0
|
|
375
|
+
|
|
376
|
+
// Valida quantidade minima por item
|
|
377
|
+
For nI := 1 To Len(aCols)
|
|
378
|
+
If !aGDFieldGet("C6_ITEMDEL", nI) // Linha nao deletada
|
|
379
|
+
nQtd := aGDFieldGet("C6_QTDVEN", nI)
|
|
380
|
+
If nQtd < 1
|
|
381
|
+
MsgAlert("Quantidade minima por item e 1. Verifique o item " + cValToChar(nI))
|
|
382
|
+
lRet := .F.
|
|
383
|
+
Exit
|
|
384
|
+
EndIf
|
|
385
|
+
EndIf
|
|
386
|
+
Next nI
|
|
387
|
+
|
|
388
|
+
Return lRet
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## 5. Financeiro Module
|
|
394
|
+
|
|
395
|
+
### FA080BUT - Botoes Adicionais no Contas a Pagar
|
|
396
|
+
|
|
397
|
+
**Purpose:** Adds custom buttons to the Accounts Payable screen.
|
|
398
|
+
|
|
399
|
+
**PARAMIXB:** Not applicable.
|
|
400
|
+
|
|
401
|
+
**Return:** Array of button definitions.
|
|
402
|
+
|
|
403
|
+
```advpl
|
|
404
|
+
#Include "TOTVS.CH"
|
|
405
|
+
|
|
406
|
+
/*/{Protheus.doc} FA080BUT
|
|
407
|
+
Botoes adicionais no contas a pagar
|
|
408
|
+
@type User Function
|
|
409
|
+
@author Autor
|
|
410
|
+
@since 01/01/2026
|
|
411
|
+
@version 1.0
|
|
412
|
+
/*/
|
|
413
|
+
User Function FA080BUT()
|
|
414
|
+
Local aButtons := {}
|
|
415
|
+
|
|
416
|
+
aAdd(aButtons, {"Extrato Fornec.", {|| u_ExtrForn()}, "Extrato do Fornecedor"})
|
|
417
|
+
|
|
418
|
+
Return aButtons
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
### FA080INC - Pos-inclusao no Contas a Pagar
|
|
424
|
+
|
|
425
|
+
**Purpose:** Executed after a new accounts payable entry (SE2) is included.
|
|
426
|
+
|
|
427
|
+
**PARAMIXB:**
|
|
428
|
+
| Position | Type | Description |
|
|
429
|
+
|----------|------|-------------|
|
|
430
|
+
| 1 | Character | Prefix (E2_PREFIXO) |
|
|
431
|
+
| 2 | Character | Title number (E2_NUM) |
|
|
432
|
+
| 3 | Character | Installment (E2_PARCELA) |
|
|
433
|
+
| 4 | Character | Type (E2_TIPO) |
|
|
434
|
+
|
|
435
|
+
**Return:** Nil.
|
|
436
|
+
|
|
437
|
+
```advpl
|
|
438
|
+
#Include "TOTVS.CH"
|
|
439
|
+
|
|
440
|
+
/*/{Protheus.doc} FA080INC
|
|
441
|
+
Pos-inclusao de titulo no contas a pagar
|
|
442
|
+
@type User Function
|
|
443
|
+
@author Autor
|
|
444
|
+
@since 01/01/2026
|
|
445
|
+
@version 1.0
|
|
446
|
+
/*/
|
|
447
|
+
User Function FA080INC()
|
|
448
|
+
Local cPrefixo := PARAMIXB[1]
|
|
449
|
+
Local cNum := PARAMIXB[2]
|
|
450
|
+
Local cParcela := PARAMIXB[3]
|
|
451
|
+
Local cTipo := PARAMIXB[4]
|
|
452
|
+
Local aArea := GetArea()
|
|
453
|
+
|
|
454
|
+
Conout("Titulo incluido no CP: " + cPrefixo + "/" + cNum + "-" + cParcela + " Tipo: " + cTipo)
|
|
455
|
+
|
|
456
|
+
// Logica customizada pos-inclusao
|
|
457
|
+
// Exemplo: criar aprovacao automatica
|
|
458
|
+
// u_CriaAprov(cPrefixo, cNum, cParcela)
|
|
459
|
+
|
|
460
|
+
RestArea(aArea)
|
|
461
|
+
Return Nil
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
### FA050BUT - Botoes Adicionais no Contas a Receber
|
|
467
|
+
|
|
468
|
+
**Purpose:** Adds custom buttons to the Accounts Receivable screen.
|
|
469
|
+
|
|
470
|
+
**PARAMIXB:** Not applicable.
|
|
471
|
+
|
|
472
|
+
**Return:** Array of button definitions.
|
|
473
|
+
|
|
474
|
+
```advpl
|
|
475
|
+
#Include "TOTVS.CH"
|
|
476
|
+
|
|
477
|
+
/*/{Protheus.doc} FA050BUT
|
|
478
|
+
Botoes adicionais no contas a receber
|
|
479
|
+
@type User Function
|
|
480
|
+
@author Autor
|
|
481
|
+
@since 01/01/2026
|
|
482
|
+
@version 1.0
|
|
483
|
+
/*/
|
|
484
|
+
User Function FA050BUT()
|
|
485
|
+
Local aButtons := {}
|
|
486
|
+
|
|
487
|
+
aAdd(aButtons, {"Hist. Pagamentos", {|| u_HistPag()}, "Historico de Pagamentos do Cliente"})
|
|
488
|
+
aAdd(aButtons, {"Gerar Boleto", {|| u_GerBol()}, "Gerar Boleto Bancario"})
|
|
489
|
+
|
|
490
|
+
Return aButtons
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
## 6. Estoque Module
|
|
496
|
+
|
|
497
|
+
### MT250LOK - Validacao de Movimentacao de Estoque
|
|
498
|
+
|
|
499
|
+
**Purpose:** Validates stock movements (entries and exits) before confirmation.
|
|
500
|
+
|
|
501
|
+
**PARAMIXB:**
|
|
502
|
+
| Position | Type | Description |
|
|
503
|
+
|----------|------|-------------|
|
|
504
|
+
| 1 | Character | Movement type (D3_TM) |
|
|
505
|
+
| 2 | Character | Product code (D3_COD) |
|
|
506
|
+
|
|
507
|
+
**Return:** Logical - `.T.` allows, `.F.` blocks.
|
|
508
|
+
|
|
509
|
+
```advpl
|
|
510
|
+
#Include "TOTVS.CH"
|
|
511
|
+
|
|
512
|
+
/*/{Protheus.doc} MT250LOK
|
|
513
|
+
Validacao da movimentacao de estoque
|
|
514
|
+
@type User Function
|
|
515
|
+
@author Autor
|
|
516
|
+
@since 01/01/2026
|
|
517
|
+
@version 1.0
|
|
518
|
+
/*/
|
|
519
|
+
User Function MT250LOK()
|
|
520
|
+
Local lRet := .T.
|
|
521
|
+
Local cTM := PARAMIXB[1]
|
|
522
|
+
Local cProd := PARAMIXB[2]
|
|
523
|
+
Local aArea := GetArea()
|
|
524
|
+
|
|
525
|
+
// Verifica se o produto permite movimentacao
|
|
526
|
+
DbSelectArea("SB1")
|
|
527
|
+
DbSetOrder(1)
|
|
528
|
+
If DbSeek(xFilial("SB1") + cProd)
|
|
529
|
+
If SB1->B1_MSBLQL == "1"
|
|
530
|
+
MsgAlert("Produto " + AllTrim(cProd) + " esta bloqueado para movimentacao.")
|
|
531
|
+
lRet := .F.
|
|
532
|
+
EndIf
|
|
533
|
+
EndIf
|
|
534
|
+
|
|
535
|
+
RestArea(aArea)
|
|
536
|
+
Return lRet
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
---
|
|
540
|
+
|
|
541
|
+
### A650GRVS - Gravacao de Solicitacao de Compra
|
|
542
|
+
|
|
543
|
+
**Purpose:** Executed after a purchase request (SC1) is saved. Used for post-processing and integrations.
|
|
544
|
+
|
|
545
|
+
**PARAMIXB:**
|
|
546
|
+
| Position | Type | Description |
|
|
547
|
+
|----------|------|-------------|
|
|
548
|
+
| 1 | Character | Request number (C1_NUM) |
|
|
549
|
+
| 2 | Character | Operation: "I" (include), "A" (alter) |
|
|
550
|
+
|
|
551
|
+
**Return:** Nil.
|
|
552
|
+
|
|
553
|
+
```advpl
|
|
554
|
+
#Include "TOTVS.CH"
|
|
555
|
+
|
|
556
|
+
/*/{Protheus.doc} A650GRVS
|
|
557
|
+
Pos-gravacao da solicitacao de compra
|
|
558
|
+
@type User Function
|
|
559
|
+
@author Autor
|
|
560
|
+
@since 01/01/2026
|
|
561
|
+
@version 1.0
|
|
562
|
+
/*/
|
|
563
|
+
User Function A650GRVS()
|
|
564
|
+
Local cNumSC := PARAMIXB[1]
|
|
565
|
+
Local cOper := PARAMIXB[2]
|
|
566
|
+
Local aArea := GetArea()
|
|
567
|
+
|
|
568
|
+
If cOper == "I"
|
|
569
|
+
// Nova solicitacao - enviar para aprovacao
|
|
570
|
+
Conout("Solicitacao de compra incluida: " + cNumSC)
|
|
571
|
+
// u_EnviaAprov(cNumSC)
|
|
572
|
+
EndIf
|
|
573
|
+
|
|
574
|
+
RestArea(aArea)
|
|
575
|
+
Return Nil
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
---
|
|
579
|
+
|
|
580
|
+
## 7. Fiscal Module
|
|
581
|
+
|
|
582
|
+
### SPEDCONTRIB - Contribuicoes SPED
|
|
583
|
+
|
|
584
|
+
**Purpose:** Allows customization of SPED Contribuicoes (PIS/COFINS) generation. Used to add, modify, or remove records from the SPED file.
|
|
585
|
+
|
|
586
|
+
**PARAMIXB:**
|
|
587
|
+
| Position | Type | Description |
|
|
588
|
+
|----------|------|-------------|
|
|
589
|
+
| 1 | Character | Record identifier (e.g., "C100", "C170") |
|
|
590
|
+
| 2 | Character | Record content line |
|
|
591
|
+
| 3 | Numeric | Record sequence number |
|
|
592
|
+
|
|
593
|
+
**Return:** Character - Modified record line, or empty string to remove the record.
|
|
594
|
+
|
|
595
|
+
```advpl
|
|
596
|
+
#Include "TOTVS.CH"
|
|
597
|
+
|
|
598
|
+
/*/{Protheus.doc} SPEDCONTRIB
|
|
599
|
+
Customizacao do SPED Contribuicoes
|
|
600
|
+
@type User Function
|
|
601
|
+
@author Autor
|
|
602
|
+
@since 01/01/2026
|
|
603
|
+
@version 1.0
|
|
604
|
+
/*/
|
|
605
|
+
User Function SPEDCONTRIB()
|
|
606
|
+
Local cReg := PARAMIXB[1]
|
|
607
|
+
Local cLinha := PARAMIXB[2]
|
|
608
|
+
Local nSeq := PARAMIXB[3]
|
|
609
|
+
|
|
610
|
+
// Exemplo: modificar registro C170 (itens do documento)
|
|
611
|
+
If cReg == "C170"
|
|
612
|
+
// Logica de ajuste no registro
|
|
613
|
+
EndIf
|
|
614
|
+
|
|
615
|
+
Return cLinha
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
---
|
|
619
|
+
|
|
620
|
+
### MT930LOK - Validacao do Livro Fiscal
|
|
621
|
+
|
|
622
|
+
**Purpose:** Validates fiscal book entries during apuracao (tax calculation).
|
|
623
|
+
|
|
624
|
+
**PARAMIXB:**
|
|
625
|
+
| Position | Type | Description |
|
|
626
|
+
|----------|------|-------------|
|
|
627
|
+
| 1 | Character | Book type |
|
|
628
|
+
| 2 | Date | Start date of the period |
|
|
629
|
+
| 3 | Date | End date of the period |
|
|
630
|
+
|
|
631
|
+
**Return:** Logical - `.T.` allows, `.F.` blocks.
|
|
632
|
+
|
|
633
|
+
```advpl
|
|
634
|
+
#Include "TOTVS.CH"
|
|
635
|
+
|
|
636
|
+
/*/{Protheus.doc} MT930LOK
|
|
637
|
+
Validacao do livro fiscal
|
|
638
|
+
@type User Function
|
|
639
|
+
@author Autor
|
|
640
|
+
@since 01/01/2026
|
|
641
|
+
@version 1.0
|
|
642
|
+
/*/
|
|
643
|
+
User Function MT930LOK()
|
|
644
|
+
Local lRet := .T.
|
|
645
|
+
Local cTipo := PARAMIXB[1]
|
|
646
|
+
Local dDtIni := PARAMIXB[2]
|
|
647
|
+
Local dDtFim := PARAMIXB[3]
|
|
648
|
+
|
|
649
|
+
// Valida se o periodo ja foi fechado
|
|
650
|
+
If dDtIni < CToD("01/01/2024")
|
|
651
|
+
MsgAlert("Periodo anterior a 2024 nao pode ser reprocessado.")
|
|
652
|
+
lRet := .F.
|
|
653
|
+
EndIf
|
|
654
|
+
|
|
655
|
+
Return lRet
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
---
|
|
659
|
+
|
|
660
|
+
## 8. How to Discover Entry Points
|
|
661
|
+
|
|
662
|
+
### 8.1 Using TDN (TOTVS Developer Network)
|
|
663
|
+
|
|
664
|
+
1. Access [https://tdn.totvs.com](https://tdn.totvs.com)
|
|
665
|
+
2. Search for the routine name (e.g., "MATA410" for sales orders)
|
|
666
|
+
3. Look for the "Pontos de Entrada" section in the documentation
|
|
667
|
+
4. Each entry point has documentation with parameters and expected return
|
|
668
|
+
|
|
669
|
+
### 8.2 Using the Debugger
|
|
670
|
+
|
|
671
|
+
1. Set a breakpoint in the standard source code
|
|
672
|
+
2. Search for `ExistBlock` calls - these indicate entry point hooks
|
|
673
|
+
3. The string passed to `ExistBlock` is the entry point name
|
|
674
|
+
|
|
675
|
+
```advpl
|
|
676
|
+
// This is what the standard code looks like:
|
|
677
|
+
If ExistBlock("MT100LOK")
|
|
678
|
+
lRet := ExecBlock("MT100LOK", .F., .F., {cTipo, cNota})
|
|
679
|
+
EndIf
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
### 8.3 Source Code Search
|
|
683
|
+
|
|
684
|
+
Search the standard RPO source for `ExistBlock` or `ExecBlock` calls:
|
|
685
|
+
|
|
686
|
+
```
|
|
687
|
+
// In TDS (TOTVS Developer Studio) or VS Code with ADVPL extension:
|
|
688
|
+
// Search for: ExistBlock("
|
|
689
|
+
// This reveals all available entry points in the compiled RPO
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
### 8.4 Common Patterns to Identify
|
|
693
|
+
|
|
694
|
+
| Standard Code Pattern | What It Means |
|
|
695
|
+
|----------------------|---------------|
|
|
696
|
+
| `ExistBlock("NAME")` | Checks if entry point "NAME" exists |
|
|
697
|
+
| `ExecBlock("NAME", .F., .F., aParams)` | Executes entry point with PARAMIXB = aParams |
|
|
698
|
+
| `PARAMIXB := aArray` then `ExecBlock(...)` | Sets PARAMIXB before calling |
|
|
699
|
+
|
|
700
|
+
### 8.5 Tips for Working with Entry Points
|
|
701
|
+
|
|
702
|
+
1. **Always test with all operations** - Include, Alter, Delete, and View.
|
|
703
|
+
2. **Check PARAMIXB length** before accessing positions - parameters may vary by operation.
|
|
704
|
+
3. **Save and restore areas** (`GetArea`/`RestArea`) - entry points run in the caller's context.
|
|
705
|
+
4. **Avoid heavy processing** - entry points run synchronously and impact user experience.
|
|
706
|
+
5. **Log extensively** - use `Conout` or custom logging for debugging.
|
|
707
|
+
6. **Document PARAMIXB** - always document which parameters you receive and use.
|
|
708
|
+
7. **Return the expected type** - returning the wrong type can crash the standard routine.
|