@things-factory/invoice 10.1.226 → 10.1.227

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.
Files changed (95) hide show
  1. package/dist-client/document/document-amount.d.ts +7 -2
  2. package/dist-client/document/document-amount.js +11 -6
  3. package/dist-client/document/document-amount.js.map +1 -1
  4. package/dist-client/document/document-defaults.d.ts +24 -0
  5. package/dist-client/document/document-defaults.js +43 -0
  6. package/dist-client/document/document-defaults.js.map +1 -0
  7. package/dist-client/document/document-form.d.ts +24 -6
  8. package/dist-client/document/document-form.js +126 -15
  9. package/dist-client/document/document-form.js.map +1 -1
  10. package/dist-client/document/document-lines.d.ts +35 -1
  11. package/dist-client/document/document-lines.js +58 -9
  12. package/dist-client/document/document-lines.js.map +1 -1
  13. package/dist-client/document/document-party.d.ts +37 -0
  14. package/dist-client/document/document-party.js +217 -0
  15. package/dist-client/document/document-party.js.map +1 -0
  16. package/dist-client/document/document-preview.d.ts +37 -0
  17. package/dist-client/document/document-preview.js +181 -0
  18. package/dist-client/document/document-preview.js.map +1 -0
  19. package/dist-client/document/document-print.d.ts +3 -13
  20. package/dist-client/document/document-print.js +3 -45
  21. package/dist-client/document/document-print.js.map +1 -1
  22. package/dist-client/index.d.ts +9 -3
  23. package/dist-client/index.js +9 -3
  24. package/dist-client/index.js.map +1 -1
  25. package/dist-client/pages/invoice-editor.d.ts +37 -12
  26. package/dist-client/pages/invoice-editor.js +171 -79
  27. package/dist-client/pages/invoice-editor.js.map +1 -1
  28. package/dist-client/pages/invoice-list.d.ts +21 -1
  29. package/dist-client/pages/invoice-list.js +145 -14
  30. package/dist-client/pages/invoice-list.js.map +1 -1
  31. package/dist-client/tsconfig.tsbuildinfo +1 -1
  32. package/dist-client/viewparts/document-defaults-setting-let.d.ts +19 -0
  33. package/dist-client/viewparts/document-defaults-setting-let.js +139 -0
  34. package/dist-client/viewparts/document-defaults-setting-let.js.map +1 -0
  35. package/dist-server/role-tasks.js +5 -2
  36. package/dist-server/role-tasks.js.map +1 -1
  37. package/dist-server/service/document-defaults/document-defaults-resolver.d.ts +28 -0
  38. package/dist-server/service/document-defaults/document-defaults-resolver.js +136 -0
  39. package/dist-server/service/document-defaults/document-defaults-resolver.js.map +1 -0
  40. package/dist-server/service/document-defaults/document-defaults-rules.d.ts +25 -0
  41. package/dist-server/service/document-defaults/document-defaults-rules.js +50 -0
  42. package/dist-server/service/document-defaults/document-defaults-rules.js.map +1 -0
  43. package/dist-server/service/document-defaults/index.d.ts +6 -0
  44. package/dist-server/service/document-defaults/index.js +11 -0
  45. package/dist-server/service/document-defaults/index.js.map +1 -0
  46. package/dist-server/service/index.d.ts +2 -0
  47. package/dist-server/service/index.js +4 -1
  48. package/dist-server/service/index.js.map +1 -1
  49. package/dist-server/service/invoice/commercial-document.d.ts +2 -0
  50. package/dist-server/service/invoice/commercial-document.js +11 -1
  51. package/dist-server/service/invoice/commercial-document.js.map +1 -1
  52. package/dist-server/service/invoice/invoice-document-file.d.ts +20 -0
  53. package/dist-server/service/invoice/invoice-document-file.js +38 -0
  54. package/dist-server/service/invoice/invoice-document-file.js.map +1 -0
  55. package/dist-server/service/invoice/invoice-query.d.ts +3 -1
  56. package/dist-server/service/invoice/invoice-query.js +33 -0
  57. package/dist-server/service/invoice/invoice-query.js.map +1 -1
  58. package/dist-server/service/invoice/invoice-rules.d.ts +18 -11
  59. package/dist-server/service/invoice/invoice-rules.js +49 -96
  60. package/dist-server/service/invoice/invoice-rules.js.map +1 -1
  61. package/dist-server/service/invoice/invoice-service.d.ts +1 -0
  62. package/dist-server/service/invoice/invoice-service.js +5 -2
  63. package/dist-server/service/invoice/invoice-service.js.map +1 -1
  64. package/dist-server/service/invoice/invoice-type.d.ts +12 -0
  65. package/dist-server/service/invoice/invoice-type.js +37 -1
  66. package/dist-server/service/invoice/invoice-type.js.map +1 -1
  67. package/dist-server/tsconfig.tsbuildinfo +1 -1
  68. package/dist-shared/document-amounts.d.ts +56 -0
  69. package/dist-shared/document-amounts.js +134 -0
  70. package/dist-shared/document-amounts.js.map +1 -0
  71. package/dist-shared/document-money.d.ts +12 -0
  72. package/dist-shared/document-money.js +38 -0
  73. package/dist-shared/document-money.js.map +1 -0
  74. package/dist-shared/document-print.d.ts +37 -0
  75. package/dist-shared/document-print.js +87 -0
  76. package/dist-shared/document-print.js.map +1 -0
  77. package/dist-shared/document-start.d.ts +15 -0
  78. package/dist-shared/document-start.js +51 -0
  79. package/dist-shared/document-start.js.map +1 -0
  80. package/dist-shared/invoice-standing.d.ts +25 -0
  81. package/dist-shared/invoice-standing.js +51 -0
  82. package/dist-shared/invoice-standing.js.map +1 -0
  83. package/package.json +9 -7
  84. package/shared/document-amounts.ts +209 -0
  85. package/shared/document-money.ts +33 -0
  86. package/shared/document-print.ts +131 -0
  87. package/shared/document-start.ts +46 -0
  88. package/shared/invoice-standing.ts +49 -0
  89. package/translations/en.json +32 -6
  90. package/translations/es.json +22 -1
  91. package/translations/ja.json +22 -1
  92. package/translations/ko.json +32 -6
  93. package/translations/ms.json +22 -1
  94. package/translations/zh.json +22 -1
  95. package/tsconfig.shared.tsbuildinfo +1 -1
@@ -0,0 +1,19 @@
1
+ import '@material/web/button/outlined-button.js';
2
+ import '@things-factory/setting-base';
3
+ import { LitElement, nothing } from 'lit';
4
+ declare const DocumentDefaultsSettingLet_base: (new (...args: any[]) => LitElement) & typeof LitElement;
5
+ /**
6
+ * The company's own words for every new quotation and invoice (ADR-0170): our side, the account to pay into, the
7
+ * payment terms offered - one a line, the first a new document's - a standing note, how long an offer holds and how
8
+ * many days after its issue an invoice is due. Shown
9
+ * to whoever keeps the invoices; for anyone else the card stays empty.
10
+ */
11
+ export declare class DocumentDefaultsSettingLet extends DocumentDefaultsSettingLet_base {
12
+ static styles: import("lit").CSSResult[];
13
+ private value?;
14
+ private busy;
15
+ connectedCallback(): Promise<void>;
16
+ render(): typeof nothing | import("lit-html").TemplateResult<1>;
17
+ private save;
18
+ }
19
+ export {};
@@ -0,0 +1,139 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@material/web/button/outlined-button.js';
3
+ import '@things-factory/setting-base';
4
+ import gql from 'graphql-tag';
5
+ import { css, html, LitElement, nothing } from 'lit';
6
+ import { customElement, state } from 'lit/decorators.js';
7
+ import { client } from '@operato/graphql';
8
+ import { i18next, localize } from '@operato/i18n';
9
+ import { notify } from '@operato/layout';
10
+ import { hasPrivilege } from '@things-factory/auth-base/dist-client';
11
+ import { DOCUMENT_DEFAULTS_FIELDS, documentDefaults } from '../document/document-defaults';
12
+ /**
13
+ * The company's own words for every new quotation and invoice (ADR-0170): our side, the account to pay into, the
14
+ * payment terms offered - one a line, the first a new document's - a standing note, how long an offer holds and how
15
+ * many days after its issue an invoice is due. Shown
16
+ * to whoever keeps the invoices; for anyone else the card stays empty.
17
+ */
18
+ let DocumentDefaultsSettingLet = class DocumentDefaultsSettingLet extends localize(i18next)(LitElement) {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.busy = false;
22
+ }
23
+ static { this.styles = [
24
+ css `
25
+ div[content] {
26
+ display: grid;
27
+ grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
28
+ gap: var(--spacing-medium, 8px) var(--spacing-large, 12px);
29
+ }
30
+ label {
31
+ display: flex;
32
+ flex-direction: column;
33
+ gap: var(--spacing-small, 4px);
34
+ font: var(--label-font);
35
+ color: var(--md-sys-color-on-surface);
36
+ text-transform: var(--label-text-transform);
37
+ }
38
+ label.wide {
39
+ grid-column: 1 / -1;
40
+ }
41
+ small {
42
+ color: var(--md-sys-color-on-surface-variant);
43
+ text-transform: none;
44
+ }
45
+ input,
46
+ textarea {
47
+ box-sizing: border-box;
48
+ width: 100%;
49
+ background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));
50
+ color: var(--input-field-color, var(--md-sys-color-on-surface));
51
+ border: var(--border-dim-color);
52
+ border-radius: var(--border-radius);
53
+ padding: var(--input-padding);
54
+ font: var(--input-font);
55
+ text-transform: none;
56
+ }
57
+ textarea {
58
+ min-height: 64px;
59
+ resize: vertical;
60
+ }
61
+ div[actions] {
62
+ grid-column: 1 / -1;
63
+ display: flex;
64
+ justify-content: flex-end;
65
+ }
66
+ `
67
+ ]; }
68
+ async connectedCallback() {
69
+ super.connectedCallback();
70
+ if (!(await hasPrivilege({ category: 'invoice', privilege: 'mutation', domainOwnerGranted: true })))
71
+ return;
72
+ this.value = (await documentDefaults()) ?? undefined;
73
+ }
74
+ render() {
75
+ const value = this.value;
76
+ if (!value)
77
+ return nothing;
78
+ const set = (patch) => (this.value = { ...value, ...patch });
79
+ const input = (name, label) => html `<label>${i18next.t(label)}<input .value=${String(value[name] ?? '')} @input=${(e) => set({ [name]: e.target.value })} /></label>`;
80
+ const prose = (name, label) => html `<label class="wide">${i18next.t(label)}<textarea .value=${String(value[name] ?? '')} @input=${(e) => set({ [name]: e.target.value })}></textarea></label>`;
81
+ return html `
82
+ <setting-let>
83
+ <span slot="title">${i18next.t('title.invoice-document-defaults')}</span>
84
+ <div slot="content" content>
85
+ ${input('supplierName', 'field.invoice-supplier-name')} ${input('supplierRegistrationNumber', 'field.invoice-party-registration-number')}
86
+ ${prose('supplierAddress', 'field.invoice-party-address')} ${prose('bankDetails', 'field.invoice-bank-details')}
87
+ <label class="wide"
88
+ >${i18next.t('field.invoice-payment-terms')} <small>${i18next.t('text.invoice-defaults-terms-hint')}</small>
89
+ <textarea .value=${value.paymentTerms.join('\n')} @input=${(e) => set({ paymentTerms: e.target.value.split('\n') })}></textarea>
90
+ </label>
91
+ ${prose('notes', 'field.invoice-notes')}
92
+ <label
93
+ >${i18next.t('field.invoice-defaults-valid-days')}
94
+ <input type="number" min="1" max="365" .value=${String(value.validDays)} @input=${(e) => set({ validDays: Number(e.target.value) })}
95
+ /></label>
96
+ <label
97
+ >${i18next.t('field.invoice-defaults-payment-days')}
98
+ <input type="number" min="0" max="365" .value=${String(value.paymentDays)} @input=${(e) => set({ paymentDays: Number(e.target.value) })}
99
+ /></label>
100
+ <div actions>
101
+ <md-outlined-button ?disabled=${this.busy} @click=${() => this.save()}>${i18next.t('button.save')}</md-outlined-button>
102
+ </div>
103
+ </div>
104
+ </setting-let>
105
+ `;
106
+ }
107
+ async save() {
108
+ this.busy = true;
109
+ try {
110
+ const response = await client.mutate({
111
+ mutation: gql(`mutation ($defaults: DocumentDefaultsInput!) { updateDocumentDefaults(defaults: $defaults) { ${DOCUMENT_DEFAULTS_FIELDS} } }`),
112
+ variables: { defaults: this.value }
113
+ });
114
+ if (response.errors?.length)
115
+ throw response.errors[0];
116
+ this.value = response.data.updateDocumentDefaults;
117
+ notify({ message: i18next.t('text.saved') });
118
+ }
119
+ catch (error) {
120
+ notify({ level: 'error', message: error?.message ?? String(error) });
121
+ }
122
+ finally {
123
+ this.busy = false;
124
+ }
125
+ }
126
+ };
127
+ __decorate([
128
+ state(),
129
+ __metadata("design:type", Object)
130
+ ], DocumentDefaultsSettingLet.prototype, "value", void 0);
131
+ __decorate([
132
+ state(),
133
+ __metadata("design:type", Object)
134
+ ], DocumentDefaultsSettingLet.prototype, "busy", void 0);
135
+ DocumentDefaultsSettingLet = __decorate([
136
+ customElement('document-defaults-setting-let')
137
+ ], DocumentDefaultsSettingLet);
138
+ export { DocumentDefaultsSettingLet };
139
+ //# sourceMappingURL=document-defaults-setting-let.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-defaults-setting-let.js","sourceRoot":"","sources":["../../client/viewparts/document-defaults-setting-let.ts"],"names":[],"mappings":";AAAA,OAAO,yCAAyC,CAAA;AAChD,OAAO,8BAA8B,CAAA;AAErC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,E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B,KAAK,EAAE;;wDAAqB;AAhDlB,0BAA0B;IADtC,aAAa,CAAC,+BAA+B,CAAC;GAClC,0BAA0B,CA4GtC","sourcesContent":["import '@material/web/button/outlined-button.js'\nimport '@things-factory/setting-base'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\n\nimport { DOCUMENT_DEFAULTS_FIELDS, documentDefaults, type DocumentDefaults } from '../document/document-defaults'\n\n/**\n * The company's own words for every new quotation and invoice (ADR-0170): our side, the account to pay into, the\n * payment terms offered - one a line, the first a new document's - a standing note, how long an offer holds and how\n * many days after its issue an invoice is due. Shown\n * to whoever keeps the invoices; for anyone else the card stays empty.\n */\n@customElement('document-defaults-setting-let')\nexport class DocumentDefaultsSettingLet extends localize(i18next)(LitElement) {\n static styles = [\n css`\n div[content] {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));\n gap: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n }\n label {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-small, 4px);\n font: var(--label-font);\n color: var(--md-sys-color-on-surface);\n text-transform: var(--label-text-transform);\n }\n label.wide {\n grid-column: 1 / -1;\n }\n small {\n color: var(--md-sys-color-on-surface-variant);\n text-transform: none;\n }\n input,\n textarea {\n box-sizing: border-box;\n width: 100%;\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n padding: var(--input-padding);\n font: var(--input-font);\n text-transform: none;\n }\n textarea {\n min-height: 64px;\n resize: vertical;\n }\n div[actions] {\n grid-column: 1 / -1;\n display: flex;\n justify-content: flex-end;\n }\n `\n ]\n\n @state() private value?: DocumentDefaults\n @state() private busy = false\n\n async connectedCallback() {\n super.connectedCallback()\n if (!(await hasPrivilege({ category: 'invoice', privilege: 'mutation', domainOwnerGranted: true }))) return\n this.value = (await documentDefaults()) ?? undefined\n }\n\n render() {\n const value = this.value\n if (!value) return nothing\n const set = (patch: Partial<DocumentDefaults>) => (this.value = { ...value, ...patch })\n const input = (name: keyof DocumentDefaults, label: string) =>\n html`<label>${i18next.t(label)}<input .value=${String(value[name] ?? '')} @input=${(e: any) => set({ [name]: e.target.value })} /></label>`\n const prose = (name: keyof DocumentDefaults, label: string) =>\n html`<label class=\"wide\">${i18next.t(label)}<textarea .value=${String(value[name] ?? '')} @input=${(e: any) => set({ [name]: e.target.value })}></textarea></label>`\n\n return html`\n <setting-let>\n <span slot=\"title\">${i18next.t('title.invoice-document-defaults')}</span>\n <div slot=\"content\" content>\n ${input('supplierName', 'field.invoice-supplier-name')} ${input('supplierRegistrationNumber', 'field.invoice-party-registration-number')}\n ${prose('supplierAddress', 'field.invoice-party-address')} ${prose('bankDetails', 'field.invoice-bank-details')}\n <label class=\"wide\"\n >${i18next.t('field.invoice-payment-terms')} <small>${i18next.t('text.invoice-defaults-terms-hint')}</small>\n <textarea .value=${value.paymentTerms.join('\\n')} @input=${(e: any) => set({ paymentTerms: e.target.value.split('\\n') })}></textarea>\n </label>\n ${prose('notes', 'field.invoice-notes')}\n <label\n >${i18next.t('field.invoice-defaults-valid-days')}\n <input type=\"number\" min=\"1\" max=\"365\" .value=${String(value.validDays)} @input=${(e: any) => set({ validDays: Number(e.target.value) })}\n /></label>\n <label\n >${i18next.t('field.invoice-defaults-payment-days')}\n <input type=\"number\" min=\"0\" max=\"365\" .value=${String(value.paymentDays)} @input=${(e: any) => set({ paymentDays: Number(e.target.value) })}\n /></label>\n <div actions>\n <md-outlined-button ?disabled=${this.busy} @click=${() => this.save()}>${i18next.t('button.save')}</md-outlined-button>\n </div>\n </div>\n </setting-let>\n `\n }\n\n private async save() {\n this.busy = true\n try {\n const response = await client.mutate({\n mutation: gql(`mutation ($defaults: DocumentDefaultsInput!) { updateDocumentDefaults(defaults: $defaults) { ${DOCUMENT_DEFAULTS_FIELDS} } }`),\n variables: { defaults: this.value }\n })\n if (response.errors?.length) throw response.errors[0]\n this.value = response.data.updateDocumentDefaults\n notify({ message: i18next.t('text.saved') })\n } catch (error: any) {\n notify({ level: 'error', message: error?.message ?? String(error) })\n } finally {\n this.busy = false\n }\n }\n}\n"]}
@@ -10,7 +10,10 @@
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.ROLE_TASKS = void 0;
12
12
  exports.ROLE_TASKS = [
13
- { id: 'invoice.reading', grants: [{ category: 'invoice', axes: ['query'] }] },
14
- { id: 'invoice.keeping', grants: [{ category: 'invoice', axes: ['query', 'mutation'] }] }
13
+ /* Reading or keeping the invoices reads the company's words a new one starts with (ADR-0170). */
14
+ { id: 'invoice.reading', grants: [{ category: 'invoice', axes: ['query'] }, { category: 'invoice-published', axes: ['query'] }] },
15
+ { id: 'invoice.keeping', grants: [{ category: 'invoice', axes: ['query', 'mutation'] }, { category: 'invoice-published', axes: ['query'] }] },
16
+ /* Writing quotations without the invoices: the company's words alone. */
17
+ { id: 'invoice.defaults-reading', grants: [{ category: 'invoice-published', axes: ['query'] }] }
15
18
  ];
16
19
  //# sourceMappingURL=role-tasks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"role-tasks.js","sourceRoot":"","sources":["../server/role-tasks.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAIU,QAAA,UAAU,GAAe;IACpC,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;IAC7E,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE;CAC1F,CAAA","sourcesContent":["/*\n * The work this module names, for the seats applications build (ADR-0139 decision 11).\n *\n * A task holds whole privileges: each opens everything its doors open, and the words under `task.<id>` in this\n * module's translations say what that is. Seats are put together by applications (`RoleTemplate.tasks`).\n *\n * Data only - `server/index.ts` registers it - so an application's tests read it without starting the framework.\n */\n\nimport type { RoleTask } from '@things-factory/auth-base'\n\nexport const ROLE_TASKS: RoleTask[] = [\n { id: 'invoice.reading', grants: [{ category: 'invoice', axes: ['query'] }] },\n { id: 'invoice.keeping', grants: [{ category: 'invoice', axes: ['query', 'mutation'] }] }\n]\n"]}
1
+ {"version":3,"file":"role-tasks.js","sourceRoot":"","sources":["../server/role-tasks.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAIU,QAAA,UAAU,GAAe;IACpC,iGAAiG;IACjG,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;IACjI,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;IAC7I,yEAAyE;IACzE,EAAE,EAAE,EAAE,0BAA0B,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;CACjG,CAAA","sourcesContent":["/*\n * The work this module names, for the seats applications build (ADR-0139 decision 11).\n *\n * A task holds whole privileges: each opens everything its doors open, and the words under `task.<id>` in this\n * module's translations say what that is. Seats are put together by applications (`RoleTemplate.tasks`).\n *\n * Data only - `server/index.ts` registers it - so an application's tests read it without starting the framework.\n */\n\nimport type { RoleTask } from '@things-factory/auth-base'\n\nexport const ROLE_TASKS: RoleTask[] = [\n /* Reading or keeping the invoices reads the company's words a new one starts with (ADR-0170). */\n { id: 'invoice.reading', grants: [{ category: 'invoice', axes: ['query'] }, { category: 'invoice-published', axes: ['query'] }] },\n { id: 'invoice.keeping', grants: [{ category: 'invoice', axes: ['query', 'mutation'] }, { category: 'invoice-published', axes: ['query'] }] },\n /* Writing quotations without the invoices: the company's words alone. */\n { id: 'invoice.defaults-reading', grants: [{ category: 'invoice-published', axes: ['query'] }] }\n]\n"]}
@@ -0,0 +1,28 @@
1
+ export declare class DocumentDefaults {
2
+ supplierName: string;
3
+ supplierRegistrationNumber: string;
4
+ supplierAddress: string;
5
+ bankDetails: string;
6
+ paymentTerms: string[];
7
+ notes: string;
8
+ validDays: number;
9
+ paymentDays: number;
10
+ }
11
+ export declare class DocumentDefaultsInput {
12
+ supplierName?: string;
13
+ supplierRegistrationNumber?: string;
14
+ supplierAddress?: string;
15
+ bankDetails?: string;
16
+ paymentTerms?: string[];
17
+ notes?: string;
18
+ validDays?: number;
19
+ paymentDays?: number;
20
+ }
21
+ /**
22
+ * The company's words for new quotations and invoices (ADR-0170). Read by whoever writes either document
23
+ * (`invoice-published`); changed by whoever keeps the invoices (`invoice:mutation`), on the Settings screen.
24
+ */
25
+ export declare class DocumentDefaultsResolver {
26
+ documentDefaults(context: ResolverContext): Promise<DocumentDefaults>;
27
+ updateDocumentDefaults(defaults: DocumentDefaultsInput, context: ResolverContext): Promise<DocumentDefaults>;
28
+ }
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentDefaultsResolver = exports.DocumentDefaultsInput = exports.DocumentDefaults = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const typeorm_1 = require("typeorm");
7
+ const shell_1 = require("@things-factory/shell");
8
+ const document_defaults_rules_1 = require("./document-defaults-rules");
9
+ let DocumentDefaults = class DocumentDefaults {
10
+ };
11
+ exports.DocumentDefaults = DocumentDefaults;
12
+ tslib_1.__decorate([
13
+ (0, type_graphql_1.Field)({ description: 'Our name as a supplier.' }),
14
+ tslib_1.__metadata("design:type", String)
15
+ ], DocumentDefaults.prototype, "supplierName", void 0);
16
+ tslib_1.__decorate([
17
+ (0, type_graphql_1.Field)({ description: 'Our business registration number.' }),
18
+ tslib_1.__metadata("design:type", String)
19
+ ], DocumentDefaults.prototype, "supplierRegistrationNumber", void 0);
20
+ tslib_1.__decorate([
21
+ (0, type_graphql_1.Field)({ description: 'Our address.' }),
22
+ tslib_1.__metadata("design:type", String)
23
+ ], DocumentDefaults.prototype, "supplierAddress", void 0);
24
+ tslib_1.__decorate([
25
+ (0, type_graphql_1.Field)({ description: 'The account to pay into, as printed.' }),
26
+ tslib_1.__metadata("design:type", String)
27
+ ], DocumentDefaults.prototype, "bankDetails", void 0);
28
+ tslib_1.__decorate([
29
+ (0, type_graphql_1.Field)(type => [String], { description: 'The payment terms the company offers - the first is a new document\'s, the others a click away.' }),
30
+ tslib_1.__metadata("design:type", Array)
31
+ ], DocumentDefaults.prototype, "paymentTerms", void 0);
32
+ tslib_1.__decorate([
33
+ (0, type_graphql_1.Field)({ description: 'A note every new document carries.' }),
34
+ tslib_1.__metadata("design:type", String)
35
+ ], DocumentDefaults.prototype, "notes", void 0);
36
+ tslib_1.__decorate([
37
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'Days a quotation holds after its issue day.' }),
38
+ tslib_1.__metadata("design:type", Number)
39
+ ], DocumentDefaults.prototype, "validDays", void 0);
40
+ tslib_1.__decorate([
41
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'Days an invoice is due after its issue day.' }),
42
+ tslib_1.__metadata("design:type", Number)
43
+ ], DocumentDefaults.prototype, "paymentDays", void 0);
44
+ exports.DocumentDefaults = DocumentDefaults = tslib_1.__decorate([
45
+ (0, type_graphql_1.ObjectType)({ description: "The company's own words every new quotation and invoice starts with (ADR-0170)." })
46
+ ], DocumentDefaults);
47
+ let DocumentDefaultsInput = class DocumentDefaultsInput {
48
+ };
49
+ exports.DocumentDefaultsInput = DocumentDefaultsInput;
50
+ tslib_1.__decorate([
51
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Our name as a supplier.' }),
52
+ tslib_1.__metadata("design:type", String)
53
+ ], DocumentDefaultsInput.prototype, "supplierName", void 0);
54
+ tslib_1.__decorate([
55
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Our business registration number.' }),
56
+ tslib_1.__metadata("design:type", String)
57
+ ], DocumentDefaultsInput.prototype, "supplierRegistrationNumber", void 0);
58
+ tslib_1.__decorate([
59
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Our address.' }),
60
+ tslib_1.__metadata("design:type", String)
61
+ ], DocumentDefaultsInput.prototype, "supplierAddress", void 0);
62
+ tslib_1.__decorate([
63
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The account to pay into, as printed.' }),
64
+ tslib_1.__metadata("design:type", String)
65
+ ], DocumentDefaultsInput.prototype, "bankDetails", void 0);
66
+ tslib_1.__decorate([
67
+ (0, type_graphql_1.Field)(type => [String], { nullable: true, description: 'The payment terms the company offers, in order.' }),
68
+ tslib_1.__metadata("design:type", Array)
69
+ ], DocumentDefaultsInput.prototype, "paymentTerms", void 0);
70
+ tslib_1.__decorate([
71
+ (0, type_graphql_1.Field)({ nullable: true, description: 'A note every new document carries.' }),
72
+ tslib_1.__metadata("design:type", String)
73
+ ], DocumentDefaultsInput.prototype, "notes", void 0);
74
+ tslib_1.__decorate([
75
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'Days a quotation holds after its issue day (1 to 365).' }),
76
+ tslib_1.__metadata("design:type", Number)
77
+ ], DocumentDefaultsInput.prototype, "validDays", void 0);
78
+ tslib_1.__decorate([
79
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'Days an invoice is due after its issue day (0 to 365).' }),
80
+ tslib_1.__metadata("design:type", Number)
81
+ ], DocumentDefaultsInput.prototype, "paymentDays", void 0);
82
+ exports.DocumentDefaultsInput = DocumentDefaultsInput = tslib_1.__decorate([
83
+ (0, type_graphql_1.InputType)({ description: "The company's own words for new documents, whole - what is left out is emptied." })
84
+ ], DocumentDefaultsInput);
85
+ /** The attribute as this domain sees it - its own, else its closest ancestor's. */
86
+ async function storedValue(domain, manager) {
87
+ const ids = await (0, shell_1.getDomainIdsWithAncestors)(domain);
88
+ const all = await manager.getRepository(shell_1.EnvVar).find({ where: { domain: { id: (0, typeorm_1.In)(ids) }, name: document_defaults_rules_1.DOCUMENT_DEFAULTS_ATTRIBUTE, active: true } });
89
+ return (0, shell_1.dedupByClosestDomain)(all, ids, one => one.name)[0]?.value;
90
+ }
91
+ /**
92
+ * The company's words for new quotations and invoices (ADR-0170). Read by whoever writes either document
93
+ * (`invoice-published`); changed by whoever keeps the invoices (`invoice:mutation`), on the Settings screen.
94
+ */
95
+ let DocumentDefaultsResolver = class DocumentDefaultsResolver {
96
+ async documentDefaults(context) {
97
+ const { domain, tx } = context.state;
98
+ return (0, document_defaults_rules_1.storedDocumentDefaults)(await storedValue(domain, tx ?? (0, shell_1.getDataSource)().manager));
99
+ }
100
+ async updateDocumentDefaults(defaults, context) {
101
+ const { domain, tx } = context.state;
102
+ const kept = (0, document_defaults_rules_1.documentDefaultsOf)(defaults);
103
+ const repository = tx.getRepository(shell_1.EnvVar);
104
+ const own = await repository.findOne({ where: { domain: { id: domain.id }, name: document_defaults_rules_1.DOCUMENT_DEFAULTS_ATTRIBUTE } });
105
+ const value = JSON.stringify(kept);
106
+ if (own)
107
+ await repository.save({ ...own, value, active: true });
108
+ else
109
+ await repository.save({ domain, name: document_defaults_rules_1.DOCUMENT_DEFAULTS_ATTRIBUTE, value, active: true, description: 'Quotation and invoice defaults (ADR-0170) - set on the Settings screen' });
110
+ return kept;
111
+ }
112
+ };
113
+ exports.DocumentDefaultsResolver = DocumentDefaultsResolver;
114
+ tslib_1.__decorate([
115
+ (0, type_graphql_1.Directive)('@privilege(category: "invoice-published", privilege: "query", domainOwnerGranted: true)'),
116
+ (0, type_graphql_1.Query)(returns => DocumentDefaults, { description: "The company's own words every new quotation and invoice starts with." }),
117
+ tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
118
+ tslib_1.__metadata("design:type", Function),
119
+ tslib_1.__metadata("design:paramtypes", [Object]),
120
+ tslib_1.__metadata("design:returntype", Promise)
121
+ ], DocumentDefaultsResolver.prototype, "documentDefaults", null);
122
+ tslib_1.__decorate([
123
+ (0, type_graphql_1.Directive)('@transaction'),
124
+ (0, type_graphql_1.Directive)('@privilege(category: "invoice", privilege: "mutation", domainOwnerGranted: true)'),
125
+ (0, type_graphql_1.Mutation)(returns => DocumentDefaults, { description: "To set the company's own words for new quotations and invoices, whole." }),
126
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('defaults', type => DocumentDefaultsInput)),
127
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
128
+ tslib_1.__metadata("design:type", Function),
129
+ tslib_1.__metadata("design:paramtypes", [DocumentDefaultsInput, Object]),
130
+ tslib_1.__metadata("design:returntype", Promise)
131
+ ], DocumentDefaultsResolver.prototype, "updateDocumentDefaults", null);
132
+ exports.DocumentDefaultsResolver = DocumentDefaultsResolver = tslib_1.__decorate([
133
+ (0, type_graphql_1.Resolver)(),
134
+ (0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
135
+ ], DocumentDefaultsResolver);
136
+ //# sourceMappingURL=document-defaults-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-defaults-resolver.js","sourceRoot":"","sources":["../../../server/service/document-defaults/document-defaults-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAA+H;AAC/H,qCAA4B;AAE5B,iDAA6H;AAE7H,uEAAmH;AAG5G,IAAM,gBAAgB,GAAtB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AI,CAAA;IACb,CAAC;CACF,CAAA;AArBY,4DAAwB;AAG7B;IAFL,IAAA,wBAAS,EAAC,yFAAyF,CAAC;IACpG,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,EAAE,WAAW,EAAE,sEAAsE,EAAE,CAAC;IACpG,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAG5B;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,kFAAkF,CAAC;IAC7F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,EAAE,WAAW,EAAE,wEAAwE,EAAE,CAAC;IACnG,mBAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAA;IAAmC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAA7B,qBAAqB;;sEAS3G;mCApBU,wBAAwB;IAFpC,IAAA,uBAAQ,GAAE;IACV,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,wBAAwB,CAqBpC","sourcesContent":["import { Arg, Ctx, Directive, Field, InputType, Int, Mutation, ObjectType, Query, Resolver, UseMiddleware } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { dedupByClosestDomain, EnvVar, getDataSource, getDomainIdsWithAncestors, SpeakRefusals } from '@things-factory/shell'\n\nimport { DOCUMENT_DEFAULTS_ATTRIBUTE, documentDefaultsOf, storedDocumentDefaults } from './document-defaults-rules'\n\n@ObjectType({ description: \"The company's own words every new quotation and invoice starts with (ADR-0170).\" })\nexport class DocumentDefaults {\n @Field({ description: 'Our name as a supplier.' }) supplierName: string\n @Field({ description: 'Our business registration number.' }) supplierRegistrationNumber: string\n @Field({ description: 'Our address.' }) supplierAddress: string\n @Field({ description: 'The account to pay into, as printed.' }) bankDetails: string\n @Field(type => [String], { description: 'The payment terms the company offers - the first is a new document\\'s, the others a click away.' }) paymentTerms: string[]\n @Field({ description: 'A note every new document carries.' }) notes: string\n @Field(type => Int, { description: 'Days a quotation holds after its issue day.' }) validDays: number\n @Field(type => Int, { description: 'Days an invoice is due after its issue day.' }) paymentDays: number\n}\n\n@InputType({ description: \"The company's own words for new documents, whole - what is left out is emptied.\" })\nexport class DocumentDefaultsInput {\n @Field({ nullable: true, description: 'Our name as a supplier.' }) supplierName?: string\n @Field({ nullable: true, description: 'Our business registration number.' }) supplierRegistrationNumber?: string\n @Field({ nullable: true, description: 'Our address.' }) supplierAddress?: string\n @Field({ nullable: true, description: 'The account to pay into, as printed.' }) bankDetails?: string\n @Field(type => [String], { nullable: true, description: 'The payment terms the company offers, in order.' }) paymentTerms?: string[]\n @Field({ nullable: true, description: 'A note every new document carries.' }) notes?: string\n @Field(type => Int, { nullable: true, description: 'Days a quotation holds after its issue day (1 to 365).' }) validDays?: number\n @Field(type => Int, { nullable: true, description: 'Days an invoice is due after its issue day (0 to 365).' }) paymentDays?: number\n}\n\n/** The attribute as this domain sees it - its own, else its closest ancestor's. */\nasync function storedValue(domain: any, manager: any): Promise<string | undefined> {\n const ids = await getDomainIdsWithAncestors(domain)\n const all: EnvVar[] = await manager.getRepository(EnvVar).find({ where: { domain: { id: In(ids) }, name: DOCUMENT_DEFAULTS_ATTRIBUTE, active: true } })\n return dedupByClosestDomain(all, ids, one => one.name)[0]?.value\n}\n\n/**\n * The company's words for new quotations and invoices (ADR-0170). Read by whoever writes either document\n * (`invoice-published`); changed by whoever keeps the invoices (`invoice:mutation`), on the Settings screen.\n */\n@Resolver()\n@UseMiddleware(SpeakRefusals)\nexport class DocumentDefaultsResolver {\n @Directive('@privilege(category: \"invoice-published\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => DocumentDefaults, { description: \"The company's own words every new quotation and invoice starts with.\" })\n async documentDefaults(@Ctx() context: ResolverContext): Promise<DocumentDefaults> {\n const { domain, tx } = context.state as any\n return storedDocumentDefaults(await storedValue(domain, tx ?? getDataSource().manager))\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"invoice\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => DocumentDefaults, { description: \"To set the company's own words for new quotations and invoices, whole.\" })\n async updateDocumentDefaults(@Arg('defaults', type => DocumentDefaultsInput) defaults: DocumentDefaultsInput, @Ctx() context: ResolverContext): Promise<DocumentDefaults> {\n const { domain, tx } = context.state as any\n const kept = documentDefaultsOf(defaults)\n const repository = tx.getRepository(EnvVar)\n const own = await repository.findOne({ where: { domain: { id: domain.id }, name: DOCUMENT_DEFAULTS_ATTRIBUTE } })\n const value = JSON.stringify(kept)\n if (own) await repository.save({ ...own, value, active: true })\n else await repository.save({ domain, name: DOCUMENT_DEFAULTS_ATTRIBUTE, value, active: true, description: 'Quotation and invoice defaults (ADR-0170) - set on the Settings screen' })\n return kept\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ export interface DocumentDefaultsValue {
2
+ supplierName: string;
3
+ supplierRegistrationNumber: string;
4
+ supplierAddress: string;
5
+ bankDetails: string;
6
+ /** The payment terms the company offers, in the order they are offered - the first is a new document's. */
7
+ paymentTerms: string[];
8
+ notes: string;
9
+ /** Days a quotation holds after its issue day. */
10
+ validDays: number;
11
+ /** Days an invoice is due after its issue day - none means due on the day. */
12
+ paymentDays: number;
13
+ }
14
+ export declare const DEFAULT_VALID_DAYS = 30;
15
+ export declare const DEFAULT_PAYMENT_DAYS = 30;
16
+ export declare const MAX_PAYMENT_TERMS = 10;
17
+ /** The attribute they are kept under. */
18
+ export declare const DOCUMENT_DEFAULTS_ATTRIBUTE = "Invoice::documentDefaults";
19
+ /**
20
+ * What is kept: words trimmed, terms without blanks or repeats and at most ten, the days an offer holds a whole number
21
+ * from 1 to 365 and the days an invoice is due one from 0 to 365.
22
+ */
23
+ export declare function documentDefaultsOf(input: any): DocumentDefaultsValue;
24
+ /** The kept attribute read back - nothing kept, or something unreadable, is the empty defaults. */
25
+ export declare function storedDocumentDefaults(value: string | null | undefined): DocumentDefaultsValue;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /*
3
+ * The company's own words for every quotation and invoice it writes (ADR-0170): our side of the document, the account
4
+ * to pay into, the payment terms it offers (several - one is picked per document), a standing note, and how long an
5
+ * offer holds. Pure - the resolver keeps them as one domain attribute.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.DOCUMENT_DEFAULTS_ATTRIBUTE = exports.MAX_PAYMENT_TERMS = exports.DEFAULT_PAYMENT_DAYS = exports.DEFAULT_VALID_DAYS = void 0;
9
+ exports.documentDefaultsOf = documentDefaultsOf;
10
+ exports.storedDocumentDefaults = storedDocumentDefaults;
11
+ exports.DEFAULT_VALID_DAYS = 30;
12
+ exports.DEFAULT_PAYMENT_DAYS = 30;
13
+ exports.MAX_PAYMENT_TERMS = 10;
14
+ /** The attribute they are kept under. */
15
+ exports.DOCUMENT_DEFAULTS_ATTRIBUTE = 'Invoice::documentDefaults';
16
+ const text = (value) => (typeof value === 'string' ? value.trim() : '');
17
+ /**
18
+ * What is kept: words trimmed, terms without blanks or repeats and at most ten, the days an offer holds a whole number
19
+ * from 1 to 365 and the days an invoice is due one from 0 to 365.
20
+ */
21
+ function documentDefaultsOf(input) {
22
+ const terms = [];
23
+ for (const one of Array.isArray(input?.paymentTerms) ? input.paymentTerms : []) {
24
+ const term = text(one);
25
+ if (term && !terms.includes(term) && terms.length < exports.MAX_PAYMENT_TERMS)
26
+ terms.push(term);
27
+ }
28
+ const days = Math.round(Number(input?.validDays));
29
+ const payment = input?.paymentDays === null || input?.paymentDays === undefined || input?.paymentDays === '' ? NaN : Math.round(Number(input.paymentDays));
30
+ return {
31
+ supplierName: text(input?.supplierName),
32
+ supplierRegistrationNumber: text(input?.supplierRegistrationNumber),
33
+ supplierAddress: text(input?.supplierAddress),
34
+ bankDetails: text(input?.bankDetails),
35
+ paymentTerms: terms,
36
+ notes: text(input?.notes),
37
+ validDays: Number.isFinite(days) && days >= 1 && days <= 365 ? days : exports.DEFAULT_VALID_DAYS,
38
+ paymentDays: Number.isFinite(payment) && payment >= 0 && payment <= 365 ? payment : exports.DEFAULT_PAYMENT_DAYS
39
+ };
40
+ }
41
+ /** The kept attribute read back - nothing kept, or something unreadable, is the empty defaults. */
42
+ function storedDocumentDefaults(value) {
43
+ try {
44
+ return documentDefaultsOf(value ? JSON.parse(value) : {});
45
+ }
46
+ catch {
47
+ return documentDefaultsOf({});
48
+ }
49
+ }
50
+ //# sourceMappingURL=document-defaults-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-defaults-rules.js","sourceRoot":"","sources":["../../../server/service/document-defaults/document-defaults-rules.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA6BH,gDAkBC;AAGD,wDAMC;AAxCY,QAAA,kBAAkB,GAAG,EAAE,CAAA;AACvB,QAAA,oBAAoB,GAAG,EAAE,CAAA;AACzB,QAAA,iBAAiB,GAAG,EAAE,CAAA;AAEnC,yCAAyC;AAC5B,QAAA,2BAA2B,GAAG,2BAA2B,CAAA;AAEtE,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAEhF;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,KAAU;IAC3C,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC/E,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;QACtB,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,yBAAiB;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAA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AAkB,CAAC,EAAE,CAAC,CAAA;IAC/B,CAAC;AACH,CAAC","sourcesContent":["/*\n * The company's own words for every quotation and invoice it writes (ADR-0170): our side of the document, the account\n * to pay into, the payment terms it offers (several - one is picked per document), a standing note, and how long an\n * offer holds. Pure - the resolver keeps them as one domain attribute.\n */\n\nexport interface DocumentDefaultsValue {\n supplierName: string\n supplierRegistrationNumber: string\n supplierAddress: string\n bankDetails: string\n /** The payment terms the company offers, in the order they are offered - the first is a new document's. */\n paymentTerms: string[]\n notes: string\n /** Days a quotation holds after its issue day. */\n validDays: number\n /** Days an invoice is due after its issue day - none means due on the day. */\n paymentDays: number\n}\n\nexport const DEFAULT_VALID_DAYS = 30\nexport const DEFAULT_PAYMENT_DAYS = 30\nexport const MAX_PAYMENT_TERMS = 10\n\n/** The attribute they are kept under. */\nexport const DOCUMENT_DEFAULTS_ATTRIBUTE = 'Invoice::documentDefaults'\n\nconst text = (value: unknown) => (typeof value === 'string' ? value.trim() : '')\n\n/**\n * What is kept: words trimmed, terms without blanks or repeats and at most ten, the days an offer holds a whole number\n * from 1 to 365 and the days an invoice is due one from 0 to 365.\n */\nexport function documentDefaultsOf(input: any): DocumentDefaultsValue {\n const terms: string[] = []\n for (const one of Array.isArray(input?.paymentTerms) ? input.paymentTerms : []) {\n const term = text(one)\n if (term && !terms.includes(term) && terms.length < MAX_PAYMENT_TERMS) terms.push(term)\n }\n const days = Math.round(Number(input?.validDays))\n const payment = input?.paymentDays === null || input?.paymentDays === undefined || input?.paymentDays === '' ? NaN : Math.round(Number(input.paymentDays))\n return {\n supplierName: text(input?.supplierName),\n supplierRegistrationNumber: text(input?.supplierRegistrationNumber),\n supplierAddress: text(input?.supplierAddress),\n bankDetails: text(input?.bankDetails),\n paymentTerms: terms,\n notes: text(input?.notes),\n validDays: Number.isFinite(days) && days >= 1 && days <= 365 ? days : DEFAULT_VALID_DAYS,\n paymentDays: Number.isFinite(payment) && payment >= 0 && payment <= 365 ? payment : DEFAULT_PAYMENT_DAYS\n }\n}\n\n/** The kept attribute read back - nothing kept, or something unreadable, is the empty defaults. */\nexport function storedDocumentDefaults(value: string | null | undefined): DocumentDefaultsValue {\n try {\n return documentDefaultsOf(value ? JSON.parse(value) : {})\n } catch {\n return documentDefaultsOf({})\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { DocumentDefaultsResolver } from './document-defaults-resolver';
2
+ export * from './document-defaults-rules';
3
+ export * from './document-defaults-resolver';
4
+ export declare const entities: any[];
5
+ export declare const subscribers: any[];
6
+ export declare const resolvers: (typeof DocumentDefaultsResolver)[];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvers = exports.subscribers = exports.entities = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const document_defaults_resolver_1 = require("./document-defaults-resolver");
6
+ tslib_1.__exportStar(require("./document-defaults-rules"), exports);
7
+ tslib_1.__exportStar(require("./document-defaults-resolver"), exports);
8
+ exports.entities = [];
9
+ exports.subscribers = [];
10
+ exports.resolvers = [document_defaults_resolver_1.DocumentDefaultsResolver];
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/document-defaults/index.ts"],"names":[],"mappings":";;;;AAAA,6EAAuE;AAEvE,oEAAyC;AACzC,uEAA4C;AAE/B,QAAA,QAAQ,GAAG,EAAE,CAAA;AACb,QAAA,WAAW,GAAG,EAAE,CAAA;AAChB,QAAA,SAAS,GAAG,CAAC,qDAAwB,CAAC,CAAA","sourcesContent":["import { DocumentDefaultsResolver } from './document-defaults-resolver'\n\nexport * from './document-defaults-rules'\nexport * from './document-defaults-resolver'\n\nexport const entities = []\nexport const subscribers = []\nexport const resolvers = [DocumentDefaultsResolver]\n"]}
@@ -5,8 +5,10 @@ export * from './invoice/commercial-document';
5
5
  export * from './invoice/invoice-rules';
6
6
  export * from './invoice/invoice-service';
7
7
  export * from './invoice/invoice-files';
8
+ export * from './invoice/invoice-document-file';
8
9
  export * from './invoice/invoice-type';
9
10
  export * from './invoice/invoice-read';
11
+ export * from './document-defaults/document-defaults-rules';
10
12
  export declare const entities: any[];
11
13
  export declare const subscribers: any[];
12
14
  export declare const schema: {
@@ -9,12 +9,15 @@ tslib_1.__exportStar(require("./invoice/commercial-document"), exports);
9
9
  tslib_1.__exportStar(require("./invoice/invoice-rules"), exports);
10
10
  tslib_1.__exportStar(require("./invoice/invoice-service"), exports);
11
11
  tslib_1.__exportStar(require("./invoice/invoice-files"), exports);
12
+ tslib_1.__exportStar(require("./invoice/invoice-document-file"), exports);
12
13
  tslib_1.__exportStar(require("./invoice/invoice-type"), exports);
13
14
  tslib_1.__exportStar(require("./invoice/invoice-read"), exports);
15
+ tslib_1.__exportStar(require("./document-defaults/document-defaults-rules"), exports);
14
16
  const invoice = tslib_1.__importStar(require("./invoice"));
15
17
  const invoiceEvent = tslib_1.__importStar(require("./invoice-event"));
16
18
  const invoiceItem = tslib_1.__importStar(require("./invoice-item"));
17
- const modules = [invoice, invoiceItem, invoiceEvent];
19
+ const documentDefaults = tslib_1.__importStar(require("./document-defaults"));
20
+ const modules = [invoice, invoiceItem, invoiceEvent, documentDefaults];
18
21
  exports.entities = modules.flatMap(one => one.entities);
19
22
  exports.subscribers = modules.flatMap(one => one.subscribers);
20
23
  exports.schema = { resolverClasses: modules.flatMap(one => one.resolvers) };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,wEAA6C;AAC7C,sEAA2C;AAC3C,4DAAiC;AACjC,wEAA6C;AAC7C,kEAAuC;AACvC,oEAAyC;AACzC,kEAAuC;AACvC,iEAAsC;AACtC,iEAAsC;AACtC,2DAAoC;AACpC,sEAA+C;AAC/C,oEAA6C;AAC7C,MAAM,OAAO,GAAgE,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC,CAAA;AACpG,QAAA,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC/C,QAAA,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AACrD,QAAA,MAAM,GAAG,EAAE,eAAe,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAA","sourcesContent":["export * from './invoice-event/invoice-event'\nexport * from './invoice-item/invoice-item'\nexport * from './invoice/invoice'\nexport * from './invoice/commercial-document'\nexport * from './invoice/invoice-rules'\nexport * from './invoice/invoice-service'\nexport * from './invoice/invoice-files'\nexport * from './invoice/invoice-type'\nexport * from './invoice/invoice-read'\nimport * as invoice from './invoice'\nimport * as invoiceEvent from './invoice-event'\nimport * as invoiceItem from './invoice-item'\nconst modules: { entities: any[]; subscribers: any[]; resolvers: any[] }[] = [invoice, invoiceItem, invoiceEvent]\nexport const entities = modules.flatMap(one => one.entities)\nexport const subscribers = modules.flatMap(one => one.subscribers)\nexport const schema = { resolverClasses: modules.flatMap(one => one.resolvers) }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,wEAA6C;AAC7C,sEAA2C;AAC3C,4DAAiC;AACjC,wEAA6C;AAC7C,kEAAuC;AACvC,oEAAyC;AACzC,kEAAuC;AACvC,0EAA+C;AAC/C,iEAAsC;AACtC,iEAAsC;AACtC,sFAA2D;AAC3D,2DAAoC;AACpC,sEAA+C;AAC/C,oEAA6C;AAC7C,8EAAuD;AACvD,MAAM,OAAO,GAAgE,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAAA;AACtH,QAAA,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC/C,QAAA,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AACrD,QAAA,MAAM,GAAG,EAAE,eAAe,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAA","sourcesContent":["export * from './invoice-event/invoice-event'\nexport * from './invoice-item/invoice-item'\nexport * from './invoice/invoice'\nexport * from './invoice/commercial-document'\nexport * from './invoice/invoice-rules'\nexport * from './invoice/invoice-service'\nexport * from './invoice/invoice-files'\nexport * from './invoice/invoice-document-file'\nexport * from './invoice/invoice-type'\nexport * from './invoice/invoice-read'\nexport * from './document-defaults/document-defaults-rules'\nimport * as invoice from './invoice'\nimport * as invoiceEvent from './invoice-event'\nimport * as invoiceItem from './invoice-item'\nimport * as documentDefaults from './document-defaults'\nconst modules: { entities: any[]; subscribers: any[]; resolvers: any[] }[] = [invoice, invoiceItem, invoiceEvent, documentDefaults]\nexport const entities = modules.flatMap(one => one.entities)\nexport const subscribers = modules.flatMap(one => one.subscribers)\nexport const schema = { resolverClasses: modules.flatMap(one => one.resolvers) }\n"]}
@@ -20,6 +20,7 @@ export declare abstract class CommercialDocument {
20
20
  bankDetails?: string;
21
21
  notes?: string;
22
22
  sourceReference?: string;
23
+ discountAmount: number;
23
24
  supplyAmount: number;
24
25
  taxAmount: number;
25
26
  totalAmount: number;
@@ -30,6 +31,7 @@ export declare abstract class CommercialLine {
30
31
  position: number;
31
32
  description: string;
32
33
  quantity: number;
34
+ unit?: string;
33
35
  unitPrice: number;
34
36
  discount: number;
35
37
  taxKind: TaxKind;
@@ -103,7 +103,12 @@ tslib_1.__decorate([
103
103
  ], CommercialDocument.prototype, "sourceReference", void 0);
104
104
  tslib_1.__decorate([
105
105
  (0, typeorm_1.Column)({ ...amount, default: 0 }),
106
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Sum of the line supply amounts' }),
106
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Discount of the whole document, taken off the lines before tax and spread over its tax groups' }),
107
+ tslib_1.__metadata("design:type", Number)
108
+ ], CommercialDocument.prototype, "discountAmount", void 0);
109
+ tslib_1.__decorate([
110
+ (0, typeorm_1.Column)({ ...amount, default: 0 }),
111
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Sum of the line supply amounts, less the discount of the whole document' }),
107
112
  tslib_1.__metadata("design:type", Number)
108
113
  ], CommercialDocument.prototype, "supplyAmount", void 0);
109
114
  tslib_1.__decorate([
@@ -147,6 +152,11 @@ tslib_1.__decorate([
147
152
  (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Quantity' }),
148
153
  tslib_1.__metadata("design:type", Number)
149
154
  ], CommercialLine.prototype, "quantity", void 0);
155
+ tslib_1.__decorate([
156
+ (0, typeorm_1.Column)({ nullable: true }),
157
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Unit the quantity counts in, as printed - pieces, a lot, man-months' }),
158
+ tslib_1.__metadata("design:type", String)
159
+ ], CommercialLine.prototype, "unit", void 0);
150
160
  tslib_1.__decorate([
151
161
  (0, typeorm_1.Column)(amount),
152
162
  (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Price of one unit' }),