@placeshakr/config 10.29.4 → 10.31.0-alpha.2
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/auth/policy.js +6 -0
- package/dist/auth/policy.js.map +1 -1
- package/dist/billing/index.js +9 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing/pennylane.js +400 -0
- package/dist/billing/pennylane.js.map +1 -0
- package/dist/billing/permissions.js +27 -0
- package/dist/billing/permissions.js.map +1 -0
- package/dist/billing/prefill.js +208 -0
- package/dist/billing/prefill.js.map +1 -0
- package/dist/billing/types.js +3 -0
- package/dist/billing/types.js.map +1 -0
- package/dist/billing/validate.js +189 -0
- package/dist/billing/validate.js.map +1 -0
- package/dist/environment/base.js +28 -0
- package/dist/environment/base.js.map +1 -1
- package/dist/environment/decorators.js +2 -0
- package/dist/environment/decorators.js.map +1 -1
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/types/auth/policy.d.ts +2 -1
- package/dist/types/auth/policy.d.ts.map +1 -1
- package/dist/types/billing/index.d.ts +6 -0
- package/dist/types/billing/index.d.ts.map +1 -0
- package/dist/types/billing/pennylane.d.ts +191 -0
- package/dist/types/billing/pennylane.d.ts.map +1 -0
- package/dist/types/billing/permissions.d.ts +23 -0
- package/dist/types/billing/permissions.d.ts.map +1 -0
- package/dist/types/billing/prefill.d.ts +42 -0
- package/dist/types/billing/prefill.d.ts.map +1 -0
- package/dist/types/billing/types.d.ts +30 -0
- package/dist/types/billing/types.d.ts.map +1 -0
- package/dist/types/billing/validate.d.ts +48 -0
- package/dist/types/billing/validate.d.ts.map +1 -0
- package/dist/types/environment/base.d.ts.map +1 -1
- package/dist/types/environment/decorators.d.ts.map +1 -1
- package/dist/types/environment/types.d.ts +5 -0
- package/dist/types/environment/types.d.ts.map +1 -1
- package/dist/types/helpers/index.d.ts +1 -0
- package/dist/types/helpers/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +491 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types.js +70 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/auth/policy.ts +21 -1
- package/src/billing/index.ts +5 -0
- package/src/billing/pennylane.ts +530 -0
- package/src/billing/permissions.ts +25 -0
- package/src/billing/prefill.ts +309 -0
- package/src/billing/types.ts +32 -0
- package/src/billing/validate.ts +198 -0
- package/src/environment/base.ts +30 -0
- package/src/environment/decorators.ts +2 -0
- package/src/environment/types.ts +5 -0
- package/src/helpers/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/types.ts +524 -0
package/dist/types/types.d.ts
CHANGED
|
@@ -396,6 +396,8 @@ export interface Enterprise extends Resource {
|
|
|
396
396
|
whatsapp?: boolean;
|
|
397
397
|
marketplace?: boolean;
|
|
398
398
|
multiProfessionals?: boolean;
|
|
399
|
+
/** PennyLane integration: enables the Bills listing and the sync. */
|
|
400
|
+
pennylane?: boolean;
|
|
399
401
|
};
|
|
400
402
|
/**
|
|
401
403
|
* Used to save the last reference created for the two types of bills
|
|
@@ -532,6 +534,12 @@ export interface User extends Resource {
|
|
|
532
534
|
}
|
|
533
535
|
type Permissions = Record<string, boolean>;
|
|
534
536
|
export interface Profile extends Resource {
|
|
537
|
+
/**
|
|
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
|
+
*/
|
|
542
|
+
billing?: BillingIdentity;
|
|
535
543
|
/**
|
|
536
544
|
*
|
|
537
545
|
*/
|
|
@@ -872,6 +880,11 @@ export interface Commissions {
|
|
|
872
880
|
* Represents an provider
|
|
873
881
|
*/
|
|
874
882
|
export interface Provider extends Resource {
|
|
883
|
+
/**
|
|
884
|
+
* Datos de facturacion. Se completa de forma incremental al facturar.
|
|
885
|
+
* Ver [[BillingIdentity]] y `config/src/billing`.
|
|
886
|
+
*/
|
|
887
|
+
billing?: BillingIdentity;
|
|
875
888
|
/**
|
|
876
889
|
* The provider name
|
|
877
890
|
*/
|
|
@@ -2041,9 +2054,31 @@ export type Bill = Resource & {
|
|
|
2041
2054
|
files?: File[];
|
|
2042
2055
|
metadata?: {
|
|
2043
2056
|
sentToIpaidthat?: boolean;
|
|
2057
|
+
/** @deprecated use metadata.pennylane. Kept until email delivery is retired. */
|
|
2044
2058
|
sentToPennyLane?: boolean;
|
|
2059
|
+
/** @deprecated usar metadata.pennylane.lastSyncAt */
|
|
2045
2060
|
sentToPennyLaneDate?: number;
|
|
2061
|
+
/**
|
|
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
|
+
*/
|
|
2066
|
+
pennylane?: PennylaneBillSync;
|
|
2046
2067
|
};
|
|
2068
|
+
/**
|
|
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
|
+
*/
|
|
2073
|
+
source?: 'pennylane';
|
|
2074
|
+
imported?: boolean;
|
|
2075
|
+
/**
|
|
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`.
|
|
2080
|
+
*/
|
|
2081
|
+
billing?: BillingIdentity;
|
|
2047
2082
|
};
|
|
2048
2083
|
export type BillReceived = Bill & {
|
|
2049
2084
|
status: BillReceivedStatus;
|
|
@@ -2181,6 +2216,11 @@ export type Price = {
|
|
|
2181
2216
|
* Represents a materials provider
|
|
2182
2217
|
*/
|
|
2183
2218
|
export interface MaterialsProvider extends Resource {
|
|
2219
|
+
/**
|
|
2220
|
+
* Datos de facturacion. Se completa de forma incremental al facturar.
|
|
2221
|
+
* Ver [[BillingIdentity]] y `config/src/billing`.
|
|
2222
|
+
*/
|
|
2223
|
+
billing?: BillingIdentity;
|
|
2184
2224
|
/**
|
|
2185
2225
|
* The material provider name
|
|
2186
2226
|
*/
|
|
@@ -3801,5 +3841,456 @@ export declare enum EmailEventsEnum {
|
|
|
3801
3841
|
RESET_USER_PASSWORD = "RESET_USER_PASSWORD",
|
|
3802
3842
|
DOCUMENTS_ISSUES = "DOCUMENTS_ISSUES"
|
|
3803
3843
|
}
|
|
3844
|
+
/** Sync state of one specific bill against PennyLane. */
|
|
3845
|
+
export type PennylaneBillSync = {
|
|
3846
|
+
status: 'PENDING' | 'SYNCED' | 'FAILED' | 'SKIPPED';
|
|
3847
|
+
/** Invoice id in PennyLane. */
|
|
3848
|
+
invoiceId?: string;
|
|
3849
|
+
/** Id of the credited invoice in PennyLane (for credit notes). */
|
|
3850
|
+
creditedInvoiceId?: string;
|
|
3851
|
+
/** Id of the PennyLane credit note that cancels this invoice. */
|
|
3852
|
+
creditNoteId?: string;
|
|
3853
|
+
creditNoteNumber?: string;
|
|
3854
|
+
creditNoteStatus?: 'PENDING' | 'SYNCED' | 'FAILED' | 'SKIPPED';
|
|
3855
|
+
creditNoteError?: string;
|
|
3856
|
+
/** Mirror document under enterprises/{id}/importedBills. */
|
|
3857
|
+
importedBillId?: string;
|
|
3858
|
+
fileAttachmentId?: string;
|
|
3859
|
+
/**
|
|
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.
|
|
3862
|
+
*/
|
|
3863
|
+
payloadHash?: string;
|
|
3864
|
+
attempts?: number;
|
|
3865
|
+
lastAttemptAt?: number;
|
|
3866
|
+
lastSyncAt?: number;
|
|
3867
|
+
syncedAt?: number;
|
|
3868
|
+
error?: {
|
|
3869
|
+
code: string;
|
|
3870
|
+
message: string;
|
|
3871
|
+
status?: number;
|
|
3872
|
+
};
|
|
3873
|
+
};
|
|
3874
|
+
/** Which field of the PennyLane invoice each reference is read from. */
|
|
3875
|
+
export type PennylaneReferenceConfig = {
|
|
3876
|
+
/** Field where the supplier writes the chantier reference. */
|
|
3877
|
+
projectField: 'label' | 'invoice_number' | 'lines';
|
|
3878
|
+
/** Field where the supplier writes the devis reference. */
|
|
3879
|
+
devisField: 'label' | 'invoice_number' | 'lines';
|
|
3880
|
+
/** Regular expression with a single capture group. */
|
|
3881
|
+
projectPattern?: string;
|
|
3882
|
+
devisPattern?: string;
|
|
3883
|
+
};
|
|
3884
|
+
export type PennylaneIgnoredSupplier = {
|
|
3885
|
+
name: string;
|
|
3886
|
+
regNo?: string | null;
|
|
3887
|
+
pennylaneId?: string | null;
|
|
3888
|
+
ignoredAt: number;
|
|
3889
|
+
ignoredBy?: string | null;
|
|
3890
|
+
};
|
|
3891
|
+
/** Per-enterprise PennyLane configuration: enterprises/{id}/configurations/pennylane */
|
|
3892
|
+
export type PennylaneConfiguration = {
|
|
3893
|
+
enabled: boolean;
|
|
3894
|
+
/** Numeric id of the company in PennyLane (e.g. '156553'). */
|
|
3895
|
+
companyId?: string;
|
|
3896
|
+
push: {
|
|
3897
|
+
issued: boolean;
|
|
3898
|
+
received: boolean;
|
|
3899
|
+
};
|
|
3900
|
+
pull: {
|
|
3901
|
+
supplierInvoices: boolean;
|
|
3902
|
+
};
|
|
3903
|
+
/** false = send aggregate amounts + PDF only. */
|
|
3904
|
+
sendLineItems: boolean;
|
|
3905
|
+
/** true while the accounting mapping is not settled with the accountant. */
|
|
3906
|
+
importAsIncomplete: boolean;
|
|
3907
|
+
references: PennylaneReferenceConfig;
|
|
3908
|
+
/** PennyLane states that are not pulled (drafts and initial noise). */
|
|
3909
|
+
excludedStates?: string[];
|
|
3910
|
+
/** Days to look back on the initial load or a full resync. */
|
|
3911
|
+
lookbackDays?: number;
|
|
3912
|
+
defaultLedgerAccountId?: string;
|
|
3913
|
+
ledgerAccountByCategory?: Record<string, string>;
|
|
3914
|
+
/** Analytical breakdown per chantier. See [[PennylaneCategoryConfig]]. */
|
|
3915
|
+
categories?: PennylaneCategoryConfig;
|
|
3916
|
+
/** Suppliers whose invoices are ignored automatically on sync. */
|
|
3917
|
+
ignoredSuppliers?: PennylaneIgnoredSupplier[];
|
|
3918
|
+
/** Sync state. Written by the Cloud Functions only. */
|
|
3919
|
+
sync?: {
|
|
3920
|
+
supplierInvoices?: PennylaneSyncState;
|
|
3921
|
+
customerInvoices?: PennylaneSyncState;
|
|
3922
|
+
};
|
|
3923
|
+
};
|
|
3924
|
+
/**
|
|
3925
|
+
* Analytical breakdown per chantier: one PennyLane category per Articho
|
|
3926
|
+
* project, the same one for that project's issued and received invoices.
|
|
3927
|
+
*
|
|
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.
|
|
3933
|
+
*/
|
|
3934
|
+
export type PennylaneCategoryConfig = {
|
|
3935
|
+
/** Master switch. Without it the sync never touches categories. */
|
|
3936
|
+
enabled: boolean;
|
|
3937
|
+
/**
|
|
3938
|
+
* Id of the group created by hand in PennyLane (e.g. "Chantiers Articho").
|
|
3939
|
+
* It differs per enterprise: they are separate PennyLane workspaces.
|
|
3940
|
+
*/
|
|
3941
|
+
groupId: number;
|
|
3942
|
+
/** Also categorise the invoices Articho issues. */
|
|
3943
|
+
includeCustomerInvoices?: boolean;
|
|
3944
|
+
};
|
|
3945
|
+
export type PennylaneSyncState = {
|
|
3946
|
+
/**
|
|
3947
|
+
* Timestamp of the last change processed. PennyLane's changelog only retains
|
|
3948
|
+
* 4 weeks: if this falls behind, data is lost.
|
|
3949
|
+
*/
|
|
3950
|
+
checkpoint: number;
|
|
3951
|
+
lastRunAt: number;
|
|
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;
|
|
3974
|
+
};
|
|
3975
|
+
export declare enum ImportedBillStatus {
|
|
3976
|
+
/** Arrived from PennyLane; project or devis could not be resolved. */
|
|
3977
|
+
PENDING_ASSIGNMENT = "PENDING_ASSIGNMENT",
|
|
3978
|
+
/** Project and devis resolved: waiting for an administrator to confirm. */
|
|
3979
|
+
READY_TO_ASSIGN = "READY_TO_ASSIGN",
|
|
3980
|
+
/** Already has a bill created inside a project. */
|
|
3981
|
+
ASSIGNED = "ASSIGNED",
|
|
3982
|
+
/** Discarded by hand. */
|
|
3983
|
+
IGNORED = "IGNORED",
|
|
3984
|
+
/** Duplicate of another imported invoice. */
|
|
3985
|
+
DUPLICATE = "DUPLICATE"
|
|
3986
|
+
}
|
|
3987
|
+
export declare enum PennylaneSyncEventType {
|
|
3988
|
+
IMPORTED = "IMPORTED",
|
|
3989
|
+
EXTERNAL_STATUS_CHANGE = "EXTERNAL_STATUS_CHANGE",
|
|
3990
|
+
BILL_STATUS_UPDATED = "BILL_STATUS_UPDATED",
|
|
3991
|
+
ASSIGNED = "ASSIGNED",
|
|
3992
|
+
IGNORED = "IGNORED",
|
|
3993
|
+
ERROR = "ERROR"
|
|
3994
|
+
}
|
|
3995
|
+
/**
|
|
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.
|
|
3998
|
+
*/
|
|
3999
|
+
export type PennylaneSyncEvent = {
|
|
4000
|
+
id: string;
|
|
4001
|
+
date: number;
|
|
4002
|
+
type: PennylaneSyncEventType;
|
|
4003
|
+
message: string;
|
|
4004
|
+
before?: Record<string, unknown>;
|
|
4005
|
+
after?: Record<string, unknown>;
|
|
4006
|
+
payload?: Record<string, unknown>;
|
|
4007
|
+
};
|
|
4008
|
+
/**
|
|
4009
|
+
* Mirror of a PennyLane invoice inside Articho.
|
|
4010
|
+
*
|
|
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.
|
|
4014
|
+
*/
|
|
4015
|
+
export type ImportedBill = {
|
|
4016
|
+
id: string;
|
|
4017
|
+
source: 'pennylane';
|
|
4018
|
+
direction: 'supplier' | 'customer';
|
|
4019
|
+
/** Id in PennyLane. The deduplication key. */
|
|
4020
|
+
externalId: string;
|
|
4021
|
+
enterpriseId: string;
|
|
4022
|
+
status: ImportedBillStatus;
|
|
4023
|
+
invoice: {
|
|
4024
|
+
reference: string;
|
|
4025
|
+
label?: string;
|
|
4026
|
+
date: number;
|
|
4027
|
+
dueDate?: number | null;
|
|
4028
|
+
currency: string;
|
|
4029
|
+
amountHT: number;
|
|
4030
|
+
amountTVA: number;
|
|
4031
|
+
amountTTC: number;
|
|
4032
|
+
isPaid: boolean;
|
|
4033
|
+
paidAt?: number | null;
|
|
4034
|
+
externalStatus?: string | null;
|
|
4035
|
+
/** How it got into PennyLane: Email, API, PA/PDP… */
|
|
4036
|
+
externalSource?: string | null;
|
|
4037
|
+
fileUrl?: string | null;
|
|
4038
|
+
};
|
|
4039
|
+
counterparty: {
|
|
4040
|
+
name: string;
|
|
4041
|
+
regNo?: string | null;
|
|
4042
|
+
pennylaneId?: string | null;
|
|
4043
|
+
};
|
|
4044
|
+
/** References exactly as they came on the invoice, and which field they came from. */
|
|
4045
|
+
references: {
|
|
4046
|
+
projectRef?: string | null;
|
|
4047
|
+
devisRef?: string | null;
|
|
4048
|
+
sources?: {
|
|
4049
|
+
project?: string;
|
|
4050
|
+
devis?: string;
|
|
4051
|
+
};
|
|
4052
|
+
};
|
|
4053
|
+
/** Automatic resolution. It never creates the bill on its own. */
|
|
4054
|
+
suggestion?: {
|
|
4055
|
+
projectId?: string | null;
|
|
4056
|
+
devisId?: string | null;
|
|
4057
|
+
reasons: string[];
|
|
4058
|
+
};
|
|
4059
|
+
/** Association confirmed by an administrator. */
|
|
4060
|
+
assignment?: {
|
|
4061
|
+
projectId: string;
|
|
4062
|
+
devisId: string;
|
|
4063
|
+
billId: string;
|
|
4064
|
+
projectName?: string | null;
|
|
4065
|
+
projectReference?: string | null;
|
|
4066
|
+
devisName?: string | null;
|
|
4067
|
+
assignedBy: string;
|
|
4068
|
+
assignedAt: number;
|
|
4069
|
+
} | null;
|
|
4070
|
+
lastSyncAt: number;
|
|
4071
|
+
createdAt: number;
|
|
4072
|
+
};
|
|
4073
|
+
/**
|
|
4074
|
+
* Postal address, broken down.
|
|
4075
|
+
*
|
|
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.
|
|
4080
|
+
*/
|
|
4081
|
+
export type PostalAddress = {
|
|
4082
|
+
address: string;
|
|
4083
|
+
postalCode: string;
|
|
4084
|
+
city: string;
|
|
4085
|
+
/** Two-letter ISO code: FR, ES, BE… */
|
|
4086
|
+
countryAlpha2: string;
|
|
4087
|
+
};
|
|
4088
|
+
export declare enum BillingPaymentConditions {
|
|
4089
|
+
UPON_RECEIPT = "upon_receipt",
|
|
4090
|
+
DAYS_7 = "7_days",
|
|
4091
|
+
DAYS_15 = "15_days",
|
|
4092
|
+
DAYS_30 = "30_days",
|
|
4093
|
+
DAYS_30_EOM = "30_days_end_of_month",
|
|
4094
|
+
DAYS_45 = "45_days",
|
|
4095
|
+
DAYS_45_EOM = "45_days_end_of_month",
|
|
4096
|
+
DAYS_60 = "60_days"
|
|
4097
|
+
}
|
|
4098
|
+
export declare enum BillingLanguage {
|
|
4099
|
+
FR = "fr_FR",
|
|
4100
|
+
EN = "en_GB",
|
|
4101
|
+
DE = "de_DE",
|
|
4102
|
+
ES = "es_ES"
|
|
4103
|
+
}
|
|
4104
|
+
/**
|
|
4105
|
+
* Everything needed to issue an invoice to this entity.
|
|
4106
|
+
*
|
|
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.
|
|
4110
|
+
*
|
|
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.
|
|
4114
|
+
*/
|
|
4115
|
+
/**
|
|
4116
|
+
* Legal person or natural person.
|
|
4117
|
+
*
|
|
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.
|
|
4122
|
+
*
|
|
4123
|
+
* `undefined` means "we do not know yet", which is different from the other
|
|
4124
|
+
* two: the form has to ask, not assume.
|
|
4125
|
+
*/
|
|
4126
|
+
export type BillingLegalType = 'company' | 'individual';
|
|
4127
|
+
export type BillingIdentity = {
|
|
4128
|
+
/** Company or private individual. See [[BillingLegalType]]. */
|
|
4129
|
+
legalType?: BillingLegalType;
|
|
4130
|
+
/**
|
|
4131
|
+
* Legal name. Mandatory for companies.
|
|
4132
|
+
*
|
|
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.
|
|
4136
|
+
*/
|
|
4137
|
+
legalName: string;
|
|
4138
|
+
/** First name. Mandatory for individuals; PennyLane wants it separate. */
|
|
4139
|
+
firstName?: string;
|
|
4140
|
+
/** Last name. Mandatory for individuals. */
|
|
4141
|
+
lastName?: string;
|
|
4142
|
+
/** Billing address. Mandatory. */
|
|
4143
|
+
address: PostalAddress;
|
|
4144
|
+
/** Delivery address, when it differs from the billing one. */
|
|
4145
|
+
deliveryAddress?: PostalAddress;
|
|
4146
|
+
/** SIREN (9 digits) or SIRET (14). */
|
|
4147
|
+
registrationNumber?: string;
|
|
4148
|
+
/** Intra-community VAT number. Not to be confused with the VAT rate. */
|
|
4149
|
+
vatNumber?: string;
|
|
4150
|
+
/** Addresses the invoice is sent to. */
|
|
4151
|
+
emails?: string[];
|
|
4152
|
+
phone?: string;
|
|
4153
|
+
/** Recipient person or department inside the company. */
|
|
4154
|
+
recipient?: string;
|
|
4155
|
+
paymentConditions?: BillingPaymentConditions;
|
|
4156
|
+
language?: BillingLanguage;
|
|
4157
|
+
/** Notes attached to the third party's record. */
|
|
4158
|
+
notes?: string;
|
|
4159
|
+
/**
|
|
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.
|
|
4162
|
+
*/
|
|
4163
|
+
pennylaneCustomerId?: string;
|
|
4164
|
+
/**
|
|
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]].
|
|
4168
|
+
*/
|
|
4169
|
+
insee?: BillingInseeData;
|
|
4170
|
+
/**
|
|
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]].
|
|
4173
|
+
*/
|
|
4174
|
+
enrichment?: BillingEnrichment;
|
|
4175
|
+
updatedAt?: number;
|
|
4176
|
+
updatedBy?: string;
|
|
4177
|
+
};
|
|
4178
|
+
/**
|
|
4179
|
+
* What the public register says about a third party's company.
|
|
4180
|
+
*
|
|
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.
|
|
4186
|
+
*/
|
|
4187
|
+
export interface BillingInseeData {
|
|
4188
|
+
/** SIREN, 9 digits. */
|
|
4189
|
+
siren?: string;
|
|
4190
|
+
/** SIRET of the establishment queried, 14 digits. */
|
|
4191
|
+
siret?: string;
|
|
4192
|
+
/** Whether the establishment queried is the registered office. */
|
|
4193
|
+
siege?: boolean;
|
|
4194
|
+
/** Legal form (`categorieJuridiqueUniteLegale`). */
|
|
4195
|
+
legalForm?: string | null;
|
|
4196
|
+
/** APE/NAF code (`activitePrincipaleUniteLegale`). */
|
|
4197
|
+
nafCode?: string | null;
|
|
4198
|
+
/** Legal unit state: `A` active, `C` ceased. */
|
|
4199
|
+
state?: string | null;
|
|
4200
|
+
/** Establishment state: `A` open, `F` closed. */
|
|
4201
|
+
establishmentState?: string | null;
|
|
4202
|
+
/** Trade name, when it differs from the legal name. */
|
|
4203
|
+
tradeName?: string | null;
|
|
4204
|
+
/** How it was resolved: `siret`, `siege` or `siege-fallback`. */
|
|
4205
|
+
matchedBy?: string;
|
|
4206
|
+
/**
|
|
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.
|
|
4210
|
+
*/
|
|
4211
|
+
sirenFoundBy?: string;
|
|
4212
|
+
/** Result of checking the VAT number against VIES. */
|
|
4213
|
+
vatCheck?: BillingVatCheck;
|
|
4214
|
+
/** When the register was last queried. */
|
|
4215
|
+
checkedAt?: number;
|
|
4216
|
+
}
|
|
4217
|
+
/**
|
|
4218
|
+
* Validation of the intra-community VAT number against the VIES register.
|
|
4219
|
+
*
|
|
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.
|
|
4224
|
+
*/
|
|
4225
|
+
export interface BillingVatCheck {
|
|
4226
|
+
/** The number that was checked. */
|
|
4227
|
+
number: string;
|
|
4228
|
+
status: 'VALID' | 'INVALID' | 'UNAVAILABLE';
|
|
4229
|
+
/** `null` when VIES did not answer: unknown, which is not the same as no. */
|
|
4230
|
+
valid: boolean | null;
|
|
4231
|
+
reason?: string | null;
|
|
4232
|
+
source: string;
|
|
4233
|
+
checkedAt: number;
|
|
4234
|
+
}
|
|
4235
|
+
/**
|
|
4236
|
+
* Severity of an enrichment issue.
|
|
4237
|
+
*
|
|
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.
|
|
4242
|
+
*/
|
|
4243
|
+
export type BillingEnrichmentLevel = 'ok' | 'warning' | 'error';
|
|
4244
|
+
/**
|
|
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.
|
|
4247
|
+
*/
|
|
4248
|
+
export declare enum BillingEnrichmentCode {
|
|
4249
|
+
/** The record carries neither SIREN nor SIRET. */
|
|
4250
|
+
NO_IDENTIFIER = "NO_IDENTIFIER",
|
|
4251
|
+
/** Several companies share that legal name: a human must choose. */
|
|
4252
|
+
SIREN_AMBIGUOUS = "SIREN_AMBIGUOUS",
|
|
4253
|
+
/** The identifier does not appear in the register. */
|
|
4254
|
+
NOT_FOUND = "NOT_FOUND",
|
|
4255
|
+
/** The legal unit is recorded as ceased. */
|
|
4256
|
+
COMPANY_CLOSED = "COMPANY_CLOSED",
|
|
4257
|
+
/** The establishment is closed; the company may still be alive. */
|
|
4258
|
+
ESTABLISHMENT_CLOSED = "ESTABLISHMENT_CLOSED",
|
|
4259
|
+
/** The VAT number is unknown to VIES. Likely franchise en base. */
|
|
4260
|
+
VAT_NOT_REGISTERED = "VAT_NOT_REGISTERED",
|
|
4261
|
+
/** VIES did not answer: the number was stored unverified. */
|
|
4262
|
+
VAT_UNVERIFIED = "VAT_UNVERIFIED",
|
|
4263
|
+
/** VIES returns a legal name different from INSEE's. */
|
|
4264
|
+
VAT_NAME_MISMATCH = "VAT_NAME_MISMATCH",
|
|
4265
|
+
/** Establishment outside France: the country must be filled in by hand. */
|
|
4266
|
+
FOREIGN_ADDRESS = "FOREIGN_ADDRESS",
|
|
4267
|
+
MISSING_POSTAL_CODE = "MISSING_POSTAL_CODE",
|
|
4268
|
+
MISSING_STREET = "MISSING_STREET",
|
|
4269
|
+
/** The register lookup failed (network, quota, credentials). */
|
|
4270
|
+
LOOKUP_ERROR = "LOOKUP_ERROR"
|
|
4271
|
+
}
|
|
4272
|
+
/**
|
|
4273
|
+
* What happened the last time this record's billing data was completed from
|
|
4274
|
+
* the public registers.
|
|
4275
|
+
*
|
|
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.
|
|
4279
|
+
*
|
|
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.
|
|
4283
|
+
*/
|
|
4284
|
+
export interface BillingEnrichment {
|
|
4285
|
+
/** One message per line, separated by `\n`. Empty when `level` is `ok`. */
|
|
4286
|
+
text: string;
|
|
4287
|
+
/** The same messages, unjoined. */
|
|
4288
|
+
messages: string[];
|
|
4289
|
+
codes: BillingEnrichmentCode[];
|
|
4290
|
+
level: BillingEnrichmentLevel;
|
|
4291
|
+
/** Who wrote it, e.g. `insee-script`. */
|
|
4292
|
+
source: string;
|
|
4293
|
+
checkedAt: number;
|
|
4294
|
+
}
|
|
3804
4295
|
export {};
|
|
3805
4296
|
//# sourceMappingURL=types.d.ts.map
|