@things-factory/sales 0.0.0-stage → 10.1.176

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 (131) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/assets/images/hatiolab-logo.png +0 -0
  3. package/dist-client/bootstrap.d.ts +1 -0
  4. package/dist-client/bootstrap.js +5 -0
  5. package/dist-client/bootstrap.js.map +1 -0
  6. package/dist-client/entity360/opportunity-360.d.ts +12 -0
  7. package/dist-client/entity360/opportunity-360.js +114 -0
  8. package/dist-client/entity360/opportunity-360.js.map +1 -0
  9. package/dist-client/index.d.ts +4 -0
  10. package/dist-client/index.js +5 -0
  11. package/dist-client/index.js.map +1 -0
  12. package/dist-client/opportunity-attach.d.ts +17 -0
  13. package/dist-client/opportunity-attach.js +8 -0
  14. package/dist-client/opportunity-attach.js.map +1 -0
  15. package/dist-client/opportunity-words.d.ts +1 -0
  16. package/dist-client/opportunity-words.js +13 -0
  17. package/dist-client/opportunity-words.js.map +1 -0
  18. package/dist-client/pages/opportunity-editor.d.ts +81 -0
  19. package/dist-client/pages/opportunity-editor.js +482 -0
  20. package/dist-client/pages/opportunity-editor.js.map +1 -0
  21. package/dist-client/pages/opportunity-list.d.ts +40 -0
  22. package/dist-client/pages/opportunity-list.js +134 -0
  23. package/dist-client/pages/opportunity-list.js.map +1 -0
  24. package/dist-client/pages/quotation-editor.d.ts +44 -0
  25. package/dist-client/pages/quotation-editor.js +315 -0
  26. package/dist-client/pages/quotation-editor.js.map +1 -0
  27. package/dist-client/pages/quotation-list.d.ts +36 -0
  28. package/dist-client/pages/quotation-list.js +113 -0
  29. package/dist-client/pages/quotation-list.js.map +1 -0
  30. package/dist-client/quotation-attach.d.ts +16 -0
  31. package/dist-client/quotation-attach.js +8 -0
  32. package/dist-client/quotation-attach.js.map +1 -0
  33. package/dist-client/quotation-words.d.ts +1 -0
  34. package/dist-client/quotation-words.js +13 -0
  35. package/dist-client/quotation-words.js.map +1 -0
  36. package/dist-client/route.d.ts +1 -0
  37. package/dist-client/route.js +17 -0
  38. package/dist-client/route.js.map +1 -0
  39. package/dist-client/tsconfig.tsbuildinfo +1 -0
  40. package/dist-server/controllers/index.d.ts +0 -0
  41. package/dist-server/controllers/index.js +1 -0
  42. package/dist-server/controllers/index.js.map +1 -0
  43. package/dist-server/index.d.ts +4 -0
  44. package/dist-server/index.js +8 -0
  45. package/dist-server/index.js.map +1 -0
  46. package/dist-server/middlewares/index.d.ts +2 -0
  47. package/dist-server/middlewares/index.js +7 -0
  48. package/dist-server/middlewares/index.js.map +1 -0
  49. package/dist-server/migrations/index.d.ts +1 -0
  50. package/dist-server/migrations/index.js +12 -0
  51. package/dist-server/migrations/index.js.map +1 -0
  52. package/dist-server/routes.d.ts +0 -0
  53. package/dist-server/routes.js +24 -0
  54. package/dist-server/routes.js.map +1 -0
  55. package/dist-server/service/index.d.ts +16 -0
  56. package/dist-server/service/index.js +21 -0
  57. package/dist-server/service/index.js.map +1 -0
  58. package/dist-server/service/opportunity/index.d.ts +8 -0
  59. package/dist-server/service/opportunity/index.js +12 -0
  60. package/dist-server/service/opportunity/index.js.map +1 -0
  61. package/dist-server/service/opportunity/opportunity-event-query.d.ts +9 -0
  62. package/dist-server/service/opportunity/opportunity-event-query.js +55 -0
  63. package/dist-server/service/opportunity/opportunity-event-query.js.map +1 -0
  64. package/dist-server/service/opportunity/opportunity-event.d.ts +27 -0
  65. package/dist-server/service/opportunity/opportunity-event.js +115 -0
  66. package/dist-server/service/opportunity/opportunity-event.js.map +1 -0
  67. package/dist-server/service/opportunity/opportunity-mutation.d.ts +7 -0
  68. package/dist-server/service/opportunity/opportunity-mutation.js +64 -0
  69. package/dist-server/service/opportunity/opportunity-mutation.js.map +1 -0
  70. package/dist-server/service/opportunity/opportunity-query.d.ts +19 -0
  71. package/dist-server/service/opportunity/opportunity-query.js +144 -0
  72. package/dist-server/service/opportunity/opportunity-query.js.map +1 -0
  73. package/dist-server/service/opportunity/opportunity-rules.d.ts +22 -0
  74. package/dist-server/service/opportunity/opportunity-rules.js +59 -0
  75. package/dist-server/service/opportunity/opportunity-rules.js.map +1 -0
  76. package/dist-server/service/opportunity/opportunity-service.d.ts +19 -0
  77. package/dist-server/service/opportunity/opportunity-service.js +107 -0
  78. package/dist-server/service/opportunity/opportunity-service.js.map +1 -0
  79. package/dist-server/service/opportunity/opportunity-type.d.ts +23 -0
  80. package/dist-server/service/opportunity/opportunity-type.js +86 -0
  81. package/dist-server/service/opportunity/opportunity-type.js.map +1 -0
  82. package/dist-server/service/opportunity/opportunity.d.ts +35 -0
  83. package/dist-server/service/opportunity/opportunity.js +147 -0
  84. package/dist-server/service/opportunity/opportunity.js.map +1 -0
  85. package/dist-server/service/quotation/index.d.ts +10 -0
  86. package/dist-server/service/quotation/index.js +14 -0
  87. package/dist-server/service/quotation/index.js.map +1 -0
  88. package/dist-server/service/quotation/quotation-event-query.d.ts +9 -0
  89. package/dist-server/service/quotation/quotation-event-query.js +55 -0
  90. package/dist-server/service/quotation/quotation-event-query.js.map +1 -0
  91. package/dist-server/service/quotation/quotation-event.d.ts +22 -0
  92. package/dist-server/service/quotation/quotation-event.js +98 -0
  93. package/dist-server/service/quotation/quotation-event.js.map +1 -0
  94. package/dist-server/service/quotation/quotation-item-query.d.ts +8 -0
  95. package/dist-server/service/quotation/quotation-item-query.js +45 -0
  96. package/dist-server/service/quotation/quotation-item-query.js.map +1 -0
  97. package/dist-server/service/quotation/quotation-item.d.ts +18 -0
  98. package/dist-server/service/quotation/quotation-item.js +75 -0
  99. package/dist-server/service/quotation/quotation-item.js.map +1 -0
  100. package/dist-server/service/quotation/quotation-mutation.d.ts +11 -0
  101. package/dist-server/service/quotation/quotation-mutation.js +117 -0
  102. package/dist-server/service/quotation/quotation-mutation.js.map +1 -0
  103. package/dist-server/service/quotation/quotation-query.d.ts +17 -0
  104. package/dist-server/service/quotation/quotation-query.js +125 -0
  105. package/dist-server/service/quotation/quotation-query.js.map +1 -0
  106. package/dist-server/service/quotation/quotation-rules.d.ts +6 -0
  107. package/dist-server/service/quotation/quotation-rules.js +22 -0
  108. package/dist-server/service/quotation/quotation-rules.js.map +1 -0
  109. package/dist-server/service/quotation/quotation-service.d.ts +23 -0
  110. package/dist-server/service/quotation/quotation-service.js +115 -0
  111. package/dist-server/service/quotation/quotation-service.js.map +1 -0
  112. package/dist-server/service/quotation/quotation-type.d.ts +9 -0
  113. package/dist-server/service/quotation/quotation-type.js +32 -0
  114. package/dist-server/service/quotation/quotation-type.js.map +1 -0
  115. package/dist-server/service/quotation/quotation.d.ts +33 -0
  116. package/dist-server/service/quotation/quotation.js +109 -0
  117. package/dist-server/service/quotation/quotation.js.map +1 -0
  118. package/dist-server/service/sales-event.d.ts +15 -0
  119. package/dist-server/service/sales-event.js +12 -0
  120. package/dist-server/service/sales-event.js.map +1 -0
  121. package/dist-server/tsconfig.tsbuildinfo +1 -0
  122. package/helps/quotation/quotation.md +160 -0
  123. package/package.json +46 -4
  124. package/things-factory.config.js +13 -0
  125. package/translations/en.json +98 -0
  126. package/translations/es.json +98 -0
  127. package/translations/ja.json +98 -0
  128. package/translations/ko.json +98 -0
  129. package/translations/ms.json +98 -0
  130. package/translations/zh.json +98 -0
  131. package/README.md +0 -3
@@ -0,0 +1,134 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist/ox-grist.js';
3
+ import '@operato/data-grist/ox-filters-form.js';
4
+ import gql from 'graphql-tag';
5
+ import { html } from 'lit';
6
+ import { customElement, query, state } from 'lit/decorators.js';
7
+ import { DataGrist } from '@operato/data-grist';
8
+ import { client } from '@operato/graphql';
9
+ import { i18next, localize } from '@operato/i18n';
10
+ import { entity360Name } from '@operato/layout';
11
+ import { navigate, PageView } from '@operato/shell';
12
+ import { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles';
13
+ import { isMobileDevice } from '@operato/utils';
14
+ import { documentAmount } from '@things-factory/invoice/dist-client';
15
+ import { opportunityStageWord } from '../opportunity-words';
16
+ const STAGES = ['LEAD', 'PROPOSAL', 'QUOTED', 'NEGOTIATION', 'WON', 'LOST'];
17
+ /** 영업 기회 — every opportunity of the domain, narrowed by stage. The name opens its 360; the edit gutter its editor. */
18
+ let OpportunityList = class OpportunityList extends localize(i18next)(PageView) {
19
+ static { this.styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]; }
20
+ get context() {
21
+ return {
22
+ title: i18next.t('title.opportunity-list'),
23
+ search: {
24
+ handler: (search) => {
25
+ this.grist.searchText = search;
26
+ },
27
+ value: this.grist?.searchText || ''
28
+ },
29
+ /* Narrowing by stage stays in the headroom, and this folds it. */
30
+ filter: {
31
+ handler: () => {
32
+ this.grist.toggleHeadroom();
33
+ }
34
+ },
35
+ actions: [{ title: i18next.t('button.opportunity-new'), icon: 'add', emphasis: { raised: true }, action: () => navigate('opportunity-editor') }],
36
+ exportable: { name: i18next.t('title.opportunity-list'), data: () => this.grist.exportRecords() }
37
+ };
38
+ }
39
+ render() {
40
+ return html `<ox-grist
41
+ class="page-fill"
42
+ search-mode="term"
43
+ .mode=${isMobileDevice() ? 'CARD' : 'GRID'}
44
+ .config=${this.gristConfig}
45
+ .fetchHandler=${this.fetchHandler.bind(this)}
46
+ >
47
+ <div slot="headroom" class="header">
48
+ <div class="filters">
49
+ <ox-filters-form without-search autofocus></ox-filters-form>
50
+ </div>
51
+ </div>
52
+ </ox-grist>`;
53
+ }
54
+ async pageInitialized() {
55
+ const open = (record) => record?.id && navigate(`opportunity-editor?id=${record.id}`);
56
+ const party = (value) => (value ? entity360Name({ __typename: 'Counterparty', ...value }, value.name) : '');
57
+ const readonly = (type, name, header, width, extra = {}) => ({
58
+ type,
59
+ name,
60
+ header,
61
+ width,
62
+ sortable: true,
63
+ ...extra,
64
+ record: { editable: false, ...extra.record }
65
+ });
66
+ this.gristConfig = {
67
+ rows: { appendable: false, selectable: false },
68
+ pagination: { limit: 50, pages: [50, 100, 500] },
69
+ emptyNote: { title: i18next.t('text.opportunity-empty'), description: i18next.t('text.opportunity-empty-description') },
70
+ list: { fields: ['name', 'counterparty'], details: ['stage', 'expectedCloseMonth', 'amount'] },
71
+ columns: [
72
+ { type: 'gutter', gutterName: 'sequence' },
73
+ { type: 'gutter', gutterName: 'button', icon: 'edit_note', handlers: { click: (_c, _d, _col, record) => open(record) } },
74
+ readonly('string', 'name', i18next.t('field.opportunity-name'), 220, {
75
+ record: { renderer: (_v, _c, record) => (record?.id ? entity360Name({ __typename: 'Opportunity', ...record }, record.name) : '') }
76
+ }),
77
+ readonly('string', 'counterparty', i18next.t('field.opportunity-counterparty'), 180, { sortable: false, record: { renderer: (value) => party(value) } }),
78
+ readonly('string', 'endCustomer', i18next.t('field.opportunity-end-customer'), 160, { sortable: false, record: { renderer: (value) => party(value) } }),
79
+ readonly('string', 'stage', i18next.t('field.opportunity-stage'), 90, {
80
+ record: { renderer: (value) => opportunityStageWord(value) },
81
+ filter: { type: 'select', operator: 'eq', options: [{ display: '', value: '' }, ...STAGES.map(stage => ({ display: opportunityStageWord(stage), value: stage }))] }
82
+ }),
83
+ readonly('integer', 'probability', i18next.t('field.opportunity-probability'), 70, { record: { align: 'right', renderer: (value) => `${value ?? 0}%` } }),
84
+ readonly('float', 'amount', i18next.t('field.opportunity-amount'), 150, {
85
+ record: { align: 'right', renderer: (value, _c, record) => documentAmount(value, record?.currency || 'KRW') }
86
+ }),
87
+ readonly('string', 'expectedCloseMonth', i18next.t('field.opportunity-expected-close-month'), 100),
88
+ readonly('string', 'owner', i18next.t('field.opportunity-owner'), 110, { sortable: false, record: { renderer: (value) => value?.name ?? '' } })
89
+ ],
90
+ sorters: [{ name: 'expectedCloseMonth' }]
91
+ };
92
+ }
93
+ async fetchHandler({ page = 1, limit = 50, sortings = [], filters = [], search }) {
94
+ const response = await client.query({
95
+ query: gql `
96
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {
97
+ responses: opportunities(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {
98
+ items {
99
+ id
100
+ name
101
+ stage
102
+ probability
103
+ amount
104
+ currency
105
+ expectedCloseMonth
106
+ counterparty { id name }
107
+ endCustomer { id name }
108
+ owner { id name }
109
+ }
110
+ total
111
+ }
112
+ }
113
+ `,
114
+ variables: { filters, pagination: { page, limit }, sortings, search: search?.trim() || undefined },
115
+ fetchPolicy: 'network-only'
116
+ });
117
+ if (response.errors?.length)
118
+ throw response;
119
+ return { total: response.data.responses.total, records: response.data.responses.items };
120
+ }
121
+ };
122
+ __decorate([
123
+ state(),
124
+ __metadata("design:type", Object)
125
+ ], OpportunityList.prototype, "gristConfig", void 0);
126
+ __decorate([
127
+ query('ox-grist'),
128
+ __metadata("design:type", DataGrist)
129
+ ], OpportunityList.prototype, "grist", void 0);
130
+ OpportunityList = __decorate([
131
+ customElement('opportunity-list')
132
+ ], OpportunityList);
133
+ export { OpportunityList };
134
+ //# sourceMappingURL=opportunity-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opportunity-list.js","sourceRoot":"","sources":["../../client/pages/opportunity-list.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,wCAAwC,CAAA;AAE/C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EA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AA;AAJjC,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CA6G3B","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\n\nimport gql from 'graphql-tag'\nimport { html } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { entity360Name } from '@operato/layout'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\nimport { documentAmount } from '@things-factory/invoice/dist-client'\n\nimport { opportunityStageWord } from '../opportunity-words'\n\nconst STAGES = ['LEAD', 'PROPOSAL', 'QUOTED', 'NEGOTIATION', 'WON', 'LOST']\n\n/** 영업 기회 — every opportunity of the domain, narrowed by stage. The name opens its 360; the edit gutter its editor. */\n@customElement('opportunity-list')\nexport class OpportunityList extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]\n\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.opportunity-list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n /* Narrowing by stage stays in the headroom, and this folds it. */\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n actions: [{ title: i18next.t('button.opportunity-new'), icon: 'add', emphasis: { raised: true }, action: () => navigate('opportunity-editor') }],\n exportable: { name: i18next.t('title.opportunity-list'), data: () => this.grist.exportRecords() }\n }\n }\n\n render() {\n return html`<ox-grist\n class=\"page-fill\"\n search-mode=\"term\"\n .mode=${isMobileDevice() ? 'CARD' : 'GRID'}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form without-search autofocus></ox-filters-form>\n </div>\n </div>\n </ox-grist>`\n }\n\n async pageInitialized() {\n const open = (record: any) => record?.id && navigate(`opportunity-editor?id=${record.id}`)\n const party = (value?: { id: string; name: string }) => (value ? entity360Name({ __typename: 'Counterparty', ...value }, value.name) : '')\n const readonly = (type: string, name: string, header: string, width: number, extra: any = {}) => ({\n type,\n name,\n header,\n width,\n sortable: true,\n ...extra,\n record: { editable: false, ...extra.record }\n })\n this.gristConfig = {\n rows: { appendable: false, selectable: false },\n pagination: { limit: 50, pages: [50, 100, 500] },\n emptyNote: { title: i18next.t('text.opportunity-empty'), description: i18next.t('text.opportunity-empty-description') },\n list: { fields: ['name', 'counterparty'], details: ['stage', 'expectedCloseMonth', 'amount'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'button', icon: 'edit_note', handlers: { click: (_c: any, _d: any, _col: any, record: any) => open(record) } },\n readonly('string', 'name', i18next.t('field.opportunity-name'), 220, {\n record: { renderer: (_v: any, _c: any, record: any) => (record?.id ? entity360Name({ __typename: 'Opportunity', ...record }, record.name) : '') }\n }),\n readonly('string', 'counterparty', i18next.t('field.opportunity-counterparty'), 180, { sortable: false, record: { renderer: (value: any) => party(value) } }),\n readonly('string', 'endCustomer', i18next.t('field.opportunity-end-customer'), 160, { sortable: false, record: { renderer: (value: any) => party(value) } }),\n readonly('string', 'stage', i18next.t('field.opportunity-stage'), 90, {\n record: { renderer: (value: string) => opportunityStageWord(value) },\n filter: { type: 'select', operator: 'eq', options: [{ display: '', value: '' }, ...STAGES.map(stage => ({ display: opportunityStageWord(stage), value: stage }))] }\n }),\n readonly('integer', 'probability', i18next.t('field.opportunity-probability'), 70, { record: { align: 'right', renderer: (value: number) => `${value ?? 0}%` } }),\n readonly('float', 'amount', i18next.t('field.opportunity-amount'), 150, {\n record: { align: 'right', renderer: (value: number, _c: any, record: any) => documentAmount(value, record?.currency || 'KRW') }\n }),\n readonly('string', 'expectedCloseMonth', i18next.t('field.opportunity-expected-close-month'), 100),\n readonly('string', 'owner', i18next.t('field.opportunity-owner'), 110, { sortable: false, record: { renderer: (value: any) => value?.name ?? '' } })\n ],\n sorters: [{ name: 'expectedCloseMonth' }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 50, sortings = [], filters = [], search }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: opportunities(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items {\n id\n name\n stage\n probability\n amount\n currency\n expectedCloseMonth\n counterparty { id name }\n endCustomer { id name }\n owner { id name }\n }\n total\n }\n }\n `,\n variables: { filters, pagination: { page, limit }, sortings, search: search?.trim() || undefined },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return { total: response.data.responses.total, records: response.data.responses.items }\n }\n}\n"]}
@@ -0,0 +1,44 @@
1
+ import '@operato/data-grist/ox-grist.js';
2
+ import '@operato/list-state/ox-page-state.js';
3
+ import { PageView } from '@operato/shell';
4
+ import { type DocumentValue } from '@things-factory/invoice/dist-client';
5
+ declare const QuotationEditor_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
6
+ /**
7
+ * 견적 편집 — the same head, lines and totals as an invoice, valid until a day.
8
+ *
9
+ * A draft is saved and sent; once sent its amounts are fixed, and the buyer's answer is recorded — accepted, or
10
+ * declined with a reason. To change a sent quotation, revise it: the next version keeps the number.
11
+ */
12
+ export declare class QuotationEditor extends QuotationEditor_base {
13
+ static styles: import("lit").CSSResult[];
14
+ quotation: DocumentValue | null;
15
+ form: DocumentValue;
16
+ loading: boolean;
17
+ error: unknown;
18
+ busy: boolean;
19
+ reason: string;
20
+ gristConfig: any;
21
+ private grist?;
22
+ get editable(): boolean;
23
+ get context(): {
24
+ frame: string;
25
+ menu: string;
26
+ actions: any[];
27
+ description?: string | undefined;
28
+ title: string;
29
+ };
30
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
31
+ render(): import("lit-html").TemplateResult<1>;
32
+ private renderDecline;
33
+ private configure;
34
+ private load;
35
+ private show;
36
+ private run;
37
+ private input;
38
+ private save;
39
+ /** Save what is on screen, then send it — its amounts are fixed from here on. */
40
+ private send;
41
+ private change;
42
+ private print;
43
+ }
44
+ export {};
@@ -0,0 +1,315 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist/ox-grist.js';
3
+ import '@operato/list-state/ox-page-state.js';
4
+ import gql from 'graphql-tag';
5
+ import { css, html, nothing } from 'lit';
6
+ import { customElement, query, state } from 'lit/decorators.js';
7
+ import { DataGrist } from '@operato/data-grist';
8
+ import { client } from '@operato/graphql';
9
+ import { i18next, localize } from '@operato/i18n';
10
+ import { notify } from '@operato/layout';
11
+ import { navigate, PageView } from '@operato/shell';
12
+ import { ButtonStyles, CommonGristStyles, DocumentPageStyles, FormFieldStyles, ScrollbarStyles } from '@operato/styles';
13
+ import { documentHtml, DocumentFormStyles, documentLinesConfig, linesOf, printDocument, renderDocumentHead, renderDocumentTotals } from '@things-factory/invoice/dist-client';
14
+ import { quotationSection } from '../quotation-attach';
15
+ import { quotationStatusWord } from '../quotation-words';
16
+ const FIELDS = `
17
+ id number version status validUntil outcomeReason direction currency language supplierName supplierAddress supplierRegistrationNumber
18
+ buyerName buyerAddress buyerRegistrationNumber issueDate purchaseOrder paymentTerms bankDetails notes sourceReference
19
+ supplyAmount taxAmount totalAmount taxRounding currencyDigits
20
+ items { position description quantity unitPrice discount taxKind taxRate supplyAmount }
21
+ taxGroups { taxKind taxRate supplyAmount taxAmount }
22
+ `;
23
+ const HEAD = [
24
+ 'number',
25
+ 'direction',
26
+ 'currency',
27
+ 'language',
28
+ 'supplierName',
29
+ 'supplierAddress',
30
+ 'supplierRegistrationNumber',
31
+ 'buyerName',
32
+ 'buyerAddress',
33
+ 'buyerRegistrationNumber',
34
+ 'issueDate',
35
+ 'purchaseOrder',
36
+ 'paymentTerms',
37
+ 'bankDetails',
38
+ 'notes',
39
+ 'sourceReference',
40
+ 'validUntil'
41
+ ];
42
+ const today = () => new Date().toLocaleDateString('en-CA');
43
+ /**
44
+ * 견적 편집 — the same head, lines and totals as an invoice, valid until a day.
45
+ *
46
+ * A draft is saved and sent; once sent its amounts are fixed, and the buyer's answer is recorded — accepted, or
47
+ * declined with a reason. To change a sent quotation, revise it: the next version keeps the number.
48
+ */
49
+ let QuotationEditor = class QuotationEditor extends localize(i18next)(PageView) {
50
+ constructor() {
51
+ super(...arguments);
52
+ this.quotation = null;
53
+ this.form = blank();
54
+ this.loading = false;
55
+ this.error = null;
56
+ this.busy = false;
57
+ this.reason = '';
58
+ }
59
+ static { this.styles = [
60
+ FormFieldStyles,
61
+ ButtonStyles,
62
+ DocumentPageStyles,
63
+ CommonGristStyles,
64
+ ScrollbarStyles,
65
+ DocumentFormStyles,
66
+ css `
67
+ ox-grist {
68
+ height: calc(var(--form-element-height-medium) * 10);
69
+ }
70
+ `
71
+ ]; }
72
+ get editable() {
73
+ return !this.quotation || this.quotation.status === 'DRAFT';
74
+ }
75
+ get context() {
76
+ const status = this.quotation?.status;
77
+ const actions = [];
78
+ if (this.editable) {
79
+ actions.push({ title: i18next.t('button.save'), icon: 'save', action: () => this.save() });
80
+ actions.push({ title: i18next.t('button.quotation-send'), icon: 'send', emphasis: { raised: true }, action: () => this.send() });
81
+ }
82
+ if (status === 'SENT') {
83
+ if (this.quotation.validUntil < today())
84
+ actions.push({ title: i18next.t('button.quotation-expire'), action: () => this.change('expireQuotation') });
85
+ else
86
+ actions.push({ title: i18next.t('button.quotation-accept'), emphasis: { raised: true }, action: () => this.change('acceptQuotation') });
87
+ }
88
+ if (['SENT', 'REJECTED', 'EXPIRED'].includes(status))
89
+ actions.push({ title: i18next.t('button.quotation-revise'), icon: 'edit_document', action: () => this.change('reviseQuotation') });
90
+ if (this.quotation)
91
+ actions.push({ title: i18next.t('button.quotation-print'), icon: 'print', action: () => this.print() });
92
+ return {
93
+ title: this.quotation ? `${i18next.t('title.quotation')} ${this.quotation.number} · v${this.quotation.version}` : i18next.t('title.quotation-new'),
94
+ ...(this.quotation ? { description: quotationStatusWord(status) } : {}),
95
+ frame: 'document',
96
+ /* Opened from the quotation list; the menu marks it. */
97
+ menu: 'quotation-list',
98
+ actions: this.error ? [] : actions
99
+ };
100
+ }
101
+ async pageUpdated(changes, lifecycle) {
102
+ if (!this.active || !(changes.active || changes.params))
103
+ return;
104
+ const id = lifecycle?.params?.id;
105
+ if (!id) {
106
+ this.quotation = null;
107
+ this.form = blank();
108
+ this.configure();
109
+ this.updateContext();
110
+ return;
111
+ }
112
+ if (id !== this.quotation?.id)
113
+ await this.load(id);
114
+ }
115
+ render() {
116
+ const attached = this.quotation ? quotationSection() : undefined;
117
+ const editable = this.editable && !this.busy;
118
+ return html `<ox-page-state .loading=${this.loading} .error=${this.error} @retry=${() => this.quotation && this.load(this.quotation.id)}>
119
+ <div class="page">
120
+ <section class="page-section">
121
+ <header class="page-section-header"><h3>${i18next.t('text.quotation-section-head')}</h3></header>
122
+ ${renderDocumentHead(this.form, editable, patch => (this.form = { ...this.form, ...patch }), html `<label
123
+ >${i18next.t('field.quotation-valid-until')}
124
+ <input type="date" .value=${this.form.validUntil ?? ''} ?disabled=${!editable} @input=${(e) => (this.form = { ...this.form, validUntil: e.target.value })}
125
+ /></label>`)}
126
+ </section>
127
+ <section class="page-section">
128
+ <header class="page-section-header"><h3>${i18next.t('text.quotation-section-lines')}</h3></header>
129
+ <ox-grist mode="GRID" .config=${this.gristConfig} .fetchHandler=${() => ({ total: this.form.items.length, records: this.form.items })}></ox-grist>
130
+ </section>
131
+ ${this.quotation
132
+ ? html `<section class="page-section">
133
+ <header class="page-section-header"><h3>${i18next.t('text.quotation-section-totals')}</h3></header>
134
+ ${renderDocumentTotals(this.quotation)}
135
+ </section>`
136
+ : nothing}
137
+ ${this.quotation?.status === 'SENT' ? this.renderDecline() : nothing}
138
+ ${this.quotation?.outcomeReason
139
+ ? html `<section class="page-section">
140
+ <header class="page-section-header"><h3>${i18next.t('field.quotation-outcome-reason')}</h3></header>
141
+ <p>${this.quotation.outcomeReason}</p>
142
+ </section>`
143
+ : nothing}
144
+ ${attached && this.quotation
145
+ ? html `<section class="page-section">
146
+ <header class="page-section-header"><h3>${attached.heading()}</h3></header>
147
+ ${attached.render(this.quotation)}
148
+ </section>`
149
+ : nothing}
150
+ </div>
151
+ </ox-page-state>`;
152
+ }
153
+ renderDecline() {
154
+ return html `<section class="page-section">
155
+ <header class="page-section-header">
156
+ <h3>${i18next.t('text.quotation-section-decline')}</h3>
157
+ <div class="page-section-actions">
158
+ <button ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.change('rejectQuotation', this.reason.trim())}>${i18next.t('button.quotation-reject')}</button>
159
+ </div>
160
+ </header>
161
+ <div class="form">
162
+ <label class="wide"
163
+ >${i18next.t('field.quotation-outcome-reason')}
164
+ <input .value=${this.reason} ?disabled=${this.busy} @input=${(e) => (this.reason = e.target.value)}
165
+ /></label>
166
+ </div>
167
+ </section>`;
168
+ }
169
+ configure() {
170
+ this.gristConfig = documentLinesConfig({ editable: this.editable, currency: this.form.currency || 'KRW' });
171
+ }
172
+ async load(id) {
173
+ this.loading = true;
174
+ this.error = null;
175
+ try {
176
+ const response = await client.query({ query: gql(`query ($id: String!) { quotation(id: $id) { ${FIELDS} } }`), variables: { id }, fetchPolicy: 'no-cache' });
177
+ if (response.errors?.length)
178
+ throw response;
179
+ if (!response.data.quotation)
180
+ throw new Error(i18next.t('text.quotation-not-found'));
181
+ this.show(response.data.quotation);
182
+ }
183
+ catch (error) {
184
+ this.error = error;
185
+ }
186
+ finally {
187
+ this.loading = false;
188
+ this.updateContext();
189
+ }
190
+ }
191
+ show(quotation) {
192
+ this.quotation = quotation;
193
+ this.form = { ...quotation, items: quotation.items.map((item) => ({ ...item })) };
194
+ this.reason = '';
195
+ this.configure();
196
+ this.grist?.fetch();
197
+ }
198
+ async run(work) {
199
+ if (this.busy)
200
+ return undefined;
201
+ this.busy = true;
202
+ try {
203
+ return await work();
204
+ }
205
+ catch (error) {
206
+ notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error) });
207
+ return undefined;
208
+ }
209
+ finally {
210
+ this.busy = false;
211
+ }
212
+ }
213
+ input() {
214
+ const input = Object.fromEntries(HEAD.map(key => [key, this.form[key] === '' ? null : this.form[key] ?? null]));
215
+ input.items = linesOf(this.grist).map(({ receivedTaxAmount, ...line }) => line);
216
+ return input;
217
+ }
218
+ async save() {
219
+ const id = this.quotation?.id;
220
+ const saved = await this.run(async () => {
221
+ const response = await client.mutate({
222
+ mutation: gql(id
223
+ ? `mutation ($id: String!, $quotation: NewQuotation!) { quotation: updateQuotation(id: $id, quotation: $quotation) { ${FIELDS} } }`
224
+ : `mutation ($quotation: NewQuotation!) { quotation: createQuotation(quotation: $quotation) { ${FIELDS} } }`),
225
+ variables: { ...(id ? { id } : {}), quotation: this.input() }
226
+ });
227
+ if (response.errors?.length)
228
+ throw response;
229
+ return response.data.quotation;
230
+ });
231
+ if (!saved)
232
+ return undefined;
233
+ this.show(saved);
234
+ this.updateContext();
235
+ if (!id)
236
+ navigate(`quotation-editor?id=${saved.id}`);
237
+ return saved;
238
+ }
239
+ /** Save what is on screen, then send it — its amounts are fixed from here on. */
240
+ async send() {
241
+ const saved = await this.save();
242
+ if (saved)
243
+ await this.change('sendQuotation');
244
+ }
245
+ async change(mutation, reason) {
246
+ const changed = await this.run(async () => {
247
+ const response = await client.mutate({
248
+ mutation: gql(reason === undefined
249
+ ? `mutation ($id: String!) { quotation: ${mutation}(id: $id) { ${FIELDS} } }`
250
+ : `mutation ($id: String!, $reason: String!) { quotation: ${mutation}(id: $id, reason: $reason) { ${FIELDS} } }`),
251
+ variables: { id: this.quotation.id, ...(reason === undefined ? {} : { reason }) }
252
+ });
253
+ if (response.errors?.length)
254
+ throw response;
255
+ return response.data.quotation;
256
+ });
257
+ if (!changed)
258
+ return;
259
+ if (changed.id !== this.quotation?.id)
260
+ navigate(`quotation-editor?id=${changed.id}`);
261
+ this.show(changed);
262
+ this.updateContext();
263
+ }
264
+ print() {
265
+ const quotation = this.quotation;
266
+ const lng = quotation.language === 'en' ? 'en' : 'ko';
267
+ printDocument(documentHtml(quotation, {
268
+ title: i18next.t('title.quotation-print', { lng }),
269
+ terms: [
270
+ { label: i18next.t('field.quotation-version', { lng }), value: `v${quotation.version}` },
271
+ { label: i18next.t('field.quotation-valid-until', { lng }), value: quotation.validUntil }
272
+ ]
273
+ }));
274
+ }
275
+ };
276
+ __decorate([
277
+ state(),
278
+ __metadata("design:type", Object)
279
+ ], QuotationEditor.prototype, "quotation", void 0);
280
+ __decorate([
281
+ state(),
282
+ __metadata("design:type", Object)
283
+ ], QuotationEditor.prototype, "form", void 0);
284
+ __decorate([
285
+ state(),
286
+ __metadata("design:type", Object)
287
+ ], QuotationEditor.prototype, "loading", void 0);
288
+ __decorate([
289
+ state(),
290
+ __metadata("design:type", Object)
291
+ ], QuotationEditor.prototype, "error", void 0);
292
+ __decorate([
293
+ state(),
294
+ __metadata("design:type", Object)
295
+ ], QuotationEditor.prototype, "busy", void 0);
296
+ __decorate([
297
+ state(),
298
+ __metadata("design:type", Object)
299
+ ], QuotationEditor.prototype, "reason", void 0);
300
+ __decorate([
301
+ state(),
302
+ __metadata("design:type", Object)
303
+ ], QuotationEditor.prototype, "gristConfig", void 0);
304
+ __decorate([
305
+ query('ox-grist'),
306
+ __metadata("design:type", DataGrist)
307
+ ], QuotationEditor.prototype, "grist", void 0);
308
+ QuotationEditor = __decorate([
309
+ customElement('quotation-editor')
310
+ ], QuotationEditor);
311
+ export { QuotationEditor };
312
+ function blank() {
313
+ return { number: '', direction: 'SALES', currency: 'KRW', language: 'ko', supplierName: '', buyerName: '', issueDate: today(), validUntil: '', items: [] };
314
+ }
315
+ //# sourceMappingURL=quotation-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quotation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oDAAiB;AAEE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AAvBjC,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAwO3B;;AAED,SAAS,KAAK;IACZ,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AAC5J,CAAC","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/list-state/ox-page-state.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { navigate, PageView } from '@operato/shell'\nimport { ButtonStyles, CommonGristStyles, DocumentPageStyles, FormFieldStyles, ScrollbarStyles } from '@operato/styles'\nimport {\n documentHtml,\n DocumentFormStyles,\n documentLinesConfig,\n linesOf,\n printDocument,\n renderDocumentHead,\n renderDocumentTotals,\n type DocumentValue\n} from '@things-factory/invoice/dist-client'\n\nimport { quotationSection } from '../quotation-attach'\nimport { quotationStatusWord } from '../quotation-words'\n\nconst FIELDS = `\n id number version status validUntil outcomeReason direction currency language supplierName supplierAddress supplierRegistrationNumber\n buyerName buyerAddress buyerRegistrationNumber issueDate purchaseOrder paymentTerms bankDetails notes sourceReference\n supplyAmount taxAmount totalAmount taxRounding currencyDigits\n items { position description quantity unitPrice discount taxKind taxRate supplyAmount }\n taxGroups { taxKind taxRate supplyAmount taxAmount }\n`\n\nconst HEAD = [\n 'number',\n 'direction',\n 'currency',\n 'language',\n 'supplierName',\n 'supplierAddress',\n 'supplierRegistrationNumber',\n 'buyerName',\n 'buyerAddress',\n 'buyerRegistrationNumber',\n 'issueDate',\n 'purchaseOrder',\n 'paymentTerms',\n 'bankDetails',\n 'notes',\n 'sourceReference',\n 'validUntil'\n]\n\nconst today = () => new Date().toLocaleDateString('en-CA')\n\n/**\n * 견적 편집 — the same head, lines and totals as an invoice, valid until a day.\n *\n * A draft is saved and sent; once sent its amounts are fixed, and the buyer's answer is recorded — accepted, or\n * declined with a reason. To change a sent quotation, revise it: the next version keeps the number.\n */\n@customElement('quotation-editor')\nexport class QuotationEditor extends localize(i18next)(PageView) {\n static styles = [\n FormFieldStyles,\n ButtonStyles,\n DocumentPageStyles,\n CommonGristStyles,\n ScrollbarStyles,\n DocumentFormStyles,\n css`\n ox-grist {\n height: calc(var(--form-element-height-medium) * 10);\n }\n `\n ]\n\n @state() quotation: DocumentValue | null = null\n @state() form: DocumentValue = blank()\n @state() loading = false\n @state() error: unknown = null\n @state() busy = false\n @state() reason = ''\n @state() gristConfig: any\n\n @query('ox-grist') private grist?: DataGrist\n\n get editable() {\n return !this.quotation || this.quotation.status === 'DRAFT'\n }\n\n get context() {\n const status = this.quotation?.status\n const actions: any[] = []\n if (this.editable) {\n actions.push({ title: i18next.t('button.save'), icon: 'save', action: () => this.save() })\n actions.push({ title: i18next.t('button.quotation-send'), icon: 'send', emphasis: { raised: true }, action: () => this.send() })\n }\n if (status === 'SENT') {\n if (this.quotation!.validUntil < today()) actions.push({ title: i18next.t('button.quotation-expire'), action: () => this.change('expireQuotation') })\n else actions.push({ title: i18next.t('button.quotation-accept'), emphasis: { raised: true }, action: () => this.change('acceptQuotation') })\n }\n if (['SENT', 'REJECTED', 'EXPIRED'].includes(status)) actions.push({ title: i18next.t('button.quotation-revise'), icon: 'edit_document', action: () => this.change('reviseQuotation') })\n if (this.quotation) actions.push({ title: i18next.t('button.quotation-print'), icon: 'print', action: () => this.print() })\n return {\n title: this.quotation ? `${i18next.t('title.quotation')} ${this.quotation.number} · v${this.quotation.version}` : i18next.t('title.quotation-new'),\n ...(this.quotation ? { description: quotationStatusWord(status) } : {}),\n frame: 'document',\n /* Opened from the quotation list; the menu marks it. */\n menu: 'quotation-list',\n actions: this.error ? [] : actions\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n const id = lifecycle?.params?.id\n if (!id) {\n this.quotation = null\n this.form = blank()\n this.configure()\n this.updateContext()\n return\n }\n if (id !== this.quotation?.id) await this.load(id)\n }\n\n render() {\n const attached = this.quotation ? quotationSection() : undefined\n const editable = this.editable && !this.busy\n return html`<ox-page-state .loading=${this.loading} .error=${this.error} @retry=${() => this.quotation && this.load(this.quotation.id)}>\n <div class=\"page\">\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.quotation-section-head')}</h3></header>\n ${renderDocumentHead(\n this.form,\n editable,\n patch => (this.form = { ...this.form, ...patch }),\n html`<label\n >${i18next.t('field.quotation-valid-until')}\n <input type=\"date\" .value=${this.form.validUntil ?? ''} ?disabled=${!editable} @input=${(e: any) => (this.form = { ...this.form, validUntil: e.target.value })}\n /></label>`\n )}\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.quotation-section-lines')}</h3></header>\n <ox-grist mode=\"GRID\" .config=${this.gristConfig} .fetchHandler=${() => ({ total: this.form.items.length, records: this.form.items })}></ox-grist>\n </section>\n ${this.quotation\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.quotation-section-totals')}</h3></header>\n ${renderDocumentTotals(this.quotation)}\n </section>`\n : nothing}\n ${this.quotation?.status === 'SENT' ? this.renderDecline() : nothing}\n ${this.quotation?.outcomeReason\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('field.quotation-outcome-reason')}</h3></header>\n <p>${this.quotation.outcomeReason}</p>\n </section>`\n : nothing}\n ${attached && this.quotation\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${attached.heading()}</h3></header>\n ${attached.render(this.quotation as any)}\n </section>`\n : nothing}\n </div>\n </ox-page-state>`\n }\n\n private renderDecline() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.quotation-section-decline')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.change('rejectQuotation', this.reason.trim())}>${i18next.t('button.quotation-reject')}</button>\n </div>\n </header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.quotation-outcome-reason')}\n <input .value=${this.reason} ?disabled=${this.busy} @input=${(e: any) => (this.reason = e.target.value)}\n /></label>\n </div>\n </section>`\n }\n\n private configure() {\n this.gristConfig = documentLinesConfig({ editable: this.editable, currency: this.form.currency || 'KRW' })\n }\n\n private async load(id: string) {\n this.loading = true\n this.error = null\n try {\n const response = await client.query({ query: gql(`query ($id: String!) { quotation(id: $id) { ${FIELDS} } }`), variables: { id }, fetchPolicy: 'no-cache' })\n if (response.errors?.length) throw response\n if (!response.data.quotation) throw new Error(i18next.t('text.quotation-not-found'))\n this.show(response.data.quotation)\n } catch (error) {\n this.error = error\n } finally {\n this.loading = false\n this.updateContext()\n }\n }\n\n private show(quotation: DocumentValue) {\n this.quotation = quotation\n this.form = { ...quotation, items: quotation.items.map((item: any) => ({ ...item })) }\n this.reason = ''\n this.configure()\n this.grist?.fetch()\n }\n\n private async run<T>(work: () => Promise<T>): Promise<T | undefined> {\n if (this.busy) return undefined\n this.busy = true\n try {\n return await work()\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error) })\n return undefined\n } finally {\n this.busy = false\n }\n }\n\n private input() {\n const input: DocumentValue = Object.fromEntries(HEAD.map(key => [key, this.form[key] === '' ? null : this.form[key] ?? null]))\n input.items = linesOf(this.grist).map(({ receivedTaxAmount, ...line }: any) => line)\n return input\n }\n\n private async save(): Promise<DocumentValue | undefined> {\n const id = this.quotation?.id\n const saved = await this.run(async () => {\n const response = await client.mutate({\n mutation: gql(\n id\n ? `mutation ($id: String!, $quotation: NewQuotation!) { quotation: updateQuotation(id: $id, quotation: $quotation) { ${FIELDS} } }`\n : `mutation ($quotation: NewQuotation!) { quotation: createQuotation(quotation: $quotation) { ${FIELDS} } }`\n ),\n variables: { ...(id ? { id } : {}), quotation: this.input() }\n })\n if (response.errors?.length) throw response\n return response.data.quotation as DocumentValue\n })\n if (!saved) return undefined\n this.show(saved)\n this.updateContext()\n if (!id) navigate(`quotation-editor?id=${saved.id}`)\n return saved\n }\n\n /** Save what is on screen, then send it — its amounts are fixed from here on. */\n private async send() {\n const saved = await this.save()\n if (saved) await this.change('sendQuotation')\n }\n\n private async change(mutation: string, reason?: string) {\n const changed = await this.run(async () => {\n const response = await client.mutate({\n mutation: gql(\n reason === undefined\n ? `mutation ($id: String!) { quotation: ${mutation}(id: $id) { ${FIELDS} } }`\n : `mutation ($id: String!, $reason: String!) { quotation: ${mutation}(id: $id, reason: $reason) { ${FIELDS} } }`\n ),\n variables: { id: this.quotation!.id, ...(reason === undefined ? {} : { reason }) }\n })\n if (response.errors?.length) throw response\n return response.data.quotation as DocumentValue\n })\n if (!changed) return\n if (changed.id !== this.quotation?.id) navigate(`quotation-editor?id=${changed.id}`)\n this.show(changed)\n this.updateContext()\n }\n\n private print() {\n const quotation = this.quotation!\n const lng = quotation.language === 'en' ? 'en' : 'ko'\n printDocument(\n documentHtml(quotation, {\n title: i18next.t('title.quotation-print', { lng }),\n terms: [\n { label: i18next.t('field.quotation-version', { lng }), value: `v${quotation.version}` },\n { label: i18next.t('field.quotation-valid-until', { lng }), value: quotation.validUntil }\n ]\n })\n )\n }\n}\n\nfunction blank(): DocumentValue {\n return { number: '', direction: 'SALES', currency: 'KRW', language: 'ko', supplierName: '', buyerName: '', issueDate: today(), validUntil: '', items: [] }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import '@operato/data-grist/ox-grist.js';
2
+ import { FetchOption } from '@operato/data-grist';
3
+ import { PageView } from '@operato/shell';
4
+ declare const QuotationList_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
5
+ /** 견적 — every version of every quotation; the latest of a number is the one still in play. */
6
+ export declare class QuotationList extends QuotationList_base {
7
+ static styles: import("lit").CSSResult[];
8
+ gristConfig: any;
9
+ private grist;
10
+ get context(): {
11
+ title: string;
12
+ search: {
13
+ handler: (search: string) => void;
14
+ value: string;
15
+ };
16
+ actions: {
17
+ title: string;
18
+ icon: string;
19
+ emphasis: {
20
+ raised: boolean;
21
+ };
22
+ action: () => void;
23
+ }[];
24
+ exportable: {
25
+ name: string;
26
+ data: () => any[];
27
+ };
28
+ };
29
+ render(): import("lit-html").TemplateResult<1>;
30
+ pageInitialized(): Promise<void>;
31
+ fetchHandler({ page, limit, sortings, filters, search }: FetchOption): Promise<{
32
+ total: any;
33
+ records: any;
34
+ }>;
35
+ }
36
+ export {};