@veroao/node 1.0.0 → 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/README.md +33 -0
- package/dist/client.d.ts +3 -1
- package/dist/client.js +4 -0
- package/dist/types.d.ts +53 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -130,6 +130,24 @@ await vero.invoices.send(orgId, invoice.id)
|
|
|
130
130
|
`documentType: 'FR'` fica com `status: 'paid'` imediatamente (já está pago); `'FT'` fica `'issued'`
|
|
131
131
|
até seres tu a marcar como pago via `vero.receipts.create`.
|
|
132
132
|
|
|
133
|
+
**Retenção na fonte** (Art. 67º do Código do Imposto Industrial, tipicamente 6,5% sobre serviços) -
|
|
134
|
+
opcional, desligada por omissão. Só tem efeito se a organização a tiver activada no dashboard
|
|
135
|
+
(Definições → Perfil → Retenção na fonte):
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
const invoice = await vero.invoices.create(orgId, {
|
|
139
|
+
customerId: 'uuid...',
|
|
140
|
+
items: [{ description: 'Consultoria', quantity: 1, unitPrice: 50000000, taxRate: 14 }],
|
|
141
|
+
applyWithholdingTax: true,
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
invoice.withholdingTax // { type: 'II', rate: 650, amount: 3250000, description: '...' } ou null
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Não altera `subtotal`/`taxAmount`/`total` (continuam o valor fiscal oficial da factura) - a retenção
|
|
148
|
+
viaja à parte, tanto na resposta como no documento submetido à AGT. O cálculo é sempre feito no
|
|
149
|
+
servidor a partir das definições da organização, nunca a partir de um valor que envies.
|
|
150
|
+
|
|
133
151
|
### `vero.proformas`
|
|
134
152
|
|
|
135
153
|
```typescript
|
|
@@ -148,6 +166,15 @@ await vero.proformas.cancel(orgId, proforma.id)
|
|
|
148
166
|
|
|
149
167
|
Proformas não têm valor fiscal - servem só de orçamento até seres convertidas em factura.
|
|
150
168
|
|
|
169
|
+
Aceitam a mesma **retenção na fonte** que as facturas (`applyWithholdingTax: true`, ver secção
|
|
170
|
+
`vero.invoices` acima) - transporta-se automaticamente para a factura ao converteres, sem precisares
|
|
171
|
+
de a pedir outra vez em `vero.proformas.convert`. Também podes activá-la ou mudá-la numa proforma já
|
|
172
|
+
criada, enquanto estiver em `draft`:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
await vero.proformas.update(orgId, proforma.id, { applyWithholdingTax: true })
|
|
176
|
+
```
|
|
177
|
+
|
|
151
178
|
### `vero.creditNotes`
|
|
152
179
|
|
|
153
180
|
```typescript
|
|
@@ -259,6 +286,12 @@ unitPrice: 150_050 // 1 500,50 AOA
|
|
|
259
286
|
| `VERO_API_KEY` | Chave secreta da API (recomendado) |
|
|
260
287
|
| `VERO_SECRET_KEY` | Alias legado - usado só se `VERO_API_KEY` não estiver definida |
|
|
261
288
|
|
|
289
|
+
## A implementar com Claude Code ou outro agente de IA?
|
|
290
|
+
|
|
291
|
+
Aponta o teu assistente para [vero.ao/vero-skill.md](https://vero.ao/vero-skill.md) - um skill
|
|
292
|
+
com o essencial da API da Vero (autenticação, endpoints, formatos e erros comuns) pronto a
|
|
293
|
+
carregar, sem teres de colar documentação à mão.
|
|
294
|
+
|
|
262
295
|
## O teu backend não é Node?
|
|
263
296
|
|
|
264
297
|
Este pacote é só uma comodidade - por baixo é tudo pedidos HTTPS normais (`Authorization: Bearer
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VeroConfig, ListResult, Customer, CreateCustomerInput, UpdateCustomerInput, EnsureCustomerInput, ListCustomersParams, Invoice, CreateInvoiceInput, ListInvoicesParams, ProformaInvoice, CreateProformaInput, ListProformasParams, CreditNote, DebitNote, CreateDebitNoteInput, Receipt, CreateReceiptInput, Product, CreateProductInput, UpdateProductInput, Webhook, RegisterWebhookInput } from './types.js';
|
|
1
|
+
import type { VeroConfig, ListResult, Customer, CreateCustomerInput, UpdateCustomerInput, EnsureCustomerInput, ListCustomersParams, Invoice, CreateInvoiceInput, ListInvoicesParams, ProformaInvoice, CreateProformaInput, UpdateProformaInput, ListProformasParams, CreditNote, DebitNote, CreateDebitNoteInput, Receipt, CreateReceiptInput, Product, CreateProductInput, UpdateProductInput, Webhook, RegisterWebhookInput } from './types.js';
|
|
2
2
|
declare class HttpClient {
|
|
3
3
|
readonly baseUrl: string;
|
|
4
4
|
private readonly secretKey;
|
|
@@ -58,6 +58,8 @@ declare class ProformasResource {
|
|
|
58
58
|
create(orgId: string, input: CreateProformaInput): Promise<ProformaInvoice>;
|
|
59
59
|
list(orgId: string, params?: ListProformasParams): Promise<ListResult<ProformaInvoice>>;
|
|
60
60
|
get(orgId: string, proformaId: string): Promise<ProformaInvoice>;
|
|
61
|
+
/** Actualiza itens, notas, validade ou retenção — só enquanto a proforma estiver em 'draft'. */
|
|
62
|
+
update(orgId: string, proformaId: string, input: UpdateProformaInput): Promise<ProformaInvoice>;
|
|
61
63
|
/** Converte pró-forma em fatura definitiva certificada — sem corpo, usa os dados já na proforma */
|
|
62
64
|
convert(orgId: string, proformaId: string): Promise<Invoice>;
|
|
63
65
|
/** Anula a proforma (não pode ser desfeito) */
|
package/dist/client.js
CHANGED
|
@@ -171,6 +171,10 @@ class ProformasResource {
|
|
|
171
171
|
get(orgId, proformaId) {
|
|
172
172
|
return this.http.get(`/v1/organisations/${orgId}/proformas/${proformaId}`);
|
|
173
173
|
}
|
|
174
|
+
/** Actualiza itens, notas, validade ou retenção — só enquanto a proforma estiver em 'draft'. */
|
|
175
|
+
update(orgId, proformaId, input) {
|
|
176
|
+
return this.http.patch(`/v1/organisations/${orgId}/proformas/${proformaId}`, input);
|
|
177
|
+
}
|
|
174
178
|
/** Converte pró-forma em fatura definitiva certificada — sem corpo, usa os dados já na proforma */
|
|
175
179
|
convert(orgId, proformaId) {
|
|
176
180
|
return this.http.post(`/v1/organisations/${orgId}/proformas/${proformaId}/convert`);
|
package/dist/types.d.ts
CHANGED
|
@@ -27,9 +27,15 @@ export interface InvoiceItem {
|
|
|
27
27
|
quantity: number;
|
|
28
28
|
/** Preço unitário em kwanzas × 100 (ex: 10000 = 100 AOA) */
|
|
29
29
|
unitPrice: number;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Taxa IVA Angola: 0 = isento, 5 = reduzida, 14 = normal. Opcional - se
|
|
32
|
+
* omitida, o servidor resolve-a a partir do regime de IVA configurado na
|
|
33
|
+
* organização (default 14% se a organização não tiver regime configurado).
|
|
34
|
+
* Organizações em regime isento/simplificado rejeitam (422) qualquer
|
|
35
|
+
* taxRate enviado que não seja 0.
|
|
36
|
+
*/
|
|
31
37
|
taxRate?: 0 | 5 | 14;
|
|
32
|
-
/** Obrigatório junto da AGT quando taxRate
|
|
38
|
+
/** Obrigatório junto da AGT quando taxRate resultar em 0 (máx. 4 caracteres, ex: "M19") */
|
|
33
39
|
taxExemptionCode?: string;
|
|
34
40
|
/** ID do produto do catálogo (opcional) */
|
|
35
41
|
productId?: string;
|
|
@@ -86,6 +92,21 @@ export interface AgtError {
|
|
|
86
92
|
idError?: string;
|
|
87
93
|
descriptionError?: string;
|
|
88
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Retenção na fonte (Art. 67º do Código do Imposto Industrial) declarada nesta
|
|
97
|
+
* factura — null quando não aplicada. NÃO altera subtotal/taxAmount/total (esses
|
|
98
|
+
* continuam o valor fiscal oficial); é informação adicional enviada à AGT à parte
|
|
99
|
+
* (só existe quando a organização activou isto nas definições do Vero).
|
|
100
|
+
*/
|
|
101
|
+
export interface WithholdingTax {
|
|
102
|
+
/** 'II' = Imposto Industrial, 'IRT' = pessoa singular/ENI */
|
|
103
|
+
type: 'II' | 'IRT';
|
|
104
|
+
/** Percentagem × 100 — ex: 650 = 6,50% */
|
|
105
|
+
rate: number;
|
|
106
|
+
/** Valor retido, em kwanzas × 100 */
|
|
107
|
+
amount: number;
|
|
108
|
+
description: string;
|
|
109
|
+
}
|
|
89
110
|
export interface Invoice {
|
|
90
111
|
id: string;
|
|
91
112
|
orgId: string;
|
|
@@ -113,6 +134,8 @@ export interface Invoice {
|
|
|
113
134
|
/** Estado da validação na AGT — consulta depois de criar, a submissão é assíncrona */
|
|
114
135
|
agtStatus?: AgtStatus;
|
|
115
136
|
agtErrors?: AgtError[] | null;
|
|
137
|
+
/** Presente só quando a organização tem retenção na fonte activada e pedida nesta factura */
|
|
138
|
+
withholdingTax?: WithholdingTax | null;
|
|
116
139
|
notes?: string | null;
|
|
117
140
|
issuedAt?: string | null;
|
|
118
141
|
cancelledAt?: string | null;
|
|
@@ -127,6 +150,12 @@ export interface CreateInvoiceInput {
|
|
|
127
150
|
notes?: string;
|
|
128
151
|
/** Chave de idempotência — gerada automaticamente se omitida */
|
|
129
152
|
idempotencyKey?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Pede para aplicar a retenção na fonte configurada na organização (Definições
|
|
155
|
+
* → Retenção na fonte). Sem efeito se a organização não a tiver activada, ou se
|
|
156
|
+
* o valor da factura não ultrapassar o limiar mínimo configurado.
|
|
157
|
+
*/
|
|
158
|
+
applyWithholdingTax?: boolean;
|
|
130
159
|
}
|
|
131
160
|
export interface ListInvoicesParams extends ListParams {
|
|
132
161
|
status?: InvoiceStatus;
|
|
@@ -151,6 +180,8 @@ export interface ProformaInvoice {
|
|
|
151
180
|
convertedAt?: string | null;
|
|
152
181
|
notes?: string | null;
|
|
153
182
|
validUntil?: string | null;
|
|
183
|
+
/** Presente só quando a organização tem retenção na fonte activada e pedida nesta proforma */
|
|
184
|
+
withholdingTax?: WithholdingTax | null;
|
|
154
185
|
createdAt: string;
|
|
155
186
|
updatedAt: string;
|
|
156
187
|
}
|
|
@@ -160,6 +191,22 @@ export interface CreateProformaInput {
|
|
|
160
191
|
notes?: string;
|
|
161
192
|
/** Data limite de validade (ISO 8601: "2026-12-31") */
|
|
162
193
|
validUntil?: string;
|
|
194
|
+
/**
|
|
195
|
+
* Pede para aplicar a retenção na fonte configurada na organização (Definições
|
|
196
|
+
* → Retenção na fonte). Sem efeito se a organização não a tiver activada, ou se
|
|
197
|
+
* o valor da proforma não ultrapassar o limiar mínimo configurado. Transportada
|
|
198
|
+
* para a factura final ao converter (proformas.convert).
|
|
199
|
+
*/
|
|
200
|
+
applyWithholdingTax?: boolean;
|
|
201
|
+
}
|
|
202
|
+
export interface UpdateProformaInput {
|
|
203
|
+
customerId?: string;
|
|
204
|
+
items?: InvoiceItem[];
|
|
205
|
+
notes?: string;
|
|
206
|
+
/** Data limite de validade (ISO 8601: "2026-12-31") */
|
|
207
|
+
validUntil?: string;
|
|
208
|
+
/** Activa/desliga a retenção na fonte pedida nesta proforma - ver CreateProformaInput. */
|
|
209
|
+
applyWithholdingTax?: boolean;
|
|
163
210
|
}
|
|
164
211
|
export interface ListProformasParams extends ListParams {
|
|
165
212
|
status?: ProformaStatus;
|
|
@@ -263,6 +310,8 @@ export interface Product {
|
|
|
263
310
|
taxRate: 0 | 5 | 14;
|
|
264
311
|
/** Obrigatório quando taxRate = 0 */
|
|
265
312
|
taxExemptionCode?: string | null;
|
|
313
|
+
/** 'product' (bem, pode ter stock) ou 'service' (prestação de serviço, nunca tem stock). Default 'product' */
|
|
314
|
+
type: 'product' | 'service';
|
|
266
315
|
/** Default 'UN' */
|
|
267
316
|
unitOfMeasure: string;
|
|
268
317
|
active: boolean;
|
|
@@ -280,6 +329,8 @@ export interface CreateProductInput {
|
|
|
280
329
|
/** Default 14 */
|
|
281
330
|
taxRate?: 0 | 5 | 14;
|
|
282
331
|
taxExemptionCode?: string;
|
|
332
|
+
/** 'product' (default) ou 'service'. Um serviço não tem stock: trackStock é ignorado. */
|
|
333
|
+
type?: 'product' | 'service';
|
|
283
334
|
/** Default 'UN' */
|
|
284
335
|
unitOfMeasure?: string;
|
|
285
336
|
trackStock?: boolean;
|