@things-factory/tax-invoice 8.0.0-beta.9 → 8.0.2

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 (51) hide show
  1. package/client/bootstrap.ts +1 -0
  2. package/client/index.ts +0 -0
  3. package/client/pages/main.ts +25 -0
  4. package/client/pages/tax-audit-result/tax-audit-result-importer.ts +87 -0
  5. package/client/pages/tax-audit-result/tax-audit-result-list-page.ts +331 -0
  6. package/client/pages/tax-invoice/tax-invoice-detail-popup.ts +454 -0
  7. package/client/pages/tax-invoice/tax-invoice-list-page.ts +525 -0
  8. package/client/pages/tax-invoice-api/tax-invoice-api-page.ts +418 -0
  9. package/client/pages/tax-invoice-company/tax-invoice-company-list-page.ts +447 -0
  10. package/client/pages/tax-invoice-send/company-list-popup.ts +188 -0
  11. package/client/pages/tax-invoice-send/tax-invoice-send-page.ts +196 -0
  12. package/client/pages/tax-invoice-send/tax-invoice-send.ts +1181 -0
  13. package/client/route.ts +23 -0
  14. package/client/tsconfig.json +11 -0
  15. package/dist-client/tsconfig.tsbuildinfo +1 -1
  16. package/dist-server/tsconfig.tsbuildinfo +1 -1
  17. package/package.json +8 -8
  18. package/server/index.ts +2 -0
  19. package/server/routes.ts +28 -0
  20. package/server/service/index.ts +37 -0
  21. package/server/service/tax-audit-result/event-subscriber.ts +17 -0
  22. package/server/service/tax-audit-result/index.ts +9 -0
  23. package/server/service/tax-audit-result/tax-audit-result-history.ts +120 -0
  24. package/server/service/tax-audit-result/tax-audit-result-mutation.ts +198 -0
  25. package/server/service/tax-audit-result/tax-audit-result-query.ts +65 -0
  26. package/server/service/tax-audit-result/tax-audit-result-type.ts +61 -0
  27. package/server/service/tax-audit-result/tax-audit-result.ts +99 -0
  28. package/server/service/tax-invoice/index.ts +6 -0
  29. package/server/service/tax-invoice/tax-invoice-mutation.ts +138 -0
  30. package/server/service/tax-invoice/tax-invoice-query.ts +99 -0
  31. package/server/service/tax-invoice/tax-invoice-type.ts +236 -0
  32. package/server/service/tax-invoice/tax-invoice-util.ts +224 -0
  33. package/server/service/tax-invoice/tax-invoice.ts +393 -0
  34. package/server/service/tax-invoice-api/index.ts +6 -0
  35. package/server/service/tax-invoice-api/tax-invoice-api-mutation.ts +275 -0
  36. package/server/service/tax-invoice-api/tax-invoice-api-query.ts +40 -0
  37. package/server/service/tax-invoice-api/tax-invoice-api-type.ts +83 -0
  38. package/server/service/tax-invoice-api/tax-invoice-api.ts +128 -0
  39. package/server/service/tax-invoice-company/index.ts +6 -0
  40. package/server/service/tax-invoice-company/tax-invoice-company-mutation.ts +84 -0
  41. package/server/service/tax-invoice-company/tax-invoice-company-query.ts +86 -0
  42. package/server/service/tax-invoice-company/tax-invoice-company-type.ts +105 -0
  43. package/server/service/tax-invoice-company/tax-invoice-company.ts +128 -0
  44. package/server/service/tax-invoice-item/index.ts +6 -0
  45. package/server/service/tax-invoice-item/tax-invoice-item-mutation.ts +128 -0
  46. package/server/service/tax-invoice-item/tax-invoice-item-query.ts +60 -0
  47. package/server/service/tax-invoice-item/tax-invoice-item-type.ts +77 -0
  48. package/server/service/tax-invoice-item/tax-invoice-item.ts +95 -0
  49. package/server/service/unipost-api/tax-invoice-inquiry.ts +99 -0
  50. package/server/service/unipost-api/tax-invoice-send.ts +32 -0
  51. package/server/tsconfig.json +10 -0
@@ -0,0 +1,418 @@
1
+ import '@operato/data-grist'
2
+
3
+ import { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
4
+ import { PageView } from '@operato/shell'
5
+ import { css, html } from 'lit'
6
+ import { customElement, property, query } from 'lit/decorators.js'
7
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements'
8
+ import { DataGrist, FetchOption } from '@operato/data-grist'
9
+ import { client } from '@operato/graphql'
10
+ import { i18next, localize } from '@operato/i18n'
11
+ import { notify } from '@operato/layout'
12
+ import { isMobileDevice } from '@operato/utils'
13
+ import gql from 'graphql-tag'
14
+ import { OxPrompt } from '@operato/popup'
15
+
16
+ @customElement('tax-invoice-api-page')
17
+ export class TaxInvoiceApiPage extends localize(i18next)(ScopedElementsMixin(PageView)) {
18
+ static styles = [
19
+ ScrollbarStyles,
20
+ CommonGristStyles,
21
+ CommonHeaderStyles,
22
+ css`
23
+ :host {
24
+ display: flex;
25
+
26
+ width: 100%;
27
+
28
+ --grid-record-emphasized-background-color: red;
29
+ --grid-record-emphasized-color: yellow;
30
+ }
31
+
32
+ ox-grist {
33
+ overflow-y: auto;
34
+ flex: 1;
35
+ }
36
+
37
+ .header {
38
+ grid-template-areas: 'filters actions';
39
+ }
40
+ `
41
+ ]
42
+
43
+ @property({ type: Object }) gristConfig: any
44
+ @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'
45
+
46
+ @query('ox-grist') private grist!: DataGrist
47
+
48
+ get context() {
49
+ return {
50
+ title: i18next.t('title.tax invoice api'),
51
+ help: 'tax-invoice-api/tax-invoice-api',
52
+ actions: [
53
+ {
54
+ title: i18next.t('button.save'),
55
+ action: this._updateTaxInvoiceApi.bind(this),
56
+ ...CommonButtonStyles.save
57
+ },
58
+ {
59
+ title: i18next.t('button.delete'),
60
+ action: this._deleteTaxAuditResult.bind(this),
61
+ ...CommonButtonStyles.delete
62
+ }
63
+ ]
64
+ }
65
+ }
66
+
67
+ render() {
68
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')
69
+
70
+ return html`
71
+ <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
72
+ <div slot="headroom" class="header">
73
+ <!-- <div class="filters">
74
+ <ox-filters-form autofocus without-search></ox-filters-form>
75
+ </div> -->
76
+ </div>
77
+ </ox-grist>
78
+ `
79
+ }
80
+
81
+ async pageInitialized(lifecycle: any) {
82
+ this.gristConfig = {
83
+ list: {
84
+ fields: ['name', 'description'],
85
+ details: ['name', 'updatedAt']
86
+ },
87
+ columns: [
88
+ { type: 'gutter', gutterName: 'sequence' },
89
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
90
+ {
91
+ type: 'boolean',
92
+ name: 'isDefault',
93
+ header: i18next.t('field.is_default'),
94
+ record: {
95
+ editable: true,
96
+ align: 'center'
97
+ },
98
+ width: 70
99
+ },
100
+ {
101
+ type: 'string',
102
+ name: 'provider',
103
+ header: i18next.t('field.provider'),
104
+ record: {
105
+ editable: true
106
+ },
107
+ width: 150
108
+ },
109
+ {
110
+ type: 'string',
111
+ name: 'apiKey',
112
+ header: i18next.t('field.api key'),
113
+ record: {
114
+ editable: true
115
+ },
116
+ width: 150
117
+ },
118
+ {
119
+ type: 'string',
120
+ name: 'apiAccountId',
121
+ header: i18next.t('field.api account id'),
122
+ record: {
123
+ editable: true
124
+ },
125
+ width: 150
126
+ },
127
+ {
128
+ type: 'password',
129
+ name: 'apiAccountPassword',
130
+ header: i18next.t('field.api account password'),
131
+ record: {
132
+ editable: true
133
+ },
134
+ width: 150
135
+ },
136
+ {
137
+ type: 'string',
138
+ name: 'businessRegistrationNumber',
139
+ header: i18next.t('field.business registration number'),
140
+ record: { editable: true },
141
+ width: 150
142
+ },
143
+ {
144
+ type: 'string',
145
+ name: 'branchIdentification',
146
+ header: i18next.t('field.branch identification'),
147
+ record: {
148
+ editable: true
149
+ },
150
+ width: 150
151
+ },
152
+ {
153
+ type: 'string',
154
+ name: 'businessName',
155
+ header: i18next.t('field.tax invoice business name'),
156
+ record: {
157
+ editable: true
158
+ },
159
+ width: 150
160
+ },
161
+ {
162
+ type: 'string',
163
+ name: 'representativeName',
164
+ header: i18next.t('field.tax invoice representative name'),
165
+ record: {
166
+ editable: true
167
+ },
168
+ width: 150
169
+ },
170
+ {
171
+ type: 'string',
172
+ name: 'address',
173
+ header: i18next.t('field.address'),
174
+ record: {
175
+ editable: true
176
+ },
177
+ width: 200
178
+ },
179
+ {
180
+ type: 'string',
181
+ name: 'businessType',
182
+ header: i18next.t('field.business type'),
183
+ record: {
184
+ editable: true
185
+ },
186
+ width: 100
187
+ },
188
+ {
189
+ type: 'string',
190
+ name: 'industryType',
191
+ header: i18next.t('field.industry type'),
192
+ record: {
193
+ editable: true
194
+ },
195
+ width: 100
196
+ },
197
+ {
198
+ type: 'string',
199
+ name: 'department',
200
+ header: i18next.t('field.department'),
201
+ record: {
202
+ editable: true
203
+ },
204
+ width: 150
205
+ },
206
+ {
207
+ type: 'string',
208
+ name: 'contactName',
209
+ header: i18next.t('field.contact name'),
210
+ record: {
211
+ editable: true
212
+ },
213
+ width: 150
214
+ },
215
+ {
216
+ type: 'string',
217
+ name: 'contactPhone',
218
+ header: i18next.t('field.contact phone'),
219
+ record: {
220
+ editable: true
221
+ },
222
+ width: 150
223
+ },
224
+ {
225
+ type: 'string',
226
+ name: 'contactEmail',
227
+ header: i18next.t('field.contact email'),
228
+ record: {
229
+ editable: true
230
+ },
231
+ width: 150
232
+ },
233
+ {
234
+ type: 'string',
235
+ name: 'contactCellPhone',
236
+ header: i18next.t('field.contact cell phone'),
237
+ record: {
238
+ editable: true
239
+ },
240
+ width: 150
241
+ },
242
+ {
243
+ type: 'attributes',
244
+ name: 'attributes',
245
+ header: i18next.t('field.attributes'),
246
+ record: {
247
+ editable: true,
248
+ options: async () => {
249
+ return {
250
+ objectified: true,
251
+ attributeSet: await this.getAttributeSetForEntity()
252
+ }
253
+ }
254
+ },
255
+ width: 150
256
+ },
257
+ {
258
+ type: 'resource-object',
259
+ name: 'updater',
260
+ header: i18next.t('field.updater'),
261
+ record: {
262
+ editable: false
263
+ },
264
+ width: 120
265
+ },
266
+ {
267
+ type: 'datetime',
268
+ name: 'updatedAt',
269
+ header: i18next.t('field.updated_at'),
270
+ record: {
271
+ editable: false
272
+ },
273
+ width: 180
274
+ }
275
+ ]
276
+ }
277
+ }
278
+
279
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
280
+ const response = await client.query({
281
+ query: gql`
282
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
283
+ responses: taxInvoiceApis(filters: $filters, pagination: $pagination, sortings: $sortings) {
284
+ items {
285
+ id
286
+ isDefault
287
+ provider
288
+ apiKey
289
+ apiAccountId
290
+ apiAccountPassword
291
+ businessRegistrationNumber
292
+ branchIdentification
293
+ businessName
294
+ representativeName
295
+ address
296
+ businessType
297
+ industryType
298
+ department
299
+ contactName
300
+ contactPhone
301
+ contactEmail
302
+ contactCellPhone
303
+ attributes
304
+ updater {
305
+ id
306
+ name
307
+ }
308
+ updatedAt
309
+ }
310
+ total
311
+ }
312
+ }
313
+ `,
314
+ variables: {
315
+ filters,
316
+ pagination: { page, limit },
317
+ sortings
318
+ }
319
+ })
320
+
321
+ return {
322
+ total: response.data.responses.total || 0,
323
+ records: response.data.responses.items || []
324
+ }
325
+ }
326
+
327
+ async _updateTaxInvoiceApi() {
328
+ let patches = this.grist.dirtyRecords
329
+ if (patches && patches.length) {
330
+ patches = patches.map(patch => {
331
+ let patchField: any = patch.id ? { id: patch.id } : {}
332
+ const dirtyFields = patch.__dirtyfields__
333
+ for (let key in dirtyFields) {
334
+ patchField[key] = dirtyFields[key].after
335
+ }
336
+ patchField.cuFlag = patch.__dirty__
337
+
338
+ return patchField
339
+ })
340
+
341
+ const response = await client.mutate({
342
+ mutation: gql`
343
+ mutation ($patches: [TaxInvoiceApiPatch!]!) {
344
+ updateMultipleTaxInvoiceApi(patches: $patches) {
345
+ provider
346
+ }
347
+ }
348
+ `,
349
+ variables: {
350
+ patches
351
+ }
352
+ })
353
+
354
+ if (!response.errors) {
355
+ this.grist.fetch()
356
+ notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.save') }) })
357
+ } else {
358
+ notify({ message: i18next.t('error.fail-save'), level: 'error' })
359
+ }
360
+ }
361
+ }
362
+
363
+ async getAttributeSetForEntity() {
364
+ const response = await client.query({
365
+ query: gql`
366
+ query {
367
+ attributeSet: attributeSetByEntity(entity: "TaxInvoiceApi") {
368
+ entity
369
+ description
370
+ items {
371
+ name
372
+ description
373
+ tag
374
+ type
375
+ active
376
+ hidden
377
+ options
378
+ }
379
+ }
380
+ }
381
+ `
382
+ })
383
+
384
+ return response.data?.attributeSet || {}
385
+ }
386
+
387
+ async _deleteTaxAuditResult() {
388
+ if (
389
+ await OxPrompt.open({
390
+ title: i18next.t('text.are_you_sure'),
391
+ text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
392
+ confirmButton: { text: i18next.t('button.confirm') },
393
+ cancelButton: { text: i18next.t('button.cancel') }
394
+ })
395
+ ) {
396
+ const ids = this.grist.selected.map(record => record.id)
397
+ if (ids && ids.length > 0) {
398
+ const response = await client.mutate({
399
+ mutation: gql`
400
+ mutation ($ids: [String!]!) {
401
+ deleteTaxInvoiceApis(ids: $ids)
402
+ }
403
+ `,
404
+ variables: {
405
+ ids
406
+ }
407
+ })
408
+
409
+ if (!response.errors) {
410
+ this.grist.fetch()
411
+ notify({
412
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
413
+ })
414
+ }
415
+ }
416
+ }
417
+ }
418
+ }