@opencxh/domain 1.246.0 → 1.248.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/entities/business-entity/index.d.ts +1 -0
- package/dist/entities/business-entity/types.d.ts +74 -0
- package/dist/entities/business-entity/types.test.d.ts +1 -0
- package/dist/entities/catalog/types.d.ts +10 -0
- package/dist/entities/document-template/types.d.ts +13 -4
- package/dist/entities/money/tax.d.ts +9 -0
- package/dist/entities/transaction/keys.d.ts +17 -0
- package/dist/entities/transaction/keys.test.d.ts +1 -0
- package/dist/entities/transaction/types.d.ts +7 -0
- package/dist/index.cjs +17 -17
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1258 -1232
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { PostalAddress } from '../organization/types';
|
|
2
|
+
/**
|
|
3
|
+
* The service-bus key `apps/organization` answers with its administrations.
|
|
4
|
+
*
|
|
5
|
+
* Here and not as a literal in each consumer: the key belongs to the record, and a consumer that
|
|
6
|
+
* spells it itself is a consumer that keeps spelling it after the owner renames it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BUSINESS_ENTITY_LIST_SERVICE = "organization.business-entities.list";
|
|
9
|
+
/**
|
|
10
|
+
* One set of books with one letterhead: a BV, a VOF, a foreign branch.
|
|
11
|
+
*
|
|
12
|
+
* Two of these in one workspace is the Odoo/Exact "divisions" model — one inbox, one CRM, one
|
|
13
|
+
* team, two sets of books. It is deliberately **not** a second tenant (that is
|
|
14
|
+
* `Organization.parentId`, and it splits the inbox and the CRM too) and **not** a rung of
|
|
15
|
+
* {@link OwnerScope}: an entity says which party issues a document and which books it lands in,
|
|
16
|
+
* never who may read it.
|
|
17
|
+
*
|
|
18
|
+
* Absent is the normal case. An organisation with one entity is an organisation that never sees
|
|
19
|
+
* the concept, and that path must keep working — which is why no field here is required beyond
|
|
20
|
+
* the name, and why no existing row anywhere needs a write.
|
|
21
|
+
*/
|
|
22
|
+
export interface BusinessEntity {
|
|
23
|
+
id: string;
|
|
24
|
+
organizationId: string;
|
|
25
|
+
/** The legal name, as it goes on the paper. */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Short code for the badge and, from the numbering phase, the default number prefix. */
|
|
28
|
+
code?: string;
|
|
29
|
+
address?: PostalAddress;
|
|
30
|
+
/**
|
|
31
|
+
* The three identifications that belong together and today live on two different objects —
|
|
32
|
+
* `billing.vatNumber` / `billing.kvkNumber` on the organisation, `houseStyle.iban` beside it.
|
|
33
|
+
* The reason they were split ("a second copy is the one that goes stale") falls away here.
|
|
34
|
+
*/
|
|
35
|
+
vatNumber?: string;
|
|
36
|
+
kvkNumber?: string;
|
|
37
|
+
iban?: string;
|
|
38
|
+
/** Inline data-URI, same rule as `Organization.logo`. */
|
|
39
|
+
logo?: string;
|
|
40
|
+
accentColor?: string;
|
|
41
|
+
footerText?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The language this entity writes in.
|
|
44
|
+
*
|
|
45
|
+
* The floor of `recipientLocale`, which never had one: `Organization` carries no locale, so the
|
|
46
|
+
* whole ladder was dead at its one call site. It belongs here and not on the tenant — a Dutch
|
|
47
|
+
* BV and its Belgian sister write different default languages under one workspace.
|
|
48
|
+
*/
|
|
49
|
+
locale?: string;
|
|
50
|
+
/** One per entity: an administration is set up per country and per currency. */
|
|
51
|
+
currency?: string;
|
|
52
|
+
/** The one a new document lands on. Exactly one row carries it. */
|
|
53
|
+
isDefault?: boolean;
|
|
54
|
+
/** Archived, never deleted: an issued quote names the entity it went out as. */
|
|
55
|
+
archived?: boolean;
|
|
56
|
+
order?: number;
|
|
57
|
+
createdBy: string;
|
|
58
|
+
createdAt?: number;
|
|
59
|
+
updatedAt?: number;
|
|
60
|
+
}
|
|
61
|
+
/** What {@link businessEntitySender} reads. Structural, so the document layer keeps pointing here. */
|
|
62
|
+
export type BusinessEntityLike = Pick<BusinessEntity, "name" | "address" | "vatNumber" | "kvkNumber" | "iban" | "logo" | "footerText">;
|
|
63
|
+
/**
|
|
64
|
+
* Does this row belong to this entity?
|
|
65
|
+
*
|
|
66
|
+
* Master data is owned by **exactly one** entity — two administrations with the same offering
|
|
67
|
+
* keep two rows. An unset owner means the **default** entity, and that is what makes this cost no
|
|
68
|
+
* backfill: every product written before entities existed keeps showing up where it always did,
|
|
69
|
+
* and the first save stamps it for real.
|
|
70
|
+
*
|
|
71
|
+
* The check runs in memory because the rows are loaded whole anyway, and because "the field is
|
|
72
|
+
* unset" is not expressible as a filter on this platform — there is no `$exists`.
|
|
73
|
+
*/
|
|
74
|
+
export declare function belongsToEntity(rowEntityId: string | undefined, entityId: string, isDefaultEntity: boolean): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -50,6 +50,14 @@ export interface Product {
|
|
|
50
50
|
costPriceCents?: Cents;
|
|
51
51
|
/** Who we buy it from. A `Company` in crm, so free — and all a later purchase order needs. */
|
|
52
52
|
supplierCompanyId?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The administration this belongs to. Unset = the default one — see `belongsToEntity`.
|
|
55
|
+
*
|
|
56
|
+
* Exactly one, not a list: two administrations that both sell this keep two rows, with their
|
|
57
|
+
* own sku, their own price and their own ledger category. That is the price of a hard split and
|
|
58
|
+
* it is what was chosen.
|
|
59
|
+
*/
|
|
60
|
+
businessEntityId?: string;
|
|
53
61
|
archived?: boolean;
|
|
54
62
|
order?: number;
|
|
55
63
|
createdBy: string;
|
|
@@ -91,6 +99,8 @@ export interface PriceRule {
|
|
|
91
99
|
* contract price is not a second pricing mechanism, it is a price rule with an owner and a term.
|
|
92
100
|
*/
|
|
93
101
|
contractId?: string;
|
|
102
|
+
/** The administration this rule belongs to. Unset = the default one. */
|
|
103
|
+
businessEntityId?: string;
|
|
94
104
|
createdBy: string;
|
|
95
105
|
createdAt?: number;
|
|
96
106
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DocumentBlock } from '../../platform/document-blocks';
|
|
2
|
+
import { BusinessEntityLike } from '../business-entity/types';
|
|
2
3
|
import { PostalAddress } from '../organization/types';
|
|
3
4
|
/**
|
|
4
5
|
* A document template: the blocks a generated document is built from.
|
|
@@ -104,11 +105,19 @@ export interface DocumentSender {
|
|
|
104
105
|
logo?: string;
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
|
-
*
|
|
108
|
+
* A sending entity's details as a letterhead.
|
|
108
109
|
*
|
|
109
|
-
* Every field is optional
|
|
110
|
-
*
|
|
111
|
-
*
|
|
110
|
+
* Every field is optional, so every line here is conditional: a half-filled entity gets a short
|
|
111
|
+
* letterhead, never `undefined, undefined`. **Nothing is inherited from the organisation** — a
|
|
112
|
+
* second BV that has not filled in its own KvK number prints no number rather than the first
|
|
113
|
+
* BV's, because this is a legal document. The issue gate catches the hole instead.
|
|
114
|
+
*/
|
|
115
|
+
export declare function businessEntitySender(entity: BusinessEntityLike | null | undefined): DocumentSender;
|
|
116
|
+
/**
|
|
117
|
+
* The organisation as a letterhead. One caller left: the seed that gives an organisation its
|
|
118
|
+
* first `BusinessEntity`. An adapter and not a second line-builder, so the two can never drift.
|
|
119
|
+
*
|
|
120
|
+
* The billing name wins over the display name — what is on a quote is the legal entity.
|
|
112
121
|
*/
|
|
113
122
|
export declare function organizationSender(organization: OrganizationLike | null | undefined): DocumentSender;
|
|
114
123
|
/**
|
|
@@ -7,6 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export interface TaxRate {
|
|
9
9
|
key: string;
|
|
10
|
+
/**
|
|
11
|
+
* Which sending entity this rate belongs to. Empty = every entity.
|
|
12
|
+
*
|
|
13
|
+
* A scalar and **not** a list, unlike the rest of the master data: a Belgian sister entity does
|
|
14
|
+
* not need the `low` rate *hidden*, it needs a different percentage for the same key. That is an
|
|
15
|
+
* override, and a membership list cannot express one. An entity's own row shadows the shared row
|
|
16
|
+
* with the same key.
|
|
17
|
+
*/
|
|
18
|
+
businessEntityId?: string;
|
|
10
19
|
/** i18n key, not text — the same rule as `FIXED_TYPES` in work. */
|
|
11
20
|
label: string;
|
|
12
21
|
/** Whole percent as written on the invoice: `21`, not `0.21`. */
|
|
@@ -14,3 +14,20 @@ export declare function transactionScopeKey(kindKey: string, id: string): string
|
|
|
14
14
|
export declare function productScopeKey(id: string): string;
|
|
15
15
|
/** Is this scopeKey one of ours, and which id does it point at? */
|
|
16
16
|
export declare function transactionIdFromScope(scopeKey: string): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* A transaction's file keys: itself, and the customer it is for.
|
|
19
|
+
*
|
|
20
|
+
* That second one is what puts a quote in the customer file without anybody linking it by hand:
|
|
21
|
+
* the relation hub matches on shared keys, so `company:<id>` on the quote makes it a *derived*
|
|
22
|
+
* row under that company — a lead, not a statement.
|
|
23
|
+
*
|
|
24
|
+
* Bounded by the row itself, on purpose. These ride along on every authorisation, including every
|
|
25
|
+
* memory write; a list that grows with the transaction would be paid for on each one.
|
|
26
|
+
*/
|
|
27
|
+
export declare function transactionDossierKeys(transaction: {
|
|
28
|
+
id: string;
|
|
29
|
+
kindKey: string;
|
|
30
|
+
companyId?: string;
|
|
31
|
+
contactId?: string;
|
|
32
|
+
dealItemId?: string;
|
|
33
|
+
}): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -25,6 +25,13 @@ export interface Transaction {
|
|
|
25
25
|
/** Version within the same quote. A sent quote is revised, never edited. */
|
|
26
26
|
version: number;
|
|
27
27
|
previousVersionId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Which sending entity issues this — whose letterhead, whose books, whose number series.
|
|
30
|
+
*
|
|
31
|
+
* Empty means the organisation's default. Frozen at issue: it is not in
|
|
32
|
+
* {@link FROZEN_WRITABLE_FIELDS}, so changing it on a sent document is already refused.
|
|
33
|
+
*/
|
|
34
|
+
businessEntityId?: string;
|
|
28
35
|
companyId: string;
|
|
29
36
|
contactId?: string;
|
|
30
37
|
/** The work item (the deal) this belongs to. Optional: not every quote has a deal. */
|