@opencxh/domain 1.242.0 → 1.244.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.
@@ -1,3 +1,4 @@
1
+ import { PostalAddress } from '../organization/types';
1
2
  import { OwnerScope } from '../scope/types';
2
3
  /** Where a company row came from. `local` is a row somebody created by hand. */
3
4
  export interface CompanySource {
@@ -39,6 +40,11 @@ export interface Company {
39
40
  externalIds: string[];
40
41
  ownerScope: OwnerScope;
41
42
  source: CompanySource;
43
+ /**
44
+ * Where the company sits. Needed by anything that puts this company on paper — a quote's
45
+ * recipient block is the first, and the issue gate refuses a document with a hole in it.
46
+ */
47
+ address?: PostalAddress;
42
48
  /** Raw, human-readable phone/website as entered, for display. */
43
49
  phone?: string;
44
50
  website?: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { DocumentBlock } from '../../platform/document-blocks';
2
+ import { PostalAddress } from '../organization/types';
2
3
  /**
3
4
  * A document template: the blocks a generated document is built from.
4
5
  *
@@ -85,3 +86,44 @@ export interface OrganizationHouseStyle {
85
86
  */
86
87
  iban?: string;
87
88
  }
89
+ /**
90
+ * The sender, as a document shows it: the organisation's own details, already turned into lines.
91
+ *
92
+ * Drawn **around** a document rather than written into it — the reason `DocumentBlock` has no
93
+ * sender block. It is computed on the server so the print, the preview and whatever mails a PDF
94
+ * one day all show the same letterhead, and so the renderer needs to know nothing about
95
+ * `Organization`.
96
+ */
97
+ export interface DocumentSender {
98
+ name: string;
99
+ /** Street, postcode + city, country — only the lines that exist. */
100
+ addressLines: string[];
101
+ /** KvK, VAT, IBAN, plus the organisation's own footer sentence. Only what is filled in. */
102
+ footerLines: string[];
103
+ /** Inline data-URI; there is no publicly readable URL for an uploaded file. */
104
+ logo?: string;
105
+ }
106
+ /**
107
+ * An organisation's details as a letterhead.
108
+ *
109
+ * Every field is optional on `Organization`, so every line here is conditional: a half-filled
110
+ * organisation gets a short letterhead, never `undefined, undefined`. The billing name wins over
111
+ * the display name — what is on a quote is the legal entity.
112
+ */
113
+ export declare function organizationSender(organization: OrganizationLike | null | undefined): DocumentSender;
114
+ /**
115
+ * What {@link organizationSender} reads. Structural rather than `Organization` itself, so this
116
+ * file keeps pointing at the organisation entity instead of the other way round.
117
+ */
118
+ export interface OrganizationLike {
119
+ name?: string;
120
+ displayName?: string;
121
+ logo?: string;
122
+ address?: PostalAddress;
123
+ billing?: {
124
+ companyName?: string;
125
+ vatNumber?: string;
126
+ kvkNumber?: string;
127
+ };
128
+ houseStyle?: OrganizationHouseStyle;
129
+ }
@@ -1,12 +1,18 @@
1
1
  import { OrganizationHouseStyle } from '../document-template/types';
2
2
  import { OrganizationProfile } from './profile';
3
- export interface OrganizationAddress {
3
+ /**
4
+ * A postal address. One shape wherever one appears — the organisation's own and a customer's.
5
+ *
6
+ * A quote prints both, and two types that differ only by name is how the two sides drift apart.
7
+ */
8
+ export interface PostalAddress {
4
9
  street?: string;
5
10
  houseNumber?: string;
6
11
  postalCode?: string;
7
12
  city?: string;
8
13
  country?: string;
9
14
  }
15
+ export type OrganizationAddress = PostalAddress;
10
16
  export interface OrganizationBilling {
11
17
  companyName?: string;
12
18
  /** BTW / VAT number */
@@ -1,6 +1,7 @@
1
1
  import { DocumentBlock } from '../../platform/document-blocks';
2
2
  import { DocumentSlots, TemplateContext } from '../document-template/tokens';
3
3
  import { TaxRate } from '../money/tax';
4
+ import { PostalAddress } from '../organization/types';
4
5
  import { Transaction } from './types';
5
6
  /**
6
7
  * The seam between a transaction and the paper it is printed on.
@@ -16,8 +17,8 @@ import { Transaction } from './types';
16
17
  /** What a template author addresses. */
17
18
  export interface TransactionContextSources {
18
19
  companyName?: string;
19
- /** `Company` carries no address today; the token exists so a template survives when it does. */
20
- companyCity?: string;
20
+ /** The customer's postal address, for the recipient block. */
21
+ companyAddress?: PostalAddress;
21
22
  contactName?: string;
22
23
  organizationName?: string;
23
24
  /** Who the recipient reads; drives which template row is picked. */