@veroao/node 1.0.1 → 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 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
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
@@ -92,6 +92,21 @@ export interface AgtError {
92
92
  idError?: string;
93
93
  descriptionError?: string;
94
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
+ }
95
110
  export interface Invoice {
96
111
  id: string;
97
112
  orgId: string;
@@ -119,6 +134,8 @@ export interface Invoice {
119
134
  /** Estado da validação na AGT — consulta depois de criar, a submissão é assíncrona */
120
135
  agtStatus?: AgtStatus;
121
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;
122
139
  notes?: string | null;
123
140
  issuedAt?: string | null;
124
141
  cancelledAt?: string | null;
@@ -133,6 +150,12 @@ export interface CreateInvoiceInput {
133
150
  notes?: string;
134
151
  /** Chave de idempotência — gerada automaticamente se omitida */
135
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;
136
159
  }
137
160
  export interface ListInvoicesParams extends ListParams {
138
161
  status?: InvoiceStatus;
@@ -157,6 +180,8 @@ export interface ProformaInvoice {
157
180
  convertedAt?: string | null;
158
181
  notes?: string | null;
159
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;
160
185
  createdAt: string;
161
186
  updatedAt: string;
162
187
  }
@@ -166,6 +191,22 @@ export interface CreateProformaInput {
166
191
  notes?: string;
167
192
  /** Data limite de validade (ISO 8601: "2026-12-31") */
168
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;
169
210
  }
170
211
  export interface ListProformasParams extends ListParams {
171
212
  status?: ProformaStatus;
@@ -269,6 +310,8 @@ export interface Product {
269
310
  taxRate: 0 | 5 | 14;
270
311
  /** Obrigatório quando taxRate = 0 */
271
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';
272
315
  /** Default 'UN' */
273
316
  unitOfMeasure: string;
274
317
  active: boolean;
@@ -286,6 +329,8 @@ export interface CreateProductInput {
286
329
  /** Default 14 */
287
330
  taxRate?: 0 | 5 | 14;
288
331
  taxExemptionCode?: string;
332
+ /** 'product' (default) ou 'service'. Um serviço não tem stock: trackStock é ignorado. */
333
+ type?: 'product' | 'service';
289
334
  /** Default 'UN' */
290
335
  unitOfMeasure?: string;
291
336
  trackStock?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veroao/node",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Vero SDK for Node.js — faturação certificada AGT para Angola",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",