@placeshakr/config 10.30.2-alpha.1 → 10.31.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/dist/types/types.d.ts +181 -159
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types.js +17 -17
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/types.ts +183 -160
package/dist/types/types.d.ts
CHANGED
|
@@ -396,7 +396,7 @@ export interface Enterprise extends Resource {
|
|
|
396
396
|
whatsapp?: boolean;
|
|
397
397
|
marketplace?: boolean;
|
|
398
398
|
multiProfessionals?: boolean;
|
|
399
|
-
/**
|
|
399
|
+
/** PennyLane integration: enables the Bills listing and the sync. */
|
|
400
400
|
pennylane?: boolean;
|
|
401
401
|
};
|
|
402
402
|
/**
|
|
@@ -535,9 +535,9 @@ export interface User extends Resource {
|
|
|
535
535
|
type Permissions = Record<string, boolean>;
|
|
536
536
|
export interface Profile extends Resource {
|
|
537
537
|
/**
|
|
538
|
-
*
|
|
539
|
-
* Seller
|
|
540
|
-
*
|
|
538
|
+
* The third party's billing data. It lives on Profile — and not on Client,
|
|
539
|
+
* Pro and Seller separately — because all three inherit from it and the SDK
|
|
540
|
+
* writes against this type. See [[BillingIdentity]] and `config/src/billing`.
|
|
541
541
|
*/
|
|
542
542
|
billing?: BillingIdentity;
|
|
543
543
|
/**
|
|
@@ -2054,28 +2054,29 @@ export type Bill = Resource & {
|
|
|
2054
2054
|
files?: File[];
|
|
2055
2055
|
metadata?: {
|
|
2056
2056
|
sentToIpaidthat?: boolean;
|
|
2057
|
-
/** @deprecated
|
|
2057
|
+
/** @deprecated use metadata.pennylane. Kept until email delivery is retired. */
|
|
2058
2058
|
sentToPennyLane?: boolean;
|
|
2059
2059
|
/** @deprecated usar metadata.pennylane.lastSyncAt */
|
|
2060
2060
|
sentToPennyLaneDate?: number;
|
|
2061
2061
|
/**
|
|
2062
|
-
*
|
|
2063
|
-
*
|
|
2064
|
-
*
|
|
2062
|
+
* PennyLane sync state. Replaces the two booleans above: it holds the
|
|
2063
|
+
* accounting id, the hash of the last payload sent (idempotency) and the
|
|
2064
|
+
* error, so a retry never duplicates.
|
|
2065
2065
|
*/
|
|
2066
2066
|
pennylane?: PennylaneBillSync;
|
|
2067
2067
|
};
|
|
2068
2068
|
/**
|
|
2069
|
-
*
|
|
2070
|
-
* source
|
|
2071
|
-
*
|
|
2069
|
+
* Where the document came from when it was not created in Articho. Bills
|
|
2070
|
+
* whose source is not undefined are neither edited nor deleted from the app:
|
|
2071
|
+
* the authority on that is firestore.rules.
|
|
2072
2072
|
*/
|
|
2073
2073
|
source?: 'pennylane';
|
|
2074
2074
|
imported?: boolean;
|
|
2075
2075
|
/**
|
|
2076
|
-
*
|
|
2077
|
-
* (fournisseur de
|
|
2078
|
-
* PROVIDER
|
|
2076
|
+
* Billing data of the recipient when they have no record of their own
|
|
2077
|
+
* (fournisseur de matériaux, de services and personnalisé). For CLIENT, PRO
|
|
2078
|
+
* and PROVIDER it lives on the third party's record. See
|
|
2079
|
+
* `config/src/billing`.
|
|
2079
2080
|
*/
|
|
2080
2081
|
billing?: BillingIdentity;
|
|
2081
2082
|
};
|
|
@@ -3840,24 +3841,24 @@ export declare enum EmailEventsEnum {
|
|
|
3840
3841
|
RESET_USER_PASSWORD = "RESET_USER_PASSWORD",
|
|
3841
3842
|
DOCUMENTS_ISSUES = "DOCUMENTS_ISSUES"
|
|
3842
3843
|
}
|
|
3843
|
-
/**
|
|
3844
|
+
/** Sync state of one specific bill against PennyLane. */
|
|
3844
3845
|
export type PennylaneBillSync = {
|
|
3845
3846
|
status: 'PENDING' | 'SYNCED' | 'FAILED' | 'SKIPPED';
|
|
3846
|
-
/**
|
|
3847
|
+
/** Invoice id in PennyLane. */
|
|
3847
3848
|
invoiceId?: string;
|
|
3848
|
-
/** Id
|
|
3849
|
+
/** Id of the credited invoice in PennyLane (for credit notes). */
|
|
3849
3850
|
creditedInvoiceId?: string;
|
|
3850
|
-
/** Id
|
|
3851
|
+
/** Id of the PennyLane credit note that cancels this invoice. */
|
|
3851
3852
|
creditNoteId?: string;
|
|
3852
3853
|
creditNoteNumber?: string;
|
|
3853
3854
|
creditNoteStatus?: 'PENDING' | 'SYNCED' | 'FAILED' | 'SKIPPED';
|
|
3854
3855
|
creditNoteError?: string;
|
|
3855
|
-
/**
|
|
3856
|
+
/** Mirror document under enterprises/{id}/importedBills. */
|
|
3856
3857
|
importedBillId?: string;
|
|
3857
3858
|
fileAttachmentId?: string;
|
|
3858
3859
|
/**
|
|
3859
|
-
* Hash
|
|
3860
|
-
*
|
|
3860
|
+
* Hash of the payload sent. PennyLane offers no Idempotency-Key, so
|
|
3861
|
+
* deduplication is ours: same hash as the last SYNCED, nothing is resent.
|
|
3861
3862
|
*/
|
|
3862
3863
|
payloadHash?: string;
|
|
3863
3864
|
attempts?: number;
|
|
@@ -3870,13 +3871,13 @@ export type PennylaneBillSync = {
|
|
|
3870
3871
|
status?: number;
|
|
3871
3872
|
};
|
|
3872
3873
|
};
|
|
3873
|
-
/**
|
|
3874
|
+
/** Which field of the PennyLane invoice each reference is read from. */
|
|
3874
3875
|
export type PennylaneReferenceConfig = {
|
|
3875
|
-
/**
|
|
3876
|
+
/** Field where the supplier writes the chantier reference. */
|
|
3876
3877
|
projectField: 'label' | 'invoice_number' | 'lines';
|
|
3877
|
-
/**
|
|
3878
|
+
/** Field where the supplier writes the devis reference. */
|
|
3878
3879
|
devisField: 'label' | 'invoice_number' | 'lines';
|
|
3879
|
-
/**
|
|
3880
|
+
/** Regular expression with a single capture group. */
|
|
3880
3881
|
projectPattern?: string;
|
|
3881
3882
|
devisPattern?: string;
|
|
3882
3883
|
};
|
|
@@ -3887,10 +3888,10 @@ export type PennylaneIgnoredSupplier = {
|
|
|
3887
3888
|
ignoredAt: number;
|
|
3888
3889
|
ignoredBy?: string | null;
|
|
3889
3890
|
};
|
|
3890
|
-
/**
|
|
3891
|
+
/** Per-enterprise PennyLane configuration: enterprises/{id}/configurations/pennylane */
|
|
3891
3892
|
export type PennylaneConfiguration = {
|
|
3892
3893
|
enabled: boolean;
|
|
3893
|
-
/**
|
|
3894
|
+
/** Numeric id of the company in PennyLane (e.g. '156553'). */
|
|
3894
3895
|
companyId?: string;
|
|
3895
3896
|
push: {
|
|
3896
3897
|
issued: boolean;
|
|
@@ -3899,67 +3900,88 @@ export type PennylaneConfiguration = {
|
|
|
3899
3900
|
pull: {
|
|
3900
3901
|
supplierInvoices: boolean;
|
|
3901
3902
|
};
|
|
3902
|
-
/** false =
|
|
3903
|
+
/** false = send aggregate amounts + PDF only. */
|
|
3903
3904
|
sendLineItems: boolean;
|
|
3904
|
-
/** true
|
|
3905
|
+
/** true while the accounting mapping is not settled with the accountant. */
|
|
3905
3906
|
importAsIncomplete: boolean;
|
|
3906
3907
|
references: PennylaneReferenceConfig;
|
|
3907
|
-
/**
|
|
3908
|
+
/** PennyLane states that are not pulled (drafts and initial noise). */
|
|
3908
3909
|
excludedStates?: string[];
|
|
3909
|
-
/**
|
|
3910
|
+
/** Days to look back on the initial load or a full resync. */
|
|
3910
3911
|
lookbackDays?: number;
|
|
3911
3912
|
defaultLedgerAccountId?: string;
|
|
3912
3913
|
ledgerAccountByCategory?: Record<string, string>;
|
|
3913
|
-
/**
|
|
3914
|
+
/** Analytical breakdown per chantier. See [[PennylaneCategoryConfig]]. */
|
|
3914
3915
|
categories?: PennylaneCategoryConfig;
|
|
3915
|
-
/**
|
|
3916
|
+
/** Suppliers whose invoices are ignored automatically on sync. */
|
|
3916
3917
|
ignoredSuppliers?: PennylaneIgnoredSupplier[];
|
|
3917
|
-
/**
|
|
3918
|
+
/** Sync state. Written by the Cloud Functions only. */
|
|
3918
3919
|
sync?: {
|
|
3919
3920
|
supplierInvoices?: PennylaneSyncState;
|
|
3920
3921
|
customerInvoices?: PennylaneSyncState;
|
|
3921
3922
|
};
|
|
3922
3923
|
};
|
|
3923
3924
|
/**
|
|
3924
|
-
*
|
|
3925
|
-
*
|
|
3925
|
+
* Analytical breakdown per chantier: one PennyLane category per Articho
|
|
3926
|
+
* project, the same one for that project's issued and received invoices.
|
|
3926
3927
|
*
|
|
3927
|
-
*
|
|
3928
|
-
*
|
|
3929
|
-
*
|
|
3930
|
-
*
|
|
3931
|
-
*
|
|
3928
|
+
* The category GROUP cannot be created through the API: a person creates it in
|
|
3929
|
+
* PennyLane and its id is pasted here. And categories, once created, can NOT
|
|
3930
|
+
* be deleted through the API — only renamed — so they are created lazily: the
|
|
3931
|
+
* first time a project receives or issues an invoice, never when the project
|
|
3932
|
+
* is created. A project that never invoices does not pollute the chart.
|
|
3932
3933
|
*/
|
|
3933
3934
|
export type PennylaneCategoryConfig = {
|
|
3934
|
-
/**
|
|
3935
|
+
/** Master switch. Without it the sync never touches categories. */
|
|
3935
3936
|
enabled: boolean;
|
|
3936
3937
|
/**
|
|
3937
|
-
* Id
|
|
3938
|
-
*
|
|
3938
|
+
* Id of the group created by hand in PennyLane (e.g. "Chantiers Articho").
|
|
3939
|
+
* It differs per enterprise: they are separate PennyLane workspaces.
|
|
3939
3940
|
*/
|
|
3940
3941
|
groupId: number;
|
|
3941
|
-
/**
|
|
3942
|
+
/** Also categorise the invoices Articho issues. */
|
|
3942
3943
|
includeCustomerInvoices?: boolean;
|
|
3943
3944
|
};
|
|
3944
3945
|
export type PennylaneSyncState = {
|
|
3945
3946
|
/**
|
|
3946
|
-
*
|
|
3947
|
-
*
|
|
3947
|
+
* Timestamp of the last change processed. PennyLane's changelog only retains
|
|
3948
|
+
* 4 weeks: if this falls behind, data is lost.
|
|
3948
3949
|
*/
|
|
3949
3950
|
checkpoint: number;
|
|
3950
3951
|
lastRunAt: number;
|
|
3951
3952
|
lastError?: string | null;
|
|
3953
|
+
/**
|
|
3954
|
+
* Invoices that failed and must be retried on the next run.
|
|
3955
|
+
*
|
|
3956
|
+
* It exists so the checkpoint can advance even when an invoice fails. The
|
|
3957
|
+
* alternative — holding the checkpoint back whenever there are errors —
|
|
3958
|
+
* looks safer and is not: a single invoice that always fails (a corrupt PDF,
|
|
3959
|
+
* a supplier that never resolves) would freeze the whole enterprise's sync,
|
|
3960
|
+
* reprocessing an ever-growing window until the function times out.
|
|
3961
|
+
*/
|
|
3962
|
+
pending?: PennylanePendingInvoice[];
|
|
3963
|
+
};
|
|
3964
|
+
/** An invoice awaiting retry, with its attempt count. */
|
|
3965
|
+
export type PennylanePendingInvoice = {
|
|
3966
|
+
/** Invoice id in PennyLane. */
|
|
3967
|
+
id: string;
|
|
3968
|
+
/** Attempts used. On reaching [[PENNYLANE_MAX_RETRIES]] it is abandoned. */
|
|
3969
|
+
attempts: number;
|
|
3970
|
+
/** Last error, so the reason is visible without opening the logs. */
|
|
3971
|
+
lastError: string;
|
|
3972
|
+
/** When it last failed. */
|
|
3973
|
+
lastAttemptAt: number;
|
|
3952
3974
|
};
|
|
3953
3975
|
export declare enum ImportedBillStatus {
|
|
3954
|
-
/**
|
|
3976
|
+
/** Arrived from PennyLane; project or devis could not be resolved. */
|
|
3955
3977
|
PENDING_ASSIGNMENT = "PENDING_ASSIGNMENT",
|
|
3956
|
-
/**
|
|
3978
|
+
/** Project and devis resolved: waiting for an administrator to confirm. */
|
|
3957
3979
|
READY_TO_ASSIGN = "READY_TO_ASSIGN",
|
|
3958
|
-
/**
|
|
3980
|
+
/** Already has a bill created inside a project. */
|
|
3959
3981
|
ASSIGNED = "ASSIGNED",
|
|
3960
|
-
/**
|
|
3982
|
+
/** Discarded by hand. */
|
|
3961
3983
|
IGNORED = "IGNORED",
|
|
3962
|
-
/**
|
|
3984
|
+
/** Duplicate of another imported invoice. */
|
|
3963
3985
|
DUPLICATE = "DUPLICATE"
|
|
3964
3986
|
}
|
|
3965
3987
|
export declare enum PennylaneSyncEventType {
|
|
@@ -3971,8 +3993,8 @@ export declare enum PennylaneSyncEventType {
|
|
|
3971
3993
|
ERROR = "ERROR"
|
|
3972
3994
|
}
|
|
3973
3995
|
/**
|
|
3974
|
-
*
|
|
3975
|
-
*
|
|
3996
|
+
* One event per thing that happens to an imported invoice. Without this, an
|
|
3997
|
+
* invoice that changes status on its own is indistinguishable from a bug.
|
|
3976
3998
|
*/
|
|
3977
3999
|
export type PennylaneSyncEvent = {
|
|
3978
4000
|
id: string;
|
|
@@ -3984,17 +4006,17 @@ export type PennylaneSyncEvent = {
|
|
|
3984
4006
|
payload?: Record<string, unknown>;
|
|
3985
4007
|
};
|
|
3986
4008
|
/**
|
|
3987
|
-
*
|
|
4009
|
+
* Mirror of a PennyLane invoice inside Articho.
|
|
3988
4010
|
*
|
|
3989
|
-
*
|
|
3990
|
-
*
|
|
3991
|
-
*
|
|
4011
|
+
* It deliberately lives at enterprise level and not inside a project: an
|
|
4012
|
+
* invoice arriving electronically does not know which project it belongs to.
|
|
4013
|
+
* It is also the source of the "Bills" listing in the administrator menu.
|
|
3992
4014
|
*/
|
|
3993
4015
|
export type ImportedBill = {
|
|
3994
4016
|
id: string;
|
|
3995
4017
|
source: 'pennylane';
|
|
3996
4018
|
direction: 'supplier' | 'customer';
|
|
3997
|
-
/** Id
|
|
4019
|
+
/** Id in PennyLane. The deduplication key. */
|
|
3998
4020
|
externalId: string;
|
|
3999
4021
|
enterpriseId: string;
|
|
4000
4022
|
status: ImportedBillStatus;
|
|
@@ -4010,7 +4032,7 @@ export type ImportedBill = {
|
|
|
4010
4032
|
isPaid: boolean;
|
|
4011
4033
|
paidAt?: number | null;
|
|
4012
4034
|
externalStatus?: string | null;
|
|
4013
|
-
/**
|
|
4035
|
+
/** How it got into PennyLane: Email, API, PA/PDP… */
|
|
4014
4036
|
externalSource?: string | null;
|
|
4015
4037
|
fileUrl?: string | null;
|
|
4016
4038
|
};
|
|
@@ -4019,7 +4041,7 @@ export type ImportedBill = {
|
|
|
4019
4041
|
regNo?: string | null;
|
|
4020
4042
|
pennylaneId?: string | null;
|
|
4021
4043
|
};
|
|
4022
|
-
/**
|
|
4044
|
+
/** References exactly as they came on the invoice, and which field they came from. */
|
|
4023
4045
|
references: {
|
|
4024
4046
|
projectRef?: string | null;
|
|
4025
4047
|
devisRef?: string | null;
|
|
@@ -4028,13 +4050,13 @@ export type ImportedBill = {
|
|
|
4028
4050
|
devis?: string;
|
|
4029
4051
|
};
|
|
4030
4052
|
};
|
|
4031
|
-
/**
|
|
4053
|
+
/** Automatic resolution. It never creates the bill on its own. */
|
|
4032
4054
|
suggestion?: {
|
|
4033
4055
|
projectId?: string | null;
|
|
4034
4056
|
devisId?: string | null;
|
|
4035
4057
|
reasons: string[];
|
|
4036
4058
|
};
|
|
4037
|
-
/**
|
|
4059
|
+
/** Association confirmed by an administrator. */
|
|
4038
4060
|
assignment?: {
|
|
4039
4061
|
projectId: string;
|
|
4040
4062
|
devisId: string;
|
|
@@ -4049,18 +4071,18 @@ export type ImportedBill = {
|
|
|
4049
4071
|
createdAt: number;
|
|
4050
4072
|
};
|
|
4051
4073
|
/**
|
|
4052
|
-
*
|
|
4074
|
+
* Postal address, broken down.
|
|
4053
4075
|
*
|
|
4054
|
-
*
|
|
4055
|
-
*
|
|
4056
|
-
*
|
|
4057
|
-
*
|
|
4076
|
+
* The loose `address` field several entities already carry is not usable for
|
|
4077
|
+
* invoicing: PennyLane — and e-invoicing in general — requires street, postal
|
|
4078
|
+
* code, city and country as separate fields. And `GeoLocation` only stores
|
|
4079
|
+
* lat/lng, so there is nothing to derive them from.
|
|
4058
4080
|
*/
|
|
4059
4081
|
export type PostalAddress = {
|
|
4060
4082
|
address: string;
|
|
4061
4083
|
postalCode: string;
|
|
4062
4084
|
city: string;
|
|
4063
|
-
/**
|
|
4085
|
+
/** Two-letter ISO code: FR, ES, BE… */
|
|
4064
4086
|
countryAlpha2: string;
|
|
4065
4087
|
};
|
|
4066
4088
|
export declare enum BillingPaymentConditions {
|
|
@@ -4080,193 +4102,193 @@ export declare enum BillingLanguage {
|
|
|
4080
4102
|
ES = "es_ES"
|
|
4081
4103
|
}
|
|
4082
4104
|
/**
|
|
4083
|
-
*
|
|
4105
|
+
* Everything needed to issue an invoice to this entity.
|
|
4084
4106
|
*
|
|
4085
|
-
*
|
|
4086
|
-
* Seller, Provider, MaterialsProvider)
|
|
4087
|
-
*
|
|
4107
|
+
* It is deliberately the same object for the five billable entities (Client,
|
|
4108
|
+
* Pro, Seller, Provider, MaterialsProvider): one type, one validator and one
|
|
4109
|
+
* form, instead of five variants that drift apart.
|
|
4088
4110
|
*
|
|
4089
|
-
*
|
|
4090
|
-
*
|
|
4091
|
-
*
|
|
4111
|
+
* It is filled in incrementally: the PennyLane sending modal asks for whatever
|
|
4112
|
+
* is missing right before invoicing and saves it here, so it only ever gets
|
|
4113
|
+
* completed for the entities that actually get invoiced.
|
|
4092
4114
|
*/
|
|
4093
4115
|
/**
|
|
4094
|
-
*
|
|
4116
|
+
* Legal person or natural person.
|
|
4095
4117
|
*
|
|
4096
|
-
*
|
|
4097
|
-
*
|
|
4098
|
-
*
|
|
4099
|
-
*
|
|
4118
|
+
* Not a cosmetic detail: it decides what the law requires and which PennyLane
|
|
4119
|
+
* endpoint is used. An invoice to a company falls under e-invoicing — SIREN
|
|
4120
|
+
* mandatory, transmitted over the network; one to a private individual is out
|
|
4121
|
+
* of scope and only produces e-reporting, with no client identity.
|
|
4100
4122
|
*
|
|
4101
|
-
*
|
|
4102
|
-
*
|
|
4123
|
+
* `undefined` means "we do not know yet", which is different from the other
|
|
4124
|
+
* two: the form has to ask, not assume.
|
|
4103
4125
|
*/
|
|
4104
4126
|
export type BillingLegalType = 'company' | 'individual';
|
|
4105
4127
|
export type BillingIdentity = {
|
|
4106
|
-
/**
|
|
4128
|
+
/** Company or private individual. See [[BillingLegalType]]. */
|
|
4107
4129
|
legalType?: BillingLegalType;
|
|
4108
4130
|
/**
|
|
4109
|
-
*
|
|
4131
|
+
* Legal name. Mandatory for companies.
|
|
4110
4132
|
*
|
|
4111
|
-
*
|
|
4112
|
-
* [[billingDisplayName]],
|
|
4113
|
-
*
|
|
4133
|
+
* It is not asked of an individual: it is composed from first and last name
|
|
4134
|
+
* by [[billingDisplayName]], so the same fact does not live in two places
|
|
4135
|
+
* and end up saying different things.
|
|
4114
4136
|
*/
|
|
4115
4137
|
legalName: string;
|
|
4116
|
-
/**
|
|
4138
|
+
/** First name. Mandatory for individuals; PennyLane wants it separate. */
|
|
4117
4139
|
firstName?: string;
|
|
4118
|
-
/**
|
|
4140
|
+
/** Last name. Mandatory for individuals. */
|
|
4119
4141
|
lastName?: string;
|
|
4120
|
-
/**
|
|
4142
|
+
/** Billing address. Mandatory. */
|
|
4121
4143
|
address: PostalAddress;
|
|
4122
|
-
/**
|
|
4144
|
+
/** Delivery address, when it differs from the billing one. */
|
|
4123
4145
|
deliveryAddress?: PostalAddress;
|
|
4124
|
-
/** SIREN (9
|
|
4146
|
+
/** SIREN (9 digits) or SIRET (14). */
|
|
4125
4147
|
registrationNumber?: string;
|
|
4126
|
-
/**
|
|
4148
|
+
/** Intra-community VAT number. Not to be confused with the VAT rate. */
|
|
4127
4149
|
vatNumber?: string;
|
|
4128
|
-
/**
|
|
4150
|
+
/** Addresses the invoice is sent to. */
|
|
4129
4151
|
emails?: string[];
|
|
4130
4152
|
phone?: string;
|
|
4131
|
-
/**
|
|
4153
|
+
/** Recipient person or department inside the company. */
|
|
4132
4154
|
recipient?: string;
|
|
4133
4155
|
paymentConditions?: BillingPaymentConditions;
|
|
4134
4156
|
language?: BillingLanguage;
|
|
4135
|
-
/**
|
|
4157
|
+
/** Notes attached to the third party's record. */
|
|
4136
4158
|
notes?: string;
|
|
4137
4159
|
/**
|
|
4138
|
-
*
|
|
4139
|
-
*
|
|
4160
|
+
* The third party's id in PennyLane, cached after the first invoice. It
|
|
4161
|
+
* avoids looking it up again and, above all, avoids duplicating the record.
|
|
4140
4162
|
*/
|
|
4141
4163
|
pennylaneCustomerId?: string;
|
|
4142
4164
|
/**
|
|
4143
|
-
*
|
|
4144
|
-
*
|
|
4145
|
-
*
|
|
4165
|
+
* What the public register says about the company, exactly as it was last
|
|
4166
|
+
* read. It is not printed on the invoice: it is the provenance of what is
|
|
4167
|
+
* above. See [[BillingInseeData]].
|
|
4146
4168
|
*/
|
|
4147
4169
|
insee?: BillingInseeData;
|
|
4148
4170
|
/**
|
|
4149
|
-
*
|
|
4150
|
-
*
|
|
4151
|
-
* Ver [[BillingEnrichment]].
|
|
4171
|
+
* What went wrong the last time this record was completed from the public
|
|
4172
|
+
* registers. Meant to be rendered as a tooltip. See [[BillingEnrichment]].
|
|
4152
4173
|
*/
|
|
4153
4174
|
enrichment?: BillingEnrichment;
|
|
4154
4175
|
updatedAt?: number;
|
|
4155
4176
|
updatedBy?: string;
|
|
4156
4177
|
};
|
|
4157
4178
|
/**
|
|
4158
|
-
*
|
|
4179
|
+
* What the public register says about a third party's company.
|
|
4159
4180
|
*
|
|
4160
|
-
*
|
|
4161
|
-
* [[BillingIdentity]]
|
|
4162
|
-
*
|
|
4163
|
-
*
|
|
4164
|
-
*
|
|
4181
|
+
* Written by `scripts/enrich-billing-from-insee.js`. It hangs off
|
|
4182
|
+
* [[BillingIdentity]] alongside the rest of what invoicing needs, but in its
|
|
4183
|
+
* own block: the fields above are what gets printed on the invoice and a human
|
|
4184
|
+
* may correct them; this is what the register says and it is rewritten on
|
|
4185
|
+
* every pass.
|
|
4165
4186
|
*/
|
|
4166
4187
|
export interface BillingInseeData {
|
|
4167
|
-
/** SIREN, 9
|
|
4188
|
+
/** SIREN, 9 digits. */
|
|
4168
4189
|
siren?: string;
|
|
4169
|
-
/** SIRET
|
|
4190
|
+
/** SIRET of the establishment queried, 14 digits. */
|
|
4170
4191
|
siret?: string;
|
|
4171
|
-
/**
|
|
4192
|
+
/** Whether the establishment queried is the registered office. */
|
|
4172
4193
|
siege?: boolean;
|
|
4173
|
-
/**
|
|
4194
|
+
/** Legal form (`categorieJuridiqueUniteLegale`). */
|
|
4174
4195
|
legalForm?: string | null;
|
|
4175
|
-
/**
|
|
4196
|
+
/** APE/NAF code (`activitePrincipaleUniteLegale`). */
|
|
4176
4197
|
nafCode?: string | null;
|
|
4177
|
-
/**
|
|
4198
|
+
/** Legal unit state: `A` active, `C` ceased. */
|
|
4178
4199
|
state?: string | null;
|
|
4179
|
-
/**
|
|
4200
|
+
/** Establishment state: `A` open, `F` closed. */
|
|
4180
4201
|
establishmentState?: string | null;
|
|
4181
|
-
/**
|
|
4202
|
+
/** Trade name, when it differs from the legal name. */
|
|
4182
4203
|
tradeName?: string | null;
|
|
4183
|
-
/**
|
|
4204
|
+
/** How it was resolved: `siret`, `siege` or `siege-fallback`. */
|
|
4184
4205
|
matchedBy?: string;
|
|
4185
4206
|
/**
|
|
4186
|
-
*
|
|
4187
|
-
*
|
|
4207
|
+
* Set only when the SIREN was absent from the record and was deduced by
|
|
4208
|
+
* searching on the legal name. It keeps a supplied fact distinguishable from
|
|
4209
|
+
* an inferred one.
|
|
4188
4210
|
*/
|
|
4189
4211
|
sirenFoundBy?: string;
|
|
4190
|
-
/**
|
|
4212
|
+
/** Result of checking the VAT number against VIES. */
|
|
4191
4213
|
vatCheck?: BillingVatCheck;
|
|
4192
|
-
/**
|
|
4214
|
+
/** When the register was last queried. */
|
|
4193
4215
|
checkedAt?: number;
|
|
4194
4216
|
}
|
|
4195
4217
|
/**
|
|
4196
|
-
*
|
|
4218
|
+
* Validation of the intra-community VAT number against the VIES register.
|
|
4197
4219
|
*
|
|
4198
|
-
*
|
|
4199
|
-
* formula
|
|
4200
|
-
*
|
|
4201
|
-
*
|
|
4220
|
+
* INSEE does not publish the number: it is computed from the SIREN, and the
|
|
4221
|
+
* formula always returns something well-formed, including for someone under
|
|
4222
|
+
* franchise en base who has no real number. `valid: false` means the number
|
|
4223
|
+
* does not exist, not that it is malformed.
|
|
4202
4224
|
*/
|
|
4203
4225
|
export interface BillingVatCheck {
|
|
4204
|
-
/**
|
|
4226
|
+
/** The number that was checked. */
|
|
4205
4227
|
number: string;
|
|
4206
4228
|
status: 'VALID' | 'INVALID' | 'UNAVAILABLE';
|
|
4207
|
-
/** `null`
|
|
4229
|
+
/** `null` when VIES did not answer: unknown, which is not the same as no. */
|
|
4208
4230
|
valid: boolean | null;
|
|
4209
4231
|
reason?: string | null;
|
|
4210
4232
|
source: string;
|
|
4211
4233
|
checkedAt: number;
|
|
4212
4234
|
}
|
|
4213
4235
|
/**
|
|
4214
|
-
*
|
|
4236
|
+
* Severity of an enrichment issue.
|
|
4215
4237
|
*
|
|
4216
|
-
* - `ok`
|
|
4217
|
-
* - `warning`
|
|
4218
|
-
* - `error`
|
|
4219
|
-
*
|
|
4238
|
+
* - `ok` the record was completed with nothing worth flagging.
|
|
4239
|
+
* - `warning` it was completed, but something is worth a look.
|
|
4240
|
+
* - `error` it could not be completed: the identifier is missing, it is not
|
|
4241
|
+
* in the register, or the lookup failed.
|
|
4220
4242
|
*/
|
|
4221
4243
|
export type BillingEnrichmentLevel = 'ok' | 'warning' | 'error';
|
|
4222
4244
|
/**
|
|
4223
|
-
*
|
|
4224
|
-
*
|
|
4245
|
+
* Code for each issue. It exists so they can be filtered and counted without
|
|
4246
|
+
* parsing the text, which is written to be read and may be reworded.
|
|
4225
4247
|
*/
|
|
4226
4248
|
export declare enum BillingEnrichmentCode {
|
|
4227
|
-
/**
|
|
4249
|
+
/** The record carries neither SIREN nor SIRET. */
|
|
4228
4250
|
NO_IDENTIFIER = "NO_IDENTIFIER",
|
|
4229
|
-
/**
|
|
4251
|
+
/** Several companies share that legal name: a human must choose. */
|
|
4230
4252
|
SIREN_AMBIGUOUS = "SIREN_AMBIGUOUS",
|
|
4231
|
-
/**
|
|
4253
|
+
/** The identifier does not appear in the register. */
|
|
4232
4254
|
NOT_FOUND = "NOT_FOUND",
|
|
4233
|
-
/**
|
|
4255
|
+
/** The legal unit is recorded as ceased. */
|
|
4234
4256
|
COMPANY_CLOSED = "COMPANY_CLOSED",
|
|
4235
|
-
/**
|
|
4257
|
+
/** The establishment is closed; the company may still be alive. */
|
|
4236
4258
|
ESTABLISHMENT_CLOSED = "ESTABLISHMENT_CLOSED",
|
|
4237
|
-
/**
|
|
4259
|
+
/** The VAT number is unknown to VIES. Likely franchise en base. */
|
|
4238
4260
|
VAT_NOT_REGISTERED = "VAT_NOT_REGISTERED",
|
|
4239
|
-
/** VIES
|
|
4261
|
+
/** VIES did not answer: the number was stored unverified. */
|
|
4240
4262
|
VAT_UNVERIFIED = "VAT_UNVERIFIED",
|
|
4241
|
-
/** VIES
|
|
4263
|
+
/** VIES returns a legal name different from INSEE's. */
|
|
4242
4264
|
VAT_NAME_MISMATCH = "VAT_NAME_MISMATCH",
|
|
4243
|
-
/**
|
|
4265
|
+
/** Establishment outside France: the country must be filled in by hand. */
|
|
4244
4266
|
FOREIGN_ADDRESS = "FOREIGN_ADDRESS",
|
|
4245
4267
|
MISSING_POSTAL_CODE = "MISSING_POSTAL_CODE",
|
|
4246
4268
|
MISSING_STREET = "MISSING_STREET",
|
|
4247
|
-
/**
|
|
4269
|
+
/** The register lookup failed (network, quota, credentials). */
|
|
4248
4270
|
LOOKUP_ERROR = "LOOKUP_ERROR"
|
|
4249
4271
|
}
|
|
4250
4272
|
/**
|
|
4251
|
-
*
|
|
4252
|
-
*
|
|
4273
|
+
* What happened the last time this record's billing data was completed from
|
|
4274
|
+
* the public registers.
|
|
4253
4275
|
*
|
|
4254
|
-
* `text`
|
|
4255
|
-
*
|
|
4256
|
-
*
|
|
4276
|
+
* `text` is the field meant to be displayed: plain text, one message per line,
|
|
4277
|
+
* ready for a `title` or a tooltip. `messages` and `codes` are there for
|
|
4278
|
+
* whoever prefers to render them separately or filter by issue type.
|
|
4257
4279
|
*
|
|
4258
|
-
*
|
|
4259
|
-
*
|
|
4260
|
-
*
|
|
4280
|
+
* The whole block is rewritten on every pass. Its absence means the record was
|
|
4281
|
+
* never reviewed; `level` being `ok` means it was reviewed and there was
|
|
4282
|
+
* nothing to flag.
|
|
4261
4283
|
*/
|
|
4262
4284
|
export interface BillingEnrichment {
|
|
4263
|
-
/**
|
|
4285
|
+
/** One message per line, separated by `\n`. Empty when `level` is `ok`. */
|
|
4264
4286
|
text: string;
|
|
4265
|
-
/**
|
|
4287
|
+
/** The same messages, unjoined. */
|
|
4266
4288
|
messages: string[];
|
|
4267
4289
|
codes: BillingEnrichmentCode[];
|
|
4268
4290
|
level: BillingEnrichmentLevel;
|
|
4269
|
-
/**
|
|
4291
|
+
/** Who wrote it, e.g. `insee-script`. */
|
|
4270
4292
|
source: string;
|
|
4271
4293
|
checkedAt: number;
|
|
4272
4294
|
}
|