apiempresas 1.5.0 → 1.6.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 +15 -0
- package/dist/ApiEmpresas.d.ts +1 -1
- package/dist/ApiEmpresas.js +1 -1
- package/dist/resources/Companies.d.ts +14 -1
- package/dist/resources/Companies.js +21 -0
- package/dist/types.d.ts +76 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,6 +99,21 @@ const { data, meta } = await api.companies.reconcile(['Mercadona', { name: 'Tall
|
|
|
99
99
|
// data[i].status: match (con company.cif) | ambiguous (candidates) | no_match. Solo se cobran los match.
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
### Validar el NIF de tus clientes antes de facturar (Pro, Business o saldo; desde 1.6.0)
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
const { data, meta } = await api.companies.verifyBatch([
|
|
106
|
+
{ cif: 'A46103834', name: 'Mercadona', ref: 'cliente-0001' }, // name: la razón social que tienes guardada
|
|
107
|
+
{ cif: 'A15075062', name: 'Inditex', ref: 'cliente-0002' }, // ref: tu identificador, vuelve tal cual
|
|
108
|
+
'B12345674', // o el NIF suelto
|
|
109
|
+
]);
|
|
110
|
+
data.forEach((fila) => console.log(fila.input, fila.invoice_hint)); // 'ok' | 'revisar' | 'no_facturar'
|
|
111
|
+
// await api.companies.verifyBatch(['A46103834'], { vat: true }); // también VIES
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Por cada NIF, en el mismo orden: `valid_format`, `exists`, `legal_name`, `address`, `status_code`, `name_check` (si das `name`) e `invoice_hint` (`ok`, `revisar` o `no_facturar`) con sus motivos en `flags`. `meta` trae `requested`, `found`, `cost`, `truncated` y `summary`. Hasta 1.000 NIF por llamada; con `vat` (lotes de hasta 20) comprueba también el NIF-IVA en VIES. Cobra 1 consulta por sociedad encontrada: los NIF inválidos, de personas o que no constan no se cobran; si no te llega el saldo, las filas que no caben vuelven con `processed: false`. No sustituye la comprobación contra el censo de la AEAT.
|
|
115
|
+
Los tipos `VerifyBatchItem`, `VerifyBatchRow` y `VerifyBatchMeta` se exportan desde el paquete.
|
|
116
|
+
|
|
102
117
|
### Segmentos de empresas
|
|
103
118
|
|
|
104
119
|
```typescript
|
package/dist/ApiEmpresas.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Tenders } from './resources/Tenders';
|
|
|
6
6
|
import { Sanctions } from './resources/Sanctions';
|
|
7
7
|
import { verifyWebhookSignature, constructWebhookEvent } from './webhooks/signature';
|
|
8
8
|
/** Versión del SDK, enviada en el User-Agent. */
|
|
9
|
-
export declare const SDK_VERSION = "1.
|
|
9
|
+
export declare const SDK_VERSION = "1.6.0";
|
|
10
10
|
export declare class ApiEmpresas {
|
|
11
11
|
private apiKey;
|
|
12
12
|
private baseURL;
|
package/dist/ApiEmpresas.js
CHANGED
|
@@ -9,7 +9,7 @@ const Tenders_1 = require("./resources/Tenders");
|
|
|
9
9
|
const Sanctions_1 = require("./resources/Sanctions");
|
|
10
10
|
const signature_1 = require("./webhooks/signature");
|
|
11
11
|
/** Versión del SDK, enviada en el User-Agent. */
|
|
12
|
-
exports.SDK_VERSION = '1.
|
|
12
|
+
exports.SDK_VERSION = '1.6.0';
|
|
13
13
|
/**
|
|
14
14
|
* Mensaje legible del cuerpo de error. Según el error, la API lo pone en
|
|
15
15
|
* message, detail, error (texto) o messages (errores de validación).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiEmpresas } from '../ApiEmpresas';
|
|
2
|
-
import { Company, BatchRequest, BatchResponse, ScoreData, BormeData, SignalsData, VerifyOptions, VerifyResult, FilterOptions, SegmentRow, SegmentMeta, ReconcileItem, ReconcileResult, ReconcileMeta, SubsidiesOptions, SubsidiesResult, ChangesOptions, ChangesResult, CompanyChange } from '../types';
|
|
2
|
+
import { Company, BatchRequest, BatchResponse, ScoreData, BormeData, SignalsData, VerifyOptions, VerifyResult, FilterOptions, SegmentRow, SegmentMeta, ReconcileItem, ReconcileResult, ReconcileMeta, SubsidiesOptions, SubsidiesResult, ChangesOptions, ChangesResult, CompanyChange, VerifyBatchItem, VerifyBatchOptions, VerifyBatchRow, VerifyBatchMeta } from '../types';
|
|
3
3
|
/** Opciones de get(): admin=true añade administradores y cargos (Pro/Business). */
|
|
4
4
|
export interface GetOptions {
|
|
5
5
|
admin?: boolean;
|
|
@@ -36,6 +36,19 @@ export declare class Companies {
|
|
|
36
36
|
* alertas, con decision_hint pass / review / fail. Coste: 2 consultas.
|
|
37
37
|
*/
|
|
38
38
|
verify(cif: string, options?: VerifyOptions): Promise<VerifyResult>;
|
|
39
|
+
/**
|
|
40
|
+
* (Pro, Business o saldo; desde 1.6.0) Valida en lote el NIF de los receptores de tus facturas
|
|
41
|
+
* (Verifactu, factura electrónica): hasta 1.000 por petición. Cada elemento puede ser un NIF o
|
|
42
|
+
* { cif, name?, ref? }: name es la razón social que tienes guardada y ref tu identificador (vuelve
|
|
43
|
+
* tal cual). Por cada NIF, en el mismo orden: valid_format, exists, legal_name, address,
|
|
44
|
+
* status_code, name_check e invoice_hint ('ok', 'revisar' o 'no_facturar') con sus motivos en flags.
|
|
45
|
+
* Cobro: 1 consulta por sociedad encontrada; NIF inválidos, de personas o que no constan, gratis.
|
|
46
|
+
* No sustituye la comprobación contra el censo de la AEAT.
|
|
47
|
+
*/
|
|
48
|
+
verifyBatch(items: Array<string | VerifyBatchItem>, options?: VerifyBatchOptions): Promise<{
|
|
49
|
+
data: VerifyBatchRow[];
|
|
50
|
+
meta: VerifyBatchMeta;
|
|
51
|
+
}>;
|
|
39
52
|
/**
|
|
40
53
|
* (Pro) Nombre a CIF, hasta 100 por petición. 1 consulta por cada "match";
|
|
41
54
|
* ambiguous y no_match no se cobran.
|
|
@@ -47,6 +47,27 @@ class Companies {
|
|
|
47
47
|
const response = await this.client.request(`/companies/verify?${params.toString()}`);
|
|
48
48
|
return response.data;
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* (Pro, Business o saldo; desde 1.6.0) Valida en lote el NIF de los receptores de tus facturas
|
|
52
|
+
* (Verifactu, factura electrónica): hasta 1.000 por petición. Cada elemento puede ser un NIF o
|
|
53
|
+
* { cif, name?, ref? }: name es la razón social que tienes guardada y ref tu identificador (vuelve
|
|
54
|
+
* tal cual). Por cada NIF, en el mismo orden: valid_format, exists, legal_name, address,
|
|
55
|
+
* status_code, name_check e invoice_hint ('ok', 'revisar' o 'no_facturar') con sus motivos en flags.
|
|
56
|
+
* Cobro: 1 consulta por sociedad encontrada; NIF inválidos, de personas o que no constan, gratis.
|
|
57
|
+
* No sustituye la comprobación contra el censo de la AEAT.
|
|
58
|
+
*/
|
|
59
|
+
async verifyBatch(items, options = {}) {
|
|
60
|
+
const body = {
|
|
61
|
+
items: items.map((i) => (typeof i === 'string' ? { cif: i } : i)),
|
|
62
|
+
};
|
|
63
|
+
if (options.vat)
|
|
64
|
+
body.vat = true;
|
|
65
|
+
const response = await this.client.request('/companies/verify/batch', {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
body: JSON.stringify(body)
|
|
68
|
+
});
|
|
69
|
+
return { data: response.data, meta: response.meta };
|
|
70
|
+
}
|
|
50
71
|
/**
|
|
51
72
|
* (Pro) Nombre a CIF, hasta 100 por petición. 1 consulta por cada "match";
|
|
52
73
|
* ambiguous y no_match no se cobran.
|
package/dist/types.d.ts
CHANGED
|
@@ -807,3 +807,79 @@ export interface StatsResult {
|
|
|
807
807
|
notes: string;
|
|
808
808
|
};
|
|
809
809
|
}
|
|
810
|
+
export interface VerifyBatchItem {
|
|
811
|
+
/** NIF del cliente (CIF, DNI o NIE). */
|
|
812
|
+
cif: string;
|
|
813
|
+
/** Razón social que tienes guardada: se compara con la oficial (name_check). */
|
|
814
|
+
name?: string;
|
|
815
|
+
/** Tu identificador (id de cliente...): se devuelve tal cual. */
|
|
816
|
+
ref?: string;
|
|
817
|
+
}
|
|
818
|
+
export interface VerifyBatchOptions {
|
|
819
|
+
/** Comprobar también el NIF-IVA en VIES (solo lotes de hasta 20). */
|
|
820
|
+
vat?: boolean;
|
|
821
|
+
}
|
|
822
|
+
export type InvoiceHint = 'ok' | 'revisar' | 'no_facturar';
|
|
823
|
+
export interface VerifyBatchFlag {
|
|
824
|
+
/** EXTINCT, MERGED, INSOLVENCY, DISSOLVED, IN_LIQUIDATION, REGISTRY_CLOSED, INACTIVE, STATUS_UNKNOWN,
|
|
825
|
+
* NAME_MISMATCH, VAT_NOT_IN_VIES, PERSON_NIF, FAKE_CIF, NOT_FOUND, INVALID_FORMAT, NOT_PROCESSED_QUOTA. */
|
|
826
|
+
code: string;
|
|
827
|
+
severity: 'info' | 'low' | 'medium' | 'high';
|
|
828
|
+
message: string;
|
|
829
|
+
}
|
|
830
|
+
export interface VerifyBatchRow {
|
|
831
|
+
/** Lo que enviaste, sin tocar. */
|
|
832
|
+
input: string;
|
|
833
|
+
/** NIF normalizado (sin espacios, guiones ni prefijo ES); null si no se reconoce. */
|
|
834
|
+
cif: string | null;
|
|
835
|
+
ref?: string;
|
|
836
|
+
/** Dígito o letra de control correctos (CIF, DNI y NIE). */
|
|
837
|
+
valid_format: boolean;
|
|
838
|
+
/** false si no se ha comprobado por falta de cupo o saldo (flag NOT_PROCESSED_QUOTA; no se cobra). */
|
|
839
|
+
processed: boolean;
|
|
840
|
+
/** true/false si es una sociedad; null si es una persona física, el formato no es válido o no se ha procesado. */
|
|
841
|
+
exists: boolean | null;
|
|
842
|
+
legal_name?: string | null;
|
|
843
|
+
address?: {
|
|
844
|
+
street: string | null;
|
|
845
|
+
postal_code: string | null;
|
|
846
|
+
municipality: string | null;
|
|
847
|
+
province: string | null;
|
|
848
|
+
};
|
|
849
|
+
/** ACTIVE, INSOLVENCY, DISSOLVED, IN_LIQUIDATION, EXTINCT, MERGED, REGISTRY_CLOSED, INACTIVE, UNKNOWN... */
|
|
850
|
+
status_code?: string;
|
|
851
|
+
status_date?: string | null;
|
|
852
|
+
/** Solo si enviaste name: parecido 0-100 y si coincide (desde 80). */
|
|
853
|
+
name_check?: {
|
|
854
|
+
provided: string;
|
|
855
|
+
score: number;
|
|
856
|
+
match: boolean;
|
|
857
|
+
};
|
|
858
|
+
/** Solo con vat: true. */
|
|
859
|
+
vat?: {
|
|
860
|
+
vat_number: string;
|
|
861
|
+
checked: boolean;
|
|
862
|
+
valid: boolean | null;
|
|
863
|
+
[k: string]: any;
|
|
864
|
+
};
|
|
865
|
+
/** null si no se ha procesado. */
|
|
866
|
+
invoice_hint: InvoiceHint | null;
|
|
867
|
+
flags: VerifyBatchFlag[];
|
|
868
|
+
}
|
|
869
|
+
export interface VerifyBatchMeta {
|
|
870
|
+
requested: number;
|
|
871
|
+
/** Sociedades encontradas (cada NIF distinto cuenta una vez). */
|
|
872
|
+
found: number;
|
|
873
|
+
/** Consultas (o créditos) cobradas. */
|
|
874
|
+
cost: number;
|
|
875
|
+
/** true si no llegó el cupo para todas: las que faltan van con processed: false. */
|
|
876
|
+
truncated: boolean;
|
|
877
|
+
summary: {
|
|
878
|
+
ok: number;
|
|
879
|
+
revisar: number;
|
|
880
|
+
no_facturar: number;
|
|
881
|
+
not_processed: number;
|
|
882
|
+
};
|
|
883
|
+
checked_at: string;
|
|
884
|
+
note: string;
|
|
885
|
+
}
|