@things-factory/saas 0.0.0-stage → 10.1.236

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 (83) hide show
  1. package/README.md +19 -2
  2. package/dist-client/bootstrap.d.ts +1 -0
  3. package/dist-client/bootstrap.js +5 -0
  4. package/dist-client/bootstrap.js.map +1 -0
  5. package/dist-client/components/saas-bill-editor.d.ts +59 -0
  6. package/dist-client/components/saas-bill-editor.js +211 -0
  7. package/dist-client/components/saas-bill-editor.js.map +1 -0
  8. package/dist-client/entity360/saas-account-360.d.ts +12 -0
  9. package/dist-client/entity360/saas-account-360.js +231 -0
  10. package/dist-client/entity360/saas-account-360.js.map +1 -0
  11. package/dist-client/index.d.ts +3 -0
  12. package/dist-client/index.js +4 -0
  13. package/dist-client/index.js.map +1 -0
  14. package/dist-client/pages/saas-account-list.d.ts +57 -0
  15. package/dist-client/pages/saas-account-list.js +175 -0
  16. package/dist-client/pages/saas-account-list.js.map +1 -0
  17. package/dist-client/pages/saas-account-page.d.ts +54 -0
  18. package/dist-client/pages/saas-account-page.js +352 -0
  19. package/dist-client/pages/saas-account-page.js.map +1 -0
  20. package/dist-client/pages/saas-cost-trend.d.ts +23 -0
  21. package/dist-client/pages/saas-cost-trend.js +219 -0
  22. package/dist-client/pages/saas-cost-trend.js.map +1 -0
  23. package/dist-client/route.d.ts +1 -0
  24. package/dist-client/route.js +16 -0
  25. package/dist-client/route.js.map +1 -0
  26. package/dist-client/tsconfig.tsbuildinfo +1 -0
  27. package/dist-client/words.d.ts +47 -0
  28. package/dist-client/words.js +39 -0
  29. package/dist-client/words.js.map +1 -0
  30. package/dist-server/index.d.ts +1 -0
  31. package/dist-server/index.js +9 -0
  32. package/dist-server/index.js.map +1 -0
  33. package/dist-server/role-tasks.d.ts +2 -0
  34. package/dist-server/role-tasks.js +16 -0
  35. package/dist-server/role-tasks.js.map +1 -0
  36. package/dist-server/service/checks.d.ts +32 -0
  37. package/dist-server/service/checks.js +83 -0
  38. package/dist-server/service/checks.js.map +1 -0
  39. package/dist-server/service/index.d.ts +20 -0
  40. package/dist-server/service/index.js +38 -0
  41. package/dist-server/service/index.js.map +1 -0
  42. package/dist-server/service/saas-access.d.ts +20 -0
  43. package/dist-server/service/saas-access.js +36 -0
  44. package/dist-server/service/saas-access.js.map +1 -0
  45. package/dist-server/service/saas-account.d.ts +43 -0
  46. package/dist-server/service/saas-account.js +166 -0
  47. package/dist-server/service/saas-account.js.map +1 -0
  48. package/dist-server/service/saas-bill.d.ts +41 -0
  49. package/dist-server/service/saas-bill.js +160 -0
  50. package/dist-server/service/saas-bill.js.map +1 -0
  51. package/dist-server/service/saas-mutation.d.ts +12 -0
  52. package/dist-server/service/saas-mutation.js +103 -0
  53. package/dist-server/service/saas-mutation.js.map +1 -0
  54. package/dist-server/service/saas-query.d.ts +69 -0
  55. package/dist-server/service/saas-query.js +215 -0
  56. package/dist-server/service/saas-query.js.map +1 -0
  57. package/dist-server/service/saas-rules.d.ts +138 -0
  58. package/dist-server/service/saas-rules.js +217 -0
  59. package/dist-server/service/saas-rules.js.map +1 -0
  60. package/dist-server/service/saas-seat.d.ts +25 -0
  61. package/dist-server/service/saas-seat.js +105 -0
  62. package/dist-server/service/saas-seat.js.map +1 -0
  63. package/dist-server/service/saas-service.d.ts +119 -0
  64. package/dist-server/service/saas-service.js +492 -0
  65. package/dist-server/service/saas-service.js.map +1 -0
  66. package/dist-server/service/saas-subscription.d.ts +44 -0
  67. package/dist-server/service/saas-subscription.js +174 -0
  68. package/dist-server/service/saas-subscription.js.map +1 -0
  69. package/dist-server/service/saas-trend-type.d.ts +9 -0
  70. package/dist-server/service/saas-trend-type.js +37 -0
  71. package/dist-server/service/saas-trend-type.js.map +1 -0
  72. package/dist-server/service/saas-type.d.ts +113 -0
  73. package/dist-server/service/saas-type.js +430 -0
  74. package/dist-server/service/saas-type.js.map +1 -0
  75. package/dist-server/tsconfig.tsbuildinfo +1 -0
  76. package/package.json +49 -4
  77. package/things-factory.config.js +13 -0
  78. package/translations/en.json +185 -0
  79. package/translations/es.json +185 -0
  80. package/translations/ja.json +185 -0
  81. package/translations/ko.json +185 -0
  82. package/translations/ms.json +185 -0
  83. package/translations/zh.json +185 -0
@@ -0,0 +1,352 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist/ox-grist.js';
3
+ import '../components/saas-bill-editor.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, getEditor } from '@operato/data-grist';
8
+ import { client } from '@operato/graphql';
9
+ import { i18next, localize } from '@operato/i18n';
10
+ import { navigate, PageView } from '@operato/shell';
11
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
12
+ import { saveGrid } from '@things-factory/asset/dist-client/grid.js';
13
+ import { hasPrivilege } from '@things-factory/auth-base/dist-client';
14
+ import { SaasBillEditor } from '../components/saas-bill-editor.js';
15
+ import { amountText, BILLINGS, fieldWord, optionsOf, picker, SUBSCRIPTION_STATUSES } from '../words.js';
16
+ const TABS = ['subscriptions', 'seats', 'bills', 'admins'];
17
+ const SUBSCRIPTION_FIELDS = ['name', 'billing', 'quantity', 'unitPrice', 'amount', 'budget', 'everyMonths', 'startOn', 'renewalOn', 'autoRenew', 'noticeDays', 'department', 'asset', 'status', 'endedOn', 'description'];
18
+ const SEAT_FIELDS = ['employee', 'holder', 'fromOn', 'untilOn', 'description'];
19
+ /**
20
+ * 구독 서비스 한 계정 — tab by tab its subscriptions, the seats of one of them, its bills month by month and who administers
21
+ * it (ADR-0177 decisions 2-6). The keepers keep all of it; an admin keeps what is under their own account, not the account
22
+ * or its admins.
23
+ */
24
+ let SaasAccountPage = class SaasAccountPage extends localize(i18next)(PageView) {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.accountId = '';
28
+ this.subscriptions = [];
29
+ this.subscriptionId = '';
30
+ this.tab = 'subscriptions';
31
+ this.keeper = false;
32
+ }
33
+ static { this.styles = [
34
+ CommonGristStyles,
35
+ ScrollbarStyles,
36
+ css `
37
+ :host {
38
+ display: flex;
39
+ flex-direction: column;
40
+ overflow: hidden;
41
+ }
42
+ .head {
43
+ display: flex;
44
+ flex-wrap: wrap;
45
+ align-items: baseline;
46
+ gap: var(--spacing-small, 4px) var(--spacing-large, 12px);
47
+ padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);
48
+ color: var(--md-sys-color-on-surface-variant);
49
+ }
50
+ .tabs {
51
+ display: flex;
52
+ gap: var(--spacing-small, 4px);
53
+ overflow-x: auto;
54
+ padding: 0 var(--spacing-large, 12px) var(--spacing-medium, 8px);
55
+ }
56
+ .tabs button {
57
+ flex: none;
58
+ padding: 4px var(--spacing-large, 12px);
59
+ border: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));
60
+ border-radius: 999px;
61
+ background: none;
62
+ color: var(--md-sys-color-on-surface);
63
+ font: inherit;
64
+ font-size: var(--ui-t-body, 14px);
65
+ cursor: pointer;
66
+ }
67
+ .tabs button[aria-selected='true'] {
68
+ border-color: var(--md-sys-color-primary);
69
+ background: var(--md-sys-color-primary-container);
70
+ color: var(--md-sys-color-on-primary-container);
71
+ }
72
+ .tabs.sub button {
73
+ font-size: var(--ui-t-caption, 12px);
74
+ }
75
+ .empty {
76
+ padding: var(--spacing-large, 12px);
77
+ color: var(--md-sys-color-on-surface-variant);
78
+ }
79
+ ox-grist {
80
+ flex: 1;
81
+ overflow-y: auto;
82
+ }
83
+ `
84
+ ]; }
85
+ get context() {
86
+ const editing = this.tab !== 'admins' || this.keeper;
87
+ const actions = this.tab === 'bills'
88
+ ? [{ title: i18next.t('button.saas-bill-new'), icon: 'add', action: () => this.openBill() }]
89
+ : editing && (this.tab !== 'seats' || this.subscriptionId)
90
+ ? [
91
+ { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop(this.blank()) },
92
+ { title: i18next.t('button.delete'), action: () => this.save(true), ...CommonButtonStyles.delete },
93
+ { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }
94
+ ]
95
+ : [];
96
+ return { title: this.account?.name ?? i18next.t('title.saas-account-page'), actions };
97
+ }
98
+ async pageUpdated(changes, lifecycle) {
99
+ if (!this.active)
100
+ return;
101
+ const params = lifecycle?.params ?? {};
102
+ this.tab = TABS.includes(params.tab) ? params.tab : 'subscriptions';
103
+ const id = params.id ?? '';
104
+ if (id !== this.accountId || changes.active) {
105
+ this.accountId = id;
106
+ this.keeper = await hasPrivilege({ category: 'saas', privilege: 'mutation', domainOwnerGranted: true });
107
+ await this.read();
108
+ }
109
+ this.subscriptionId = params.subscription ?? this.seatPlans()[0]?.id ?? '';
110
+ this.gristConfig = this.configOf(this.tab);
111
+ this.updateContext();
112
+ }
113
+ seatPlans() {
114
+ return this.subscriptions.filter(one => one.billing === 'SEAT');
115
+ }
116
+ async read() {
117
+ if (!this.accountId)
118
+ return;
119
+ const response = await client.query({
120
+ query: gql `
121
+ query ($id: String!) {
122
+ saasAccount(id: $id) { id name identifier purpose currency billingDay secretLocation paymentAccount { id name } parent { id name } admins { id name controlNo } }
123
+ saasSubscriptions(accountId: $id) { id name billing status }
124
+ }
125
+ `,
126
+ variables: { id: this.accountId },
127
+ fetchPolicy: 'network-only'
128
+ });
129
+ this.account = response.data?.saasAccount;
130
+ this.subscriptions = response.data?.saasSubscriptions ?? [];
131
+ }
132
+ blank() {
133
+ const today = new Date().toISOString().slice(0, 10);
134
+ if (this.tab === 'subscriptions')
135
+ return { billing: 'FIXED', everyMonths: 1, startOn: today, autoRenew: true, status: 'ACTIVE' };
136
+ return this.tab === 'seats' ? { fromOn: today } : {};
137
+ }
138
+ render() {
139
+ const one = this.account;
140
+ const tabs = this.account?.parent ? ['admins'] : TABS;
141
+ return html `
142
+ <div class="head">
143
+ ${one
144
+ ? html `<span>
145
+ ${[
146
+ one.identifier,
147
+ one.parent ? i18next.t('text.saas-account-under', { name: one.parent.name }) : null,
148
+ one.purpose,
149
+ one.currency,
150
+ one.billingDay ? i18next.t('text.saas-account-billing-day', { day: one.billingDay }) : null,
151
+ one.paymentAccount?.name,
152
+ one.secretLocation ? i18next.t('text.saas-account-secret-at', { where: one.secretLocation }) : null
153
+ ]
154
+ .filter(Boolean)
155
+ .join(' · ')}
156
+ </span>`
157
+ : nothing}
158
+ </div>
159
+ <div class="tabs" role="tablist">
160
+ ${tabs.map(tab => html `<button role="tab" aria-selected=${String(this.tab === tab)} @click=${() => navigate(`saas-account-page?id=${this.accountId}&tab=${tab}`)}>${i18next.t(`text.saas-tab-${tab}`)}</button>`)}
161
+ </div>
162
+ ${this.tab === 'seats'
163
+ ? this.seatPlans().length
164
+ ? html `<div class="tabs sub" role="tablist">
165
+ ${this.seatPlans().map(sub => html `<button role="tab" aria-selected=${String(this.subscriptionId === sub.id)} @click=${() => navigate(`saas-account-page?id=${this.accountId}&tab=seats&subscription=${sub.id}`)}>
166
+ ${sub.name}
167
+ </button>`)}
168
+ </div>`
169
+ : html `<div class="empty">${i18next.t('text.saas-seats-no-plan')}</div>`
170
+ : nothing}
171
+ ${this.gristConfig && (this.tab !== 'seats' || this.subscriptionId)
172
+ ? html `<ox-grist .mode=${'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}></ox-grist>`
173
+ : nothing}
174
+ `;
175
+ }
176
+ configOf(tab) {
177
+ const editable = { editable: tab !== 'bills' && (tab !== 'admins' || this.keeper) };
178
+ const set = `saas-${tab === 'subscriptions' ? 'subscription' : tab === 'seats' ? 'seat' : tab === 'bills' ? 'bill' : 'admin'}`;
179
+ const text = (name, width, extra = {}) => ({ type: 'string', name, header: fieldWord(set, name), width, ...extra, record: { ...editable, ...extra.record } });
180
+ const day = (name, extra = {}) => text(name, 100, { ...extra, record: { align: 'center', ...extra.record } });
181
+ const money = (name, extra = {}) => ({ type: 'float', name, header: fieldWord(set, name), width: 110, ...extra, record: { ...editable, align: 'right', renderer: (value) => amountText(value), ...extra.record } });
182
+ const int = (name, width = 70) => ({ type: 'integer', name, header: fieldWord(set, name), width, record: { ...editable, align: 'right' } });
183
+ const object = (name, width, queryName, columns) => ({
184
+ type: 'object',
185
+ name,
186
+ header: fieldWord(set, name),
187
+ width,
188
+ record: { ...editable, editor: getEditor('resource-object'), options: picker(queryName, columns) }
189
+ });
190
+ const columns = {
191
+ subscriptions: [
192
+ text('name', 200, { record: { mandatory: true } }),
193
+ { type: 'select', name: 'billing', header: fieldWord(set, 'billing'), width: 90, record: { ...editable, mandatory: true, options: optionsOf('saas-billing', BILLINGS) } },
194
+ money('quantity', { width: 70, record: { renderer: (value) => amountText(value) } }),
195
+ money('unitPrice'),
196
+ money('amount'),
197
+ money('budget'),
198
+ int('everyMonths'),
199
+ day('startOn', { record: { mandatory: true } }),
200
+ day('renewalOn'),
201
+ { type: 'checkbox', name: 'autoRenew', header: fieldWord(set, 'autoRenew'), width: 70, record: editable },
202
+ int('noticeDays'),
203
+ { type: 'integer', name: 'seatsHeld', header: fieldWord(set, 'seatsHeld'), width: 70, record: { align: 'right' } },
204
+ object('department', 120, 'departments', [{ name: 'name', header: fieldWord(set, 'department') }]),
205
+ object('asset', 140, 'assets', [{ name: 'name', header: fieldWord(set, 'asset') }]),
206
+ { type: 'select', name: 'status', header: fieldWord(set, 'status'), width: 90, record: { ...editable, options: optionsOf('saas-subscription-status', SUBSCRIPTION_STATUSES) } },
207
+ day('endedOn'),
208
+ text('description', 200)
209
+ ],
210
+ seats: [
211
+ object('employee', 140, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),
212
+ text('holder', 140),
213
+ day('fromOn'),
214
+ day('untilOn'),
215
+ text('description', 240)
216
+ ],
217
+ bills: [
218
+ text('month', 90, { record: { align: 'center' } }),
219
+ day('billedOn'),
220
+ money('total', { width: 140, header: `${fieldWord(set, 'total')} (${this.account?.currency ?? ''})` }),
221
+ { type: 'string', name: 'lines', header: fieldWord(set, 'lines'), width: 360, record: { renderer: (lines) => (lines ?? []).map(line => `${line.subscription?.name ?? line.label ?? ''} ${amountText(line.amount)}`).join(' · ') } },
222
+ text('description', 200)
223
+ ],
224
+ admins: [
225
+ object('employee', 160, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),
226
+ { type: 'string', name: 'controlNo', header: i18next.t('field.control-no'), width: 100 }
227
+ ]
228
+ };
229
+ return {
230
+ rows: { appendable: !!editable.editable, selectable: { multiple: !!editable.editable } },
231
+ pagination: { infinite: true },
232
+ emptyNote: { title: i18next.t(`text.saas-${tab}-empty`) },
233
+ columns: [
234
+ { type: 'gutter', gutterName: 'sequence' },
235
+ ...(editable.editable ? [{ type: 'gutter', gutterName: 'row-selector', multiple: true }] : []),
236
+ ...(tab === 'bills'
237
+ ? [{ type: 'gutter', gutterName: 'button', icon: 'edit', handlers: { click: (_c, _d, _col, record) => record?.id && this.openBill(record) } }]
238
+ : tab === 'subscriptions'
239
+ ? [
240
+ {
241
+ type: 'gutter',
242
+ gutterName: 'button',
243
+ icon: 'group',
244
+ handlers: { click: (_c, _d, _col, record) => record?.id && record.billing === 'SEAT' && navigate(`saas-account-page?id=${this.accountId}&tab=seats&subscription=${record.id}`) }
245
+ }
246
+ ]
247
+ : []),
248
+ ...columns[tab]
249
+ ]
250
+ };
251
+ }
252
+ async fetchHandler() {
253
+ if (!this.accountId)
254
+ return { total: 0, records: [] };
255
+ if (this.tab === 'admins') {
256
+ const records = (this.account?.admins ?? []).map((one) => ({ id: one.id, employee: { id: one.id, name: one.name }, controlNo: one.controlNo }));
257
+ return { total: records.length, records };
258
+ }
259
+ const queries = {
260
+ subscriptions: `rows: saasSubscriptions(accountId: $id) { id name billing quantity unitPrice amount budget everyMonths startOn renewalOn autoRenew noticeDays seatsHeld department { id name } asset { id name } status endedOn description }`,
261
+ seats: `rows: saasSeats(subscriptionId: $id) { id employee { id name } holder fromOn untilOn description }`,
262
+ bills: `rows: saasBills(accountId: $id) { id month billedOn total description lines { subscription { id name } label amount } }`
263
+ };
264
+ const response = await client.query({
265
+ query: gql `query ($id: String!) { ${queries[this.tab]} }`,
266
+ variables: { id: this.tab === 'seats' ? this.subscriptionId : this.accountId },
267
+ fetchPolicy: 'network-only'
268
+ });
269
+ if (response.errors?.length)
270
+ throw response;
271
+ return { total: response.data.rows.length, records: response.data.rows };
272
+ }
273
+ openBill(bill) {
274
+ SaasBillEditor.open({
275
+ accountId: this.accountId,
276
+ currency: this.account?.currency ?? '',
277
+ subscriptions: this.subscriptions,
278
+ bill,
279
+ saved: () => this.grist?.fetch()
280
+ });
281
+ }
282
+ async save(deleting = false) {
283
+ if (this.tab === 'admins')
284
+ return this.saveAdmins(deleting);
285
+ /* A picked row goes as its id. */
286
+ const shape = ({ department, asset, employee, ...patch }) => ({
287
+ ...patch,
288
+ ...(department === undefined ? {} : { departmentId: department?.id ?? null }),
289
+ ...(asset === undefined ? {} : { assetId: asset?.id ?? null }),
290
+ ...(employee === undefined ? {} : { employeeId: employee?.id ?? null })
291
+ });
292
+ const saved = this.tab === 'subscriptions'
293
+ ? await saveGrid(this.grist, SUBSCRIPTION_FIELDS, 'updateMultipleSaasSubscription', 'SaasSubscriptionPatch', { accountId: this.accountId }, deleting, shape)
294
+ : await saveGrid(this.grist, SEAT_FIELDS, 'updateMultipleSaasSeat', 'SaasSeatPatch', { subscriptionId: this.subscriptionId }, deleting, shape);
295
+ if (saved) {
296
+ this.grist.fetch();
297
+ if (this.tab === 'subscriptions')
298
+ await this.read();
299
+ }
300
+ }
301
+ /** The admins are a field of the account - the grid's rows, less the deleted, saved as its list. */
302
+ async saveAdmins(deleting) {
303
+ const removed = new Set(deleting ? this.grist.selected.map((one) => one.employee?.id ?? one.id) : []);
304
+ const rows = (this.grist.dirtyData?.records ?? []).filter((one) => one.__dirty__ !== '-' && one.employee?.id && !removed.has(one.employee.id));
305
+ const adminIds = [...new Set(rows.map((one) => one.employee.id))];
306
+ const grist = {
307
+ dirtyRecords: [{ id: this.accountId, __dirty__: 'M', __dirtyfields__: { adminIds: true }, adminIds }],
308
+ selected: []
309
+ };
310
+ if (await saveGrid(grist, ['adminIds'], 'updateMultipleSaasAccount', 'SaasAccountPatch')) {
311
+ await this.read();
312
+ this.grist.fetch();
313
+ }
314
+ }
315
+ };
316
+ __decorate([
317
+ state(),
318
+ __metadata("design:type", Object)
319
+ ], SaasAccountPage.prototype, "accountId", void 0);
320
+ __decorate([
321
+ state(),
322
+ __metadata("design:type", Object)
323
+ ], SaasAccountPage.prototype, "account", void 0);
324
+ __decorate([
325
+ state(),
326
+ __metadata("design:type", Array)
327
+ ], SaasAccountPage.prototype, "subscriptions", void 0);
328
+ __decorate([
329
+ state(),
330
+ __metadata("design:type", Object)
331
+ ], SaasAccountPage.prototype, "subscriptionId", void 0);
332
+ __decorate([
333
+ state(),
334
+ __metadata("design:type", String)
335
+ ], SaasAccountPage.prototype, "tab", void 0);
336
+ __decorate([
337
+ state(),
338
+ __metadata("design:type", Object)
339
+ ], SaasAccountPage.prototype, "keeper", void 0);
340
+ __decorate([
341
+ state(),
342
+ __metadata("design:type", Object)
343
+ ], SaasAccountPage.prototype, "gristConfig", void 0);
344
+ __decorate([
345
+ query('ox-grist'),
346
+ __metadata("design:type", DataGrist)
347
+ ], SaasAccountPage.prototype, "grist", void 0);
348
+ SaasAccountPage = __decorate([
349
+ customElement('saas-account-page')
350
+ ], SaasAccountPage);
351
+ export { SaasAccountPage };
352
+ //# sourceMappingURL=saas-account-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saas-account-page.js","sourceRoot":"","sources":["../../client/pages/saas-account-page.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,mCAAmC,CAAA;AAE1C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,E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,EAAE,EAAE,QAAQ,EAAE,CAAC;YACrG,QAAQ,EAAE,EAAE;SACN,CAAA;QACR,IAAI,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,2BAA2B,EAAE,kBAAkB,CAAC,EAAE,CAAC;YACzF,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;YACjB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;IACH,CAAC;;AAxPQ;IAAR,KAAK,EAAE;;kDAAe;AACd;IAAR,KAAK,EAAE;;gDAAc;AACb;IAAR,KAAK,EAAE;;sDAA0B;AACzB;IAAR,KAAK,EAAE;;uDAAoB;AACnB;IAAR,KAAK,EAAE;;4CAA2B;AAC1B;IAAR,KAAK,EAAE;;+CAAe;AACd;IAAR,KAAK,EAAE;;oDAAiB;AACE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AA7DjC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA+S3B","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '../components/saas-bill-editor.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, getEditor } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { saveGrid } from '@things-factory/asset/dist-client/grid.js'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\n\nimport { SaasBillEditor } from '../components/saas-bill-editor.js'\nimport { amountText, BILLINGS, fieldWord, optionsOf, picker, SUBSCRIPTION_STATUSES } from '../words.js'\n\ntype Tab = 'subscriptions' | 'seats' | 'bills' | 'admins'\nconst TABS: Tab[] = ['subscriptions', 'seats', 'bills', 'admins']\n\nconst SUBSCRIPTION_FIELDS = ['name', 'billing', 'quantity', 'unitPrice', 'amount', 'budget', 'everyMonths', 'startOn', 'renewalOn', 'autoRenew', 'noticeDays', 'department', 'asset', 'status', 'endedOn', 'description']\nconst SEAT_FIELDS = ['employee', 'holder', 'fromOn', 'untilOn', 'description']\n\n/**\n * 구독 서비스 한 계정 — tab by tab its subscriptions, the seats of one of them, its bills month by month and who administers\n * it (ADR-0177 decisions 2-6). The keepers keep all of it; an admin keeps what is under their own account, not the account\n * or its admins.\n */\n@customElement('saas-account-page')\nexport class SaasAccountPage extends localize(i18next)(PageView) {\n static styles = [\n CommonGristStyles,\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n .head {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: var(--spacing-small, 4px) var(--spacing-large, 12px);\n padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n color: var(--md-sys-color-on-surface-variant);\n }\n .tabs {\n display: flex;\n gap: var(--spacing-small, 4px);\n overflow-x: auto;\n padding: 0 var(--spacing-large, 12px) var(--spacing-medium, 8px);\n }\n .tabs button {\n flex: none;\n padding: 4px var(--spacing-large, 12px);\n border: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));\n border-radius: 999px;\n background: none;\n color: var(--md-sys-color-on-surface);\n font: inherit;\n font-size: var(--ui-t-body, 14px);\n cursor: pointer;\n }\n .tabs button[aria-selected='true'] {\n border-color: var(--md-sys-color-primary);\n background: var(--md-sys-color-primary-container);\n color: var(--md-sys-color-on-primary-container);\n }\n .tabs.sub button {\n font-size: var(--ui-t-caption, 12px);\n }\n .empty {\n padding: var(--spacing-large, 12px);\n color: var(--md-sys-color-on-surface-variant);\n }\n ox-grist {\n flex: 1;\n overflow-y: auto;\n }\n `\n ]\n\n @state() accountId = ''\n @state() account?: any\n @state() subscriptions: any[] = []\n @state() subscriptionId = ''\n @state() tab: Tab = 'subscriptions'\n @state() keeper = false\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n const editing = this.tab !== 'admins' || this.keeper\n const actions =\n this.tab === 'bills'\n ? [{ title: i18next.t('button.saas-bill-new'), icon: 'add', action: () => this.openBill() }]\n : editing && (this.tab !== 'seats' || this.subscriptionId)\n ? [\n { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop(this.blank()) },\n { title: i18next.t('button.delete'), action: () => this.save(true), ...CommonButtonStyles.delete },\n { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }\n ]\n : []\n return { title: this.account?.name ?? i18next.t('title.saas-account-page'), actions }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active) return\n const params = lifecycle?.params ?? {}\n this.tab = TABS.includes(params.tab) ? params.tab : 'subscriptions'\n const id = params.id ?? ''\n if (id !== this.accountId || changes.active) {\n this.accountId = id\n this.keeper = await hasPrivilege({ category: 'saas', privilege: 'mutation', domainOwnerGranted: true })\n await this.read()\n }\n this.subscriptionId = params.subscription ?? this.seatPlans()[0]?.id ?? ''\n this.gristConfig = this.configOf(this.tab)\n this.updateContext()\n }\n\n private seatPlans() {\n return this.subscriptions.filter(one => one.billing === 'SEAT')\n }\n\n private async read() {\n if (!this.accountId) return\n const response = await client.query({\n query: gql`\n query ($id: String!) {\n saasAccount(id: $id) { id name identifier purpose currency billingDay secretLocation paymentAccount { id name } parent { id name } admins { id name controlNo } }\n saasSubscriptions(accountId: $id) { id name billing status }\n }\n `,\n variables: { id: this.accountId },\n fetchPolicy: 'network-only'\n })\n this.account = response.data?.saasAccount\n this.subscriptions = response.data?.saasSubscriptions ?? []\n }\n\n private blank(): any {\n const today = new Date().toISOString().slice(0, 10)\n if (this.tab === 'subscriptions') return { billing: 'FIXED', everyMonths: 1, startOn: today, autoRenew: true, status: 'ACTIVE' }\n return this.tab === 'seats' ? { fromOn: today } : {}\n }\n\n render() {\n const one = this.account\n const tabs = this.account?.parent ? (['admins'] as Tab[]) : TABS\n return html`\n <div class=\"head\">\n ${one\n ? html`<span>\n ${[\n one.identifier,\n one.parent ? i18next.t('text.saas-account-under', { name: one.parent.name }) : null,\n one.purpose,\n one.currency,\n one.billingDay ? i18next.t('text.saas-account-billing-day', { day: one.billingDay }) : null,\n one.paymentAccount?.name,\n one.secretLocation ? i18next.t('text.saas-account-secret-at', { where: one.secretLocation }) : null\n ]\n .filter(Boolean)\n .join(' · ')}\n </span>`\n : nothing}\n </div>\n <div class=\"tabs\" role=\"tablist\">\n ${tabs.map(\n tab => html`<button role=\"tab\" aria-selected=${String(this.tab === tab)} @click=${() => navigate(`saas-account-page?id=${this.accountId}&tab=${tab}`)}>${i18next.t(`text.saas-tab-${tab}`)}</button>`\n )}\n </div>\n ${this.tab === 'seats'\n ? this.seatPlans().length\n ? html`<div class=\"tabs sub\" role=\"tablist\">\n ${this.seatPlans().map(\n sub =>\n html`<button role=\"tab\" aria-selected=${String(this.subscriptionId === sub.id)} @click=${() => navigate(`saas-account-page?id=${this.accountId}&tab=seats&subscription=${sub.id}`)}>\n ${sub.name}\n </button>`\n )}\n </div>`\n : html`<div class=\"empty\">${i18next.t('text.saas-seats-no-plan')}</div>`\n : nothing}\n ${this.gristConfig && (this.tab !== 'seats' || this.subscriptionId)\n ? html`<ox-grist .mode=${'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}></ox-grist>`\n : nothing}\n `\n }\n\n private configOf(tab: Tab) {\n const editable = { editable: tab !== 'bills' && (tab !== 'admins' || this.keeper) }\n const set = `saas-${tab === 'subscriptions' ? 'subscription' : tab === 'seats' ? 'seat' : tab === 'bills' ? 'bill' : 'admin'}`\n const text = (name: string, width: number, extra: any = {}) => ({ type: 'string', name, header: fieldWord(set, name), width, ...extra, record: { ...editable, ...extra.record } })\n const day = (name: string, extra: any = {}) => text(name, 100, { ...extra, record: { align: 'center', ...extra.record } })\n const money = (name: string, extra: any = {}) => ({ type: 'float', name, header: fieldWord(set, name), width: 110, ...extra, record: { ...editable, align: 'right', renderer: (value: number) => amountText(value), ...extra.record } })\n const int = (name: string, width = 70) => ({ type: 'integer', name, header: fieldWord(set, name), width, record: { ...editable, align: 'right' } })\n const object = (name: string, width: number, queryName: string, columns: { name: string; header?: string }[]) => ({\n type: 'object',\n name,\n header: fieldWord(set, name),\n width,\n record: { ...editable, editor: getEditor('resource-object'), options: picker(queryName, columns) }\n })\n const columns: Record<Tab, any[]> = {\n subscriptions: [\n text('name', 200, { record: { mandatory: true } }),\n { type: 'select', name: 'billing', header: fieldWord(set, 'billing'), width: 90, record: { ...editable, mandatory: true, options: optionsOf('saas-billing', BILLINGS) } },\n money('quantity', { width: 70, record: { renderer: (value: number) => amountText(value) } }),\n money('unitPrice'),\n money('amount'),\n money('budget'),\n int('everyMonths'),\n day('startOn', { record: { mandatory: true } }),\n day('renewalOn'),\n { type: 'checkbox', name: 'autoRenew', header: fieldWord(set, 'autoRenew'), width: 70, record: editable },\n int('noticeDays'),\n { type: 'integer', name: 'seatsHeld', header: fieldWord(set, 'seatsHeld'), width: 70, record: { align: 'right' } },\n object('department', 120, 'departments', [{ name: 'name', header: fieldWord(set, 'department') }]),\n object('asset', 140, 'assets', [{ name: 'name', header: fieldWord(set, 'asset') }]),\n { type: 'select', name: 'status', header: fieldWord(set, 'status'), width: 90, record: { ...editable, options: optionsOf('saas-subscription-status', SUBSCRIPTION_STATUSES) } },\n day('endedOn'),\n text('description', 200)\n ],\n seats: [\n object('employee', 140, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),\n text('holder', 140),\n day('fromOn'),\n day('untilOn'),\n text('description', 240)\n ],\n bills: [\n text('month', 90, { record: { align: 'center' } }),\n day('billedOn'),\n money('total', { width: 140, header: `${fieldWord(set, 'total')} (${this.account?.currency ?? ''})` }),\n { type: 'string', name: 'lines', header: fieldWord(set, 'lines'), width: 360, record: { renderer: (lines: any[]) => (lines ?? []).map(line => `${line.subscription?.name ?? line.label ?? ''} ${amountText(line.amount)}`).join(' · ') } },\n text('description', 200)\n ],\n admins: [\n object('employee', 160, 'employees', [{ name: 'name', header: fieldWord(set, 'employee') }, { name: 'controlNo', header: i18next.t('field.control-no') }]),\n { type: 'string', name: 'controlNo', header: i18next.t('field.control-no'), width: 100 }\n ]\n }\n return {\n rows: { appendable: !!editable.editable, selectable: { multiple: !!editable.editable } },\n pagination: { infinite: true },\n emptyNote: { title: i18next.t(`text.saas-${tab}-empty`) },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n ...(editable.editable ? [{ type: 'gutter', gutterName: 'row-selector', multiple: true }] : []),\n ...(tab === 'bills'\n ? [{ type: 'gutter', gutterName: 'button', icon: 'edit', handlers: { click: (_c: any, _d: any, _col: any, record: any) => record?.id && this.openBill(record) } }]\n : tab === 'subscriptions'\n ? [\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'group',\n handlers: { click: (_c: any, _d: any, _col: any, record: any) => record?.id && record.billing === 'SEAT' && navigate(`saas-account-page?id=${this.accountId}&tab=seats&subscription=${record.id}`) }\n }\n ]\n : []),\n ...columns[tab]\n ]\n }\n }\n\n async fetchHandler() {\n if (!this.accountId) return { total: 0, records: [] }\n if (this.tab === 'admins') {\n const records = (this.account?.admins ?? []).map((one: any) => ({ id: one.id, employee: { id: one.id, name: one.name }, controlNo: one.controlNo }))\n return { total: records.length, records }\n }\n const queries: Record<Exclude<Tab, 'admins'>, string> = {\n subscriptions: `rows: saasSubscriptions(accountId: $id) { id name billing quantity unitPrice amount budget everyMonths startOn renewalOn autoRenew noticeDays seatsHeld department { id name } asset { id name } status endedOn description }`,\n seats: `rows: saasSeats(subscriptionId: $id) { id employee { id name } holder fromOn untilOn description }`,\n bills: `rows: saasBills(accountId: $id) { id month billedOn total description lines { subscription { id name } label amount } }`\n }\n const response = await client.query({\n query: gql`query ($id: String!) { ${queries[this.tab]} }`,\n variables: { id: this.tab === 'seats' ? this.subscriptionId : this.accountId },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return { total: response.data.rows.length, records: response.data.rows }\n }\n\n private openBill(bill?: any) {\n SaasBillEditor.open({\n accountId: this.accountId,\n currency: this.account?.currency ?? '',\n subscriptions: this.subscriptions,\n bill,\n saved: () => this.grist?.fetch()\n })\n }\n\n private async save(deleting = false) {\n if (this.tab === 'admins') return this.saveAdmins(deleting)\n /* A picked row goes as its id. */\n const shape = ({ department, asset, employee, ...patch }: any) => ({\n ...patch,\n ...(department === undefined ? {} : { departmentId: department?.id ?? null }),\n ...(asset === undefined ? {} : { assetId: asset?.id ?? null }),\n ...(employee === undefined ? {} : { employeeId: employee?.id ?? null })\n })\n const saved =\n this.tab === 'subscriptions'\n ? await saveGrid(this.grist, SUBSCRIPTION_FIELDS, 'updateMultipleSaasSubscription', 'SaasSubscriptionPatch', { accountId: this.accountId }, deleting, shape)\n : await saveGrid(this.grist, SEAT_FIELDS, 'updateMultipleSaasSeat', 'SaasSeatPatch', { subscriptionId: this.subscriptionId }, deleting, shape)\n if (saved) {\n this.grist.fetch()\n if (this.tab === 'subscriptions') await this.read()\n }\n }\n\n /** The admins are a field of the account - the grid's rows, less the deleted, saved as its list. */\n private async saveAdmins(deleting: boolean) {\n const removed = new Set(deleting ? this.grist.selected.map((one: any) => one.employee?.id ?? one.id) : [])\n const rows = (this.grist.dirtyData?.records ?? []).filter((one: any) => one.__dirty__ !== '-' && one.employee?.id && !removed.has(one.employee.id))\n const adminIds = [...new Set(rows.map((one: any) => one.employee.id))]\n const grist = {\n dirtyRecords: [{ id: this.accountId, __dirty__: 'M', __dirtyfields__: { adminIds: true }, adminIds }],\n selected: []\n } as any\n if (await saveGrid(grist, ['adminIds'], 'updateMultipleSaasAccount', 'SaasAccountPatch')) {\n await this.read()\n this.grist.fetch()\n }\n }\n}\n\n"]}
@@ -0,0 +1,23 @@
1
+ import { PageView } from '@operato/shell';
2
+ declare const SaasCostTrend_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
3
+ /**
4
+ * 비용 추이 — what the subscriptions cost month by month, from their bills (ADR-0177 decision 9): everything, each account
5
+ * with its subscriptions under it, each department, in each bill's own currency. What the latest bills are worth telling
6
+ * comes first. Nothing here is stored; it is read from the bills each time.
7
+ */
8
+ export declare class SaasCostTrend extends SaasCostTrend_base {
9
+ static styles: import("lit").CSSResult[];
10
+ from: string;
11
+ to: string;
12
+ trend?: any;
13
+ get context(): {
14
+ title: string;
15
+ };
16
+ pageUpdated(changes: any): Promise<void>;
17
+ private read;
18
+ private change;
19
+ private row;
20
+ private head;
21
+ render(): import("lit-html").TemplateResult<1>;
22
+ }
23
+ export {};