@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/src/types.ts
CHANGED
|
@@ -527,7 +527,7 @@ export interface Enterprise extends Resource {
|
|
|
527
527
|
whatsapp?: boolean;
|
|
528
528
|
marketplace?: boolean;
|
|
529
529
|
multiProfessionals?: boolean;
|
|
530
|
-
/**
|
|
530
|
+
/** PennyLane integration: enables the Bills listing and the sync. */
|
|
531
531
|
pennylane?: boolean;
|
|
532
532
|
};
|
|
533
533
|
|
|
@@ -693,9 +693,9 @@ type Permissions = Record<string, boolean>;
|
|
|
693
693
|
|
|
694
694
|
export interface Profile extends Resource {
|
|
695
695
|
/**
|
|
696
|
-
*
|
|
697
|
-
* Seller
|
|
698
|
-
*
|
|
696
|
+
* The third party's billing data. It lives on Profile — and not on Client,
|
|
697
|
+
* Pro and Seller separately — because all three inherit from it and the SDK
|
|
698
|
+
* writes against this type. See [[BillingIdentity]] and `config/src/billing`.
|
|
699
699
|
*/
|
|
700
700
|
billing?: BillingIdentity;
|
|
701
701
|
|
|
@@ -2508,30 +2508,31 @@ export type Bill = Resource & {
|
|
|
2508
2508
|
// used to save information related with any possible external system
|
|
2509
2509
|
metadata?: {
|
|
2510
2510
|
sentToIpaidthat?: boolean;
|
|
2511
|
-
/** @deprecated
|
|
2511
|
+
/** @deprecated use metadata.pennylane. Kept until email delivery is retired. */
|
|
2512
2512
|
sentToPennyLane?: boolean;
|
|
2513
2513
|
/** @deprecated usar metadata.pennylane.lastSyncAt */
|
|
2514
2514
|
sentToPennyLaneDate?: number;
|
|
2515
2515
|
/**
|
|
2516
|
-
*
|
|
2517
|
-
*
|
|
2518
|
-
*
|
|
2516
|
+
* PennyLane sync state. Replaces the two booleans above: it holds the
|
|
2517
|
+
* accounting id, the hash of the last payload sent (idempotency) and the
|
|
2518
|
+
* error, so a retry never duplicates.
|
|
2519
2519
|
*/
|
|
2520
2520
|
pennylane?: PennylaneBillSync;
|
|
2521
2521
|
};
|
|
2522
2522
|
|
|
2523
2523
|
/**
|
|
2524
|
-
*
|
|
2525
|
-
* source
|
|
2526
|
-
*
|
|
2524
|
+
* Where the document came from when it was not created in Articho. Bills
|
|
2525
|
+
* whose source is not undefined are neither edited nor deleted from the app:
|
|
2526
|
+
* the authority on that is firestore.rules.
|
|
2527
2527
|
*/
|
|
2528
2528
|
source?: 'pennylane';
|
|
2529
2529
|
imported?: boolean;
|
|
2530
2530
|
|
|
2531
2531
|
/**
|
|
2532
|
-
*
|
|
2533
|
-
* (fournisseur de
|
|
2534
|
-
* PROVIDER
|
|
2532
|
+
* Billing data of the recipient when they have no record of their own
|
|
2533
|
+
* (fournisseur de matériaux, de services and personnalisé). For CLIENT, PRO
|
|
2534
|
+
* and PROVIDER it lives on the third party's record. See
|
|
2535
|
+
* `config/src/billing`.
|
|
2535
2536
|
*/
|
|
2536
2537
|
billing?: BillingIdentity;
|
|
2537
2538
|
};
|
|
@@ -4612,24 +4613,24 @@ export enum EmailEventsEnum {
|
|
|
4612
4613
|
/* PennyLane */
|
|
4613
4614
|
/* -------------------------------------------------------------------------- */
|
|
4614
4615
|
|
|
4615
|
-
/**
|
|
4616
|
+
/** Sync state of one specific bill against PennyLane. */
|
|
4616
4617
|
export type PennylaneBillSync = {
|
|
4617
4618
|
status: 'PENDING' | 'SYNCED' | 'FAILED' | 'SKIPPED';
|
|
4618
|
-
/**
|
|
4619
|
+
/** Invoice id in PennyLane. */
|
|
4619
4620
|
invoiceId?: string;
|
|
4620
|
-
/** Id
|
|
4621
|
+
/** Id of the credited invoice in PennyLane (for credit notes). */
|
|
4621
4622
|
creditedInvoiceId?: string;
|
|
4622
|
-
/** Id
|
|
4623
|
+
/** Id of the PennyLane credit note that cancels this invoice. */
|
|
4623
4624
|
creditNoteId?: string;
|
|
4624
4625
|
creditNoteNumber?: string;
|
|
4625
4626
|
creditNoteStatus?: 'PENDING' | 'SYNCED' | 'FAILED' | 'SKIPPED';
|
|
4626
4627
|
creditNoteError?: string;
|
|
4627
|
-
/**
|
|
4628
|
+
/** Mirror document under enterprises/{id}/importedBills. */
|
|
4628
4629
|
importedBillId?: string;
|
|
4629
4630
|
fileAttachmentId?: string;
|
|
4630
4631
|
/**
|
|
4631
|
-
* Hash
|
|
4632
|
-
*
|
|
4632
|
+
* Hash of the payload sent. PennyLane offers no Idempotency-Key, so
|
|
4633
|
+
* deduplication is ours: same hash as the last SYNCED, nothing is resent.
|
|
4633
4634
|
*/
|
|
4634
4635
|
payloadHash?: string;
|
|
4635
4636
|
attempts?: number;
|
|
@@ -4639,13 +4640,13 @@ export type PennylaneBillSync = {
|
|
|
4639
4640
|
error?: { code: string; message: string; status?: number };
|
|
4640
4641
|
};
|
|
4641
4642
|
|
|
4642
|
-
/**
|
|
4643
|
+
/** Which field of the PennyLane invoice each reference is read from. */
|
|
4643
4644
|
export type PennylaneReferenceConfig = {
|
|
4644
|
-
/**
|
|
4645
|
+
/** Field where the supplier writes the chantier reference. */
|
|
4645
4646
|
projectField: 'label' | 'invoice_number' | 'lines';
|
|
4646
|
-
/**
|
|
4647
|
+
/** Field where the supplier writes the devis reference. */
|
|
4647
4648
|
devisField: 'label' | 'invoice_number' | 'lines';
|
|
4648
|
-
/**
|
|
4649
|
+
/** Regular expression with a single capture group. */
|
|
4649
4650
|
projectPattern?: string;
|
|
4650
4651
|
devisPattern?: string;
|
|
4651
4652
|
};
|
|
@@ -4658,29 +4659,29 @@ export type PennylaneIgnoredSupplier = {
|
|
|
4658
4659
|
ignoredBy?: string | null;
|
|
4659
4660
|
};
|
|
4660
4661
|
|
|
4661
|
-
/**
|
|
4662
|
+
/** Per-enterprise PennyLane configuration: enterprises/{id}/configurations/pennylane */
|
|
4662
4663
|
export type PennylaneConfiguration = {
|
|
4663
4664
|
enabled: boolean;
|
|
4664
|
-
/**
|
|
4665
|
+
/** Numeric id of the company in PennyLane (e.g. '156553'). */
|
|
4665
4666
|
companyId?: string;
|
|
4666
4667
|
push: { issued: boolean; received: boolean };
|
|
4667
4668
|
pull: { supplierInvoices: boolean };
|
|
4668
|
-
/** false =
|
|
4669
|
+
/** false = send aggregate amounts + PDF only. */
|
|
4669
4670
|
sendLineItems: boolean;
|
|
4670
|
-
/** true
|
|
4671
|
+
/** true while the accounting mapping is not settled with the accountant. */
|
|
4671
4672
|
importAsIncomplete: boolean;
|
|
4672
4673
|
references: PennylaneReferenceConfig;
|
|
4673
|
-
/**
|
|
4674
|
+
/** PennyLane states that are not pulled (drafts and initial noise). */
|
|
4674
4675
|
excludedStates?: string[];
|
|
4675
|
-
/**
|
|
4676
|
+
/** Days to look back on the initial load or a full resync. */
|
|
4676
4677
|
lookbackDays?: number;
|
|
4677
4678
|
defaultLedgerAccountId?: string;
|
|
4678
4679
|
ledgerAccountByCategory?: Record<string, string>;
|
|
4679
|
-
/**
|
|
4680
|
+
/** Analytical breakdown per chantier. See [[PennylaneCategoryConfig]]. */
|
|
4680
4681
|
categories?: PennylaneCategoryConfig;
|
|
4681
|
-
/**
|
|
4682
|
+
/** Suppliers whose invoices are ignored automatically on sync. */
|
|
4682
4683
|
ignoredSuppliers?: PennylaneIgnoredSupplier[];
|
|
4683
|
-
/**
|
|
4684
|
+
/** Sync state. Written by the Cloud Functions only. */
|
|
4684
4685
|
sync?: {
|
|
4685
4686
|
supplierInvoices?: PennylaneSyncState;
|
|
4686
4687
|
customerInvoices?: PennylaneSyncState;
|
|
@@ -4688,47 +4689,69 @@ export type PennylaneConfiguration = {
|
|
|
4688
4689
|
};
|
|
4689
4690
|
|
|
4690
4691
|
/**
|
|
4691
|
-
*
|
|
4692
|
-
*
|
|
4692
|
+
* Analytical breakdown per chantier: one PennyLane category per Articho
|
|
4693
|
+
* project, the same one for that project's issued and received invoices.
|
|
4693
4694
|
*
|
|
4694
|
-
*
|
|
4695
|
-
*
|
|
4696
|
-
*
|
|
4697
|
-
*
|
|
4698
|
-
*
|
|
4695
|
+
* The category GROUP cannot be created through the API: a person creates it in
|
|
4696
|
+
* PennyLane and its id is pasted here. And categories, once created, can NOT
|
|
4697
|
+
* be deleted through the API — only renamed — so they are created lazily: the
|
|
4698
|
+
* first time a project receives or issues an invoice, never when the project
|
|
4699
|
+
* is created. A project that never invoices does not pollute the chart.
|
|
4699
4700
|
*/
|
|
4700
4701
|
export type PennylaneCategoryConfig = {
|
|
4701
|
-
/**
|
|
4702
|
+
/** Master switch. Without it the sync never touches categories. */
|
|
4702
4703
|
enabled: boolean;
|
|
4703
4704
|
/**
|
|
4704
|
-
* Id
|
|
4705
|
-
*
|
|
4705
|
+
* Id of the group created by hand in PennyLane (e.g. "Chantiers Articho").
|
|
4706
|
+
* It differs per enterprise: they are separate PennyLane workspaces.
|
|
4706
4707
|
*/
|
|
4707
4708
|
groupId: number;
|
|
4708
|
-
/**
|
|
4709
|
+
/** Also categorise the invoices Articho issues. */
|
|
4709
4710
|
includeCustomerInvoices?: boolean;
|
|
4710
4711
|
};
|
|
4711
4712
|
|
|
4712
4713
|
export type PennylaneSyncState = {
|
|
4713
4714
|
/**
|
|
4714
|
-
*
|
|
4715
|
-
*
|
|
4715
|
+
* Timestamp of the last change processed. PennyLane's changelog only retains
|
|
4716
|
+
* 4 weeks: if this falls behind, data is lost.
|
|
4716
4717
|
*/
|
|
4717
4718
|
checkpoint: number;
|
|
4718
4719
|
lastRunAt: number;
|
|
4719
4720
|
lastError?: string | null;
|
|
4721
|
+
/**
|
|
4722
|
+
* Invoices that failed and must be retried on the next run.
|
|
4723
|
+
*
|
|
4724
|
+
* It exists so the checkpoint can advance even when an invoice fails. The
|
|
4725
|
+
* alternative — holding the checkpoint back whenever there are errors —
|
|
4726
|
+
* looks safer and is not: a single invoice that always fails (a corrupt PDF,
|
|
4727
|
+
* a supplier that never resolves) would freeze the whole enterprise's sync,
|
|
4728
|
+
* reprocessing an ever-growing window until the function times out.
|
|
4729
|
+
*/
|
|
4730
|
+
pending?: PennylanePendingInvoice[];
|
|
4731
|
+
};
|
|
4732
|
+
|
|
4733
|
+
/** An invoice awaiting retry, with its attempt count. */
|
|
4734
|
+
export type PennylanePendingInvoice = {
|
|
4735
|
+
/** Invoice id in PennyLane. */
|
|
4736
|
+
id: string;
|
|
4737
|
+
/** Attempts used. On reaching [[PENNYLANE_MAX_RETRIES]] it is abandoned. */
|
|
4738
|
+
attempts: number;
|
|
4739
|
+
/** Last error, so the reason is visible without opening the logs. */
|
|
4740
|
+
lastError: string;
|
|
4741
|
+
/** When it last failed. */
|
|
4742
|
+
lastAttemptAt: number;
|
|
4720
4743
|
};
|
|
4721
4744
|
|
|
4722
4745
|
export enum ImportedBillStatus {
|
|
4723
|
-
/**
|
|
4746
|
+
/** Arrived from PennyLane; project or devis could not be resolved. */
|
|
4724
4747
|
PENDING_ASSIGNMENT = 'PENDING_ASSIGNMENT',
|
|
4725
|
-
/**
|
|
4748
|
+
/** Project and devis resolved: waiting for an administrator to confirm. */
|
|
4726
4749
|
READY_TO_ASSIGN = 'READY_TO_ASSIGN',
|
|
4727
|
-
/**
|
|
4750
|
+
/** Already has a bill created inside a project. */
|
|
4728
4751
|
ASSIGNED = 'ASSIGNED',
|
|
4729
|
-
/**
|
|
4752
|
+
/** Discarded by hand. */
|
|
4730
4753
|
IGNORED = 'IGNORED',
|
|
4731
|
-
/**
|
|
4754
|
+
/** Duplicate of another imported invoice. */
|
|
4732
4755
|
DUPLICATE = 'DUPLICATE',
|
|
4733
4756
|
}
|
|
4734
4757
|
|
|
@@ -4742,8 +4765,8 @@ export enum PennylaneSyncEventType {
|
|
|
4742
4765
|
}
|
|
4743
4766
|
|
|
4744
4767
|
/**
|
|
4745
|
-
*
|
|
4746
|
-
*
|
|
4768
|
+
* One event per thing that happens to an imported invoice. Without this, an
|
|
4769
|
+
* invoice that changes status on its own is indistinguishable from a bug.
|
|
4747
4770
|
*/
|
|
4748
4771
|
export type PennylaneSyncEvent = {
|
|
4749
4772
|
id: string;
|
|
@@ -4756,17 +4779,17 @@ export type PennylaneSyncEvent = {
|
|
|
4756
4779
|
};
|
|
4757
4780
|
|
|
4758
4781
|
/**
|
|
4759
|
-
*
|
|
4782
|
+
* Mirror of a PennyLane invoice inside Articho.
|
|
4760
4783
|
*
|
|
4761
|
-
*
|
|
4762
|
-
*
|
|
4763
|
-
*
|
|
4784
|
+
* It deliberately lives at enterprise level and not inside a project: an
|
|
4785
|
+
* invoice arriving electronically does not know which project it belongs to.
|
|
4786
|
+
* It is also the source of the "Bills" listing in the administrator menu.
|
|
4764
4787
|
*/
|
|
4765
4788
|
export type ImportedBill = {
|
|
4766
4789
|
id: string;
|
|
4767
4790
|
source: 'pennylane';
|
|
4768
4791
|
direction: 'supplier' | 'customer';
|
|
4769
|
-
/** Id
|
|
4792
|
+
/** Id in PennyLane. The deduplication key. */
|
|
4770
4793
|
externalId: string;
|
|
4771
4794
|
enterpriseId: string;
|
|
4772
4795
|
status: ImportedBillStatus;
|
|
@@ -4783,7 +4806,7 @@ export type ImportedBill = {
|
|
|
4783
4806
|
isPaid: boolean;
|
|
4784
4807
|
paidAt?: number | null;
|
|
4785
4808
|
externalStatus?: string | null;
|
|
4786
|
-
/**
|
|
4809
|
+
/** How it got into PennyLane: Email, API, PA/PDP… */
|
|
4787
4810
|
externalSource?: string | null;
|
|
4788
4811
|
fileUrl?: string | null;
|
|
4789
4812
|
};
|
|
@@ -4794,21 +4817,21 @@ export type ImportedBill = {
|
|
|
4794
4817
|
pennylaneId?: string | null;
|
|
4795
4818
|
};
|
|
4796
4819
|
|
|
4797
|
-
/**
|
|
4820
|
+
/** References exactly as they came on the invoice, and which field they came from. */
|
|
4798
4821
|
references: {
|
|
4799
4822
|
projectRef?: string | null;
|
|
4800
4823
|
devisRef?: string | null;
|
|
4801
4824
|
sources?: { project?: string; devis?: string };
|
|
4802
4825
|
};
|
|
4803
4826
|
|
|
4804
|
-
/**
|
|
4827
|
+
/** Automatic resolution. It never creates the bill on its own. */
|
|
4805
4828
|
suggestion?: {
|
|
4806
4829
|
projectId?: string | null;
|
|
4807
4830
|
devisId?: string | null;
|
|
4808
4831
|
reasons: string[];
|
|
4809
4832
|
};
|
|
4810
4833
|
|
|
4811
|
-
/**
|
|
4834
|
+
/** Association confirmed by an administrator. */
|
|
4812
4835
|
assignment?: {
|
|
4813
4836
|
projectId: string;
|
|
4814
4837
|
devisId: string;
|
|
@@ -4825,22 +4848,22 @@ export type ImportedBill = {
|
|
|
4825
4848
|
};
|
|
4826
4849
|
|
|
4827
4850
|
/* -------------------------------------------------------------------------- */
|
|
4828
|
-
/*
|
|
4851
|
+
/* Billing identity */
|
|
4829
4852
|
/* -------------------------------------------------------------------------- */
|
|
4830
4853
|
|
|
4831
4854
|
/**
|
|
4832
|
-
*
|
|
4855
|
+
* Postal address, broken down.
|
|
4833
4856
|
*
|
|
4834
|
-
*
|
|
4835
|
-
*
|
|
4836
|
-
*
|
|
4837
|
-
*
|
|
4857
|
+
* The loose `address` field several entities already carry is not usable for
|
|
4858
|
+
* invoicing: PennyLane — and e-invoicing in general — requires street, postal
|
|
4859
|
+
* code, city and country as separate fields. And `GeoLocation` only stores
|
|
4860
|
+
* lat/lng, so there is nothing to derive them from.
|
|
4838
4861
|
*/
|
|
4839
4862
|
export type PostalAddress = {
|
|
4840
4863
|
address: string;
|
|
4841
4864
|
postalCode: string;
|
|
4842
4865
|
city: string;
|
|
4843
|
-
/**
|
|
4866
|
+
/** Two-letter ISO code: FR, ES, BE… */
|
|
4844
4867
|
countryAlpha2: string;
|
|
4845
4868
|
};
|
|
4846
4869
|
|
|
@@ -4863,80 +4886,79 @@ export enum BillingLanguage {
|
|
|
4863
4886
|
}
|
|
4864
4887
|
|
|
4865
4888
|
/**
|
|
4866
|
-
*
|
|
4889
|
+
* Everything needed to issue an invoice to this entity.
|
|
4867
4890
|
*
|
|
4868
|
-
*
|
|
4869
|
-
* Seller, Provider, MaterialsProvider)
|
|
4870
|
-
*
|
|
4891
|
+
* It is deliberately the same object for the five billable entities (Client,
|
|
4892
|
+
* Pro, Seller, Provider, MaterialsProvider): one type, one validator and one
|
|
4893
|
+
* form, instead of five variants that drift apart.
|
|
4871
4894
|
*
|
|
4872
|
-
*
|
|
4873
|
-
*
|
|
4874
|
-
*
|
|
4895
|
+
* It is filled in incrementally: the PennyLane sending modal asks for whatever
|
|
4896
|
+
* is missing right before invoicing and saves it here, so it only ever gets
|
|
4897
|
+
* completed for the entities that actually get invoiced.
|
|
4875
4898
|
*/
|
|
4876
4899
|
/**
|
|
4877
|
-
*
|
|
4900
|
+
* Legal person or natural person.
|
|
4878
4901
|
*
|
|
4879
|
-
*
|
|
4880
|
-
*
|
|
4881
|
-
*
|
|
4882
|
-
*
|
|
4902
|
+
* Not a cosmetic detail: it decides what the law requires and which PennyLane
|
|
4903
|
+
* endpoint is used. An invoice to a company falls under e-invoicing — SIREN
|
|
4904
|
+
* mandatory, transmitted over the network; one to a private individual is out
|
|
4905
|
+
* of scope and only produces e-reporting, with no client identity.
|
|
4883
4906
|
*
|
|
4884
|
-
*
|
|
4885
|
-
*
|
|
4907
|
+
* `undefined` means "we do not know yet", which is different from the other
|
|
4908
|
+
* two: the form has to ask, not assume.
|
|
4886
4909
|
*/
|
|
4887
4910
|
export type BillingLegalType = 'company' | 'individual';
|
|
4888
4911
|
|
|
4889
4912
|
export type BillingIdentity = {
|
|
4890
|
-
/**
|
|
4913
|
+
/** Company or private individual. See [[BillingLegalType]]. */
|
|
4891
4914
|
legalType?: BillingLegalType;
|
|
4892
4915
|
|
|
4893
4916
|
/**
|
|
4894
|
-
*
|
|
4917
|
+
* Legal name. Mandatory for companies.
|
|
4895
4918
|
*
|
|
4896
|
-
*
|
|
4897
|
-
* [[billingDisplayName]],
|
|
4898
|
-
*
|
|
4919
|
+
* It is not asked of an individual: it is composed from first and last name
|
|
4920
|
+
* by [[billingDisplayName]], so the same fact does not live in two places
|
|
4921
|
+
* and end up saying different things.
|
|
4899
4922
|
*/
|
|
4900
4923
|
legalName: string;
|
|
4901
4924
|
|
|
4902
|
-
/**
|
|
4925
|
+
/** First name. Mandatory for individuals; PennyLane wants it separate. */
|
|
4903
4926
|
firstName?: string;
|
|
4904
|
-
/**
|
|
4927
|
+
/** Last name. Mandatory for individuals. */
|
|
4905
4928
|
lastName?: string;
|
|
4906
|
-
/**
|
|
4929
|
+
/** Billing address. Mandatory. */
|
|
4907
4930
|
address: PostalAddress;
|
|
4908
|
-
/**
|
|
4931
|
+
/** Delivery address, when it differs from the billing one. */
|
|
4909
4932
|
deliveryAddress?: PostalAddress;
|
|
4910
|
-
/** SIREN (9
|
|
4933
|
+
/** SIREN (9 digits) or SIRET (14). */
|
|
4911
4934
|
registrationNumber?: string;
|
|
4912
|
-
/**
|
|
4935
|
+
/** Intra-community VAT number. Not to be confused with the VAT rate. */
|
|
4913
4936
|
vatNumber?: string;
|
|
4914
|
-
/**
|
|
4937
|
+
/** Addresses the invoice is sent to. */
|
|
4915
4938
|
emails?: string[];
|
|
4916
4939
|
phone?: string;
|
|
4917
|
-
/**
|
|
4940
|
+
/** Recipient person or department inside the company. */
|
|
4918
4941
|
recipient?: string;
|
|
4919
4942
|
paymentConditions?: BillingPaymentConditions;
|
|
4920
4943
|
language?: BillingLanguage;
|
|
4921
|
-
/**
|
|
4944
|
+
/** Notes attached to the third party's record. */
|
|
4922
4945
|
notes?: string;
|
|
4923
4946
|
/**
|
|
4924
|
-
*
|
|
4925
|
-
*
|
|
4947
|
+
* The third party's id in PennyLane, cached after the first invoice. It
|
|
4948
|
+
* avoids looking it up again and, above all, avoids duplicating the record.
|
|
4926
4949
|
*/
|
|
4927
4950
|
pennylaneCustomerId?: string;
|
|
4928
4951
|
|
|
4929
4952
|
/**
|
|
4930
|
-
*
|
|
4931
|
-
*
|
|
4932
|
-
*
|
|
4953
|
+
* What the public register says about the company, exactly as it was last
|
|
4954
|
+
* read. It is not printed on the invoice: it is the provenance of what is
|
|
4955
|
+
* above. See [[BillingInseeData]].
|
|
4933
4956
|
*/
|
|
4934
4957
|
insee?: BillingInseeData;
|
|
4935
4958
|
|
|
4936
4959
|
/**
|
|
4937
|
-
*
|
|
4938
|
-
*
|
|
4939
|
-
* Ver [[BillingEnrichment]].
|
|
4960
|
+
* What went wrong the last time this record was completed from the public
|
|
4961
|
+
* registers. Meant to be rendered as a tooltip. See [[BillingEnrichment]].
|
|
4940
4962
|
*/
|
|
4941
4963
|
enrichment?: BillingEnrichment;
|
|
4942
4964
|
|
|
@@ -4945,57 +4967,58 @@ export type BillingIdentity = {
|
|
|
4945
4967
|
};
|
|
4946
4968
|
|
|
4947
4969
|
/**
|
|
4948
|
-
*
|
|
4970
|
+
* What the public register says about a third party's company.
|
|
4949
4971
|
*
|
|
4950
|
-
*
|
|
4951
|
-
* [[BillingIdentity]]
|
|
4952
|
-
*
|
|
4953
|
-
*
|
|
4954
|
-
*
|
|
4972
|
+
* Written by `scripts/enrich-billing-from-insee.js`. It hangs off
|
|
4973
|
+
* [[BillingIdentity]] alongside the rest of what invoicing needs, but in its
|
|
4974
|
+
* own block: the fields above are what gets printed on the invoice and a human
|
|
4975
|
+
* may correct them; this is what the register says and it is rewritten on
|
|
4976
|
+
* every pass.
|
|
4955
4977
|
*/
|
|
4956
4978
|
export interface BillingInseeData {
|
|
4957
|
-
/** SIREN, 9
|
|
4979
|
+
/** SIREN, 9 digits. */
|
|
4958
4980
|
siren?: string;
|
|
4959
|
-
/** SIRET
|
|
4981
|
+
/** SIRET of the establishment queried, 14 digits. */
|
|
4960
4982
|
siret?: string;
|
|
4961
|
-
/**
|
|
4983
|
+
/** Whether the establishment queried is the registered office. */
|
|
4962
4984
|
siege?: boolean;
|
|
4963
|
-
/**
|
|
4985
|
+
/** Legal form (`categorieJuridiqueUniteLegale`). */
|
|
4964
4986
|
legalForm?: string | null;
|
|
4965
|
-
/**
|
|
4987
|
+
/** APE/NAF code (`activitePrincipaleUniteLegale`). */
|
|
4966
4988
|
nafCode?: string | null;
|
|
4967
|
-
/**
|
|
4989
|
+
/** Legal unit state: `A` active, `C` ceased. */
|
|
4968
4990
|
state?: string | null;
|
|
4969
|
-
/**
|
|
4991
|
+
/** Establishment state: `A` open, `F` closed. */
|
|
4970
4992
|
establishmentState?: string | null;
|
|
4971
|
-
/**
|
|
4993
|
+
/** Trade name, when it differs from the legal name. */
|
|
4972
4994
|
tradeName?: string | null;
|
|
4973
|
-
/**
|
|
4995
|
+
/** How it was resolved: `siret`, `siege` or `siege-fallback`. */
|
|
4974
4996
|
matchedBy?: string;
|
|
4975
4997
|
/**
|
|
4976
|
-
*
|
|
4977
|
-
*
|
|
4998
|
+
* Set only when the SIREN was absent from the record and was deduced by
|
|
4999
|
+
* searching on the legal name. It keeps a supplied fact distinguishable from
|
|
5000
|
+
* an inferred one.
|
|
4978
5001
|
*/
|
|
4979
5002
|
sirenFoundBy?: string;
|
|
4980
|
-
/**
|
|
5003
|
+
/** Result of checking the VAT number against VIES. */
|
|
4981
5004
|
vatCheck?: BillingVatCheck;
|
|
4982
|
-
/**
|
|
5005
|
+
/** When the register was last queried. */
|
|
4983
5006
|
checkedAt?: number;
|
|
4984
5007
|
}
|
|
4985
5008
|
|
|
4986
5009
|
/**
|
|
4987
|
-
*
|
|
5010
|
+
* Validation of the intra-community VAT number against the VIES register.
|
|
4988
5011
|
*
|
|
4989
|
-
*
|
|
4990
|
-
* formula
|
|
4991
|
-
*
|
|
4992
|
-
*
|
|
5012
|
+
* INSEE does not publish the number: it is computed from the SIREN, and the
|
|
5013
|
+
* formula always returns something well-formed, including for someone under
|
|
5014
|
+
* franchise en base who has no real number. `valid: false` means the number
|
|
5015
|
+
* does not exist, not that it is malformed.
|
|
4993
5016
|
*/
|
|
4994
5017
|
export interface BillingVatCheck {
|
|
4995
|
-
/**
|
|
5018
|
+
/** The number that was checked. */
|
|
4996
5019
|
number: string;
|
|
4997
5020
|
status: 'VALID' | 'INVALID' | 'UNAVAILABLE';
|
|
4998
|
-
/** `null`
|
|
5021
|
+
/** `null` when VIES did not answer: unknown, which is not the same as no. */
|
|
4999
5022
|
valid: boolean | null;
|
|
5000
5023
|
reason?: string | null;
|
|
5001
5024
|
source: string;
|
|
@@ -5003,64 +5026,64 @@ export interface BillingVatCheck {
|
|
|
5003
5026
|
}
|
|
5004
5027
|
|
|
5005
5028
|
/**
|
|
5006
|
-
*
|
|
5029
|
+
* Severity of an enrichment issue.
|
|
5007
5030
|
*
|
|
5008
|
-
* - `ok`
|
|
5009
|
-
* - `warning`
|
|
5010
|
-
* - `error`
|
|
5011
|
-
*
|
|
5031
|
+
* - `ok` the record was completed with nothing worth flagging.
|
|
5032
|
+
* - `warning` it was completed, but something is worth a look.
|
|
5033
|
+
* - `error` it could not be completed: the identifier is missing, it is not
|
|
5034
|
+
* in the register, or the lookup failed.
|
|
5012
5035
|
*/
|
|
5013
5036
|
export type BillingEnrichmentLevel = 'ok' | 'warning' | 'error';
|
|
5014
5037
|
|
|
5015
5038
|
/**
|
|
5016
|
-
*
|
|
5017
|
-
*
|
|
5039
|
+
* Code for each issue. It exists so they can be filtered and counted without
|
|
5040
|
+
* parsing the text, which is written to be read and may be reworded.
|
|
5018
5041
|
*/
|
|
5019
5042
|
export enum BillingEnrichmentCode {
|
|
5020
|
-
/**
|
|
5043
|
+
/** The record carries neither SIREN nor SIRET. */
|
|
5021
5044
|
NO_IDENTIFIER = 'NO_IDENTIFIER',
|
|
5022
|
-
/**
|
|
5045
|
+
/** Several companies share that legal name: a human must choose. */
|
|
5023
5046
|
SIREN_AMBIGUOUS = 'SIREN_AMBIGUOUS',
|
|
5024
|
-
/**
|
|
5047
|
+
/** The identifier does not appear in the register. */
|
|
5025
5048
|
NOT_FOUND = 'NOT_FOUND',
|
|
5026
|
-
/**
|
|
5049
|
+
/** The legal unit is recorded as ceased. */
|
|
5027
5050
|
COMPANY_CLOSED = 'COMPANY_CLOSED',
|
|
5028
|
-
/**
|
|
5051
|
+
/** The establishment is closed; the company may still be alive. */
|
|
5029
5052
|
ESTABLISHMENT_CLOSED = 'ESTABLISHMENT_CLOSED',
|
|
5030
|
-
/**
|
|
5053
|
+
/** The VAT number is unknown to VIES. Likely franchise en base. */
|
|
5031
5054
|
VAT_NOT_REGISTERED = 'VAT_NOT_REGISTERED',
|
|
5032
|
-
/** VIES
|
|
5055
|
+
/** VIES did not answer: the number was stored unverified. */
|
|
5033
5056
|
VAT_UNVERIFIED = 'VAT_UNVERIFIED',
|
|
5034
|
-
/** VIES
|
|
5057
|
+
/** VIES returns a legal name different from INSEE's. */
|
|
5035
5058
|
VAT_NAME_MISMATCH = 'VAT_NAME_MISMATCH',
|
|
5036
|
-
/**
|
|
5059
|
+
/** Establishment outside France: the country must be filled in by hand. */
|
|
5037
5060
|
FOREIGN_ADDRESS = 'FOREIGN_ADDRESS',
|
|
5038
5061
|
MISSING_POSTAL_CODE = 'MISSING_POSTAL_CODE',
|
|
5039
5062
|
MISSING_STREET = 'MISSING_STREET',
|
|
5040
|
-
/**
|
|
5063
|
+
/** The register lookup failed (network, quota, credentials). */
|
|
5041
5064
|
LOOKUP_ERROR = 'LOOKUP_ERROR',
|
|
5042
5065
|
}
|
|
5043
5066
|
|
|
5044
5067
|
/**
|
|
5045
|
-
*
|
|
5046
|
-
*
|
|
5068
|
+
* What happened the last time this record's billing data was completed from
|
|
5069
|
+
* the public registers.
|
|
5047
5070
|
*
|
|
5048
|
-
* `text`
|
|
5049
|
-
*
|
|
5050
|
-
*
|
|
5071
|
+
* `text` is the field meant to be displayed: plain text, one message per line,
|
|
5072
|
+
* ready for a `title` or a tooltip. `messages` and `codes` are there for
|
|
5073
|
+
* whoever prefers to render them separately or filter by issue type.
|
|
5051
5074
|
*
|
|
5052
|
-
*
|
|
5053
|
-
*
|
|
5054
|
-
*
|
|
5075
|
+
* The whole block is rewritten on every pass. Its absence means the record was
|
|
5076
|
+
* never reviewed; `level` being `ok` means it was reviewed and there was
|
|
5077
|
+
* nothing to flag.
|
|
5055
5078
|
*/
|
|
5056
5079
|
export interface BillingEnrichment {
|
|
5057
|
-
/**
|
|
5080
|
+
/** One message per line, separated by `\n`. Empty when `level` is `ok`. */
|
|
5058
5081
|
text: string;
|
|
5059
|
-
/**
|
|
5082
|
+
/** The same messages, unjoined. */
|
|
5060
5083
|
messages: string[];
|
|
5061
5084
|
codes: BillingEnrichmentCode[];
|
|
5062
5085
|
level: BillingEnrichmentLevel;
|
|
5063
|
-
/**
|
|
5086
|
+
/** Who wrote it, e.g. `insee-script`. */
|
|
5064
5087
|
source: string;
|
|
5065
5088
|
checkedAt: number;
|
|
5066
5089
|
}
|