@things-factory/tax-invoice 7.0.0-alpha.8 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/bootstrap.ts +1 -0
- package/client/pages/tax-audit-result/tax-audit-result-importer.ts +8 -19
- package/client/pages/tax-audit-result/tax-audit-result-list-page.ts +10 -25
- package/client/pages/tax-invoice/tax-invoice-detail-popup.ts +21 -19
- package/client/pages/tax-invoice-api/tax-invoice-api-page.ts +99 -61
- package/client/pages/tax-invoice-company/tax-invoice-company-list-page.ts +2 -67
- package/client/pages/{tax-invoice-company/tax-invoice-company-importer.ts → tax-invoice-send/company-list-popup.ts} +69 -57
- package/client/pages/tax-invoice-send/tax-invoice-send-page.ts +78 -742
- package/client/pages/tax-invoice-send/tax-invoice-send.ts +1181 -0
- package/config/config.development.js +13 -0
- package/config/config.production.js +13 -0
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +1 -1
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/pages/main.js.map +1 -1
- package/dist-client/pages/tax-audit-result/tax-audit-result-importer.d.ts +1 -0
- package/dist-client/pages/tax-audit-result/tax-audit-result-importer.js +5 -12
- package/dist-client/pages/tax-audit-result/tax-audit-result-importer.js.map +1 -1
- package/dist-client/pages/tax-audit-result/tax-audit-result-list-page.js +8 -16
- package/dist-client/pages/tax-audit-result/tax-audit-result-list-page.js.map +1 -1
- package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.d.ts +0 -1
- package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.js +20 -17
- package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.js.map +1 -1
- package/dist-client/pages/tax-invoice/tax-invoice-list-page.d.ts +5 -5
- package/dist-client/pages/tax-invoice/tax-invoice-list-page.js.map +1 -1
- package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.d.ts +3 -2
- package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.js +91 -61
- package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.js.map +1 -1
- package/dist-client/pages/tax-invoice-company/tax-invoice-company-list-page.d.ts +0 -16
- package/dist-client/pages/tax-invoice-company/tax-invoice-company-list-page.js +3 -62
- package/dist-client/pages/tax-invoice-company/tax-invoice-company-list-page.js.map +1 -1
- package/dist-client/pages/tax-invoice-send/company-list-popup.d.ts +69 -0
- package/dist-client/pages/{tax-invoice-company/tax-invoice-company-importer.js → tax-invoice-send/company-list-popup.js} +75 -60
- package/dist-client/pages/tax-invoice-send/company-list-popup.js.map +1 -0
- package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.d.ts +11 -78
- package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.js +65 -654
- package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.js.map +1 -1
- package/dist-client/pages/tax-invoice-send/tax-invoice-send.d.ts +112 -0
- package/dist-client/pages/tax-invoice-send/tax-invoice-send.js +1086 -0
- package/dist-client/pages/tax-invoice-send/tax-invoice-send.js.map +1 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/index.d.ts +2 -0
- package/dist-server/routes.d.ts +1 -0
- package/dist-server/service/index.d.ts +9 -0
- package/dist-server/service/index.js +1 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/tax-audit-result/event-subscriber.d.ts +7 -0
- package/dist-server/service/tax-audit-result/event-subscriber.js +2 -2
- package/dist-server/service/tax-audit-result/event-subscriber.js.map +1 -1
- package/dist-server/service/tax-audit-result/index.d.ts +7 -0
- package/dist-server/service/tax-audit-result/tax-audit-result-history.d.ts +25 -0
- package/dist-server/service/tax-audit-result/tax-audit-result-history.js +10 -6
- package/dist-server/service/tax-audit-result/tax-audit-result-history.js.map +1 -1
- package/dist-server/service/tax-audit-result/tax-audit-result-mutation.d.ts +10 -0
- package/dist-server/service/tax-audit-result/tax-audit-result-mutation.js +2 -2
- package/dist-server/service/tax-audit-result/tax-audit-result-mutation.js.map +1 -1
- package/dist-server/service/tax-audit-result/tax-audit-result-query.d.ts +12 -0
- package/dist-server/service/tax-audit-result/tax-audit-result-query.js +3 -3
- package/dist-server/service/tax-audit-result/tax-audit-result-query.js.map +1 -1
- package/dist-server/service/tax-audit-result/tax-audit-result-type.d.ts +23 -0
- package/dist-server/service/tax-audit-result/tax-audit-result-type.js +6 -6
- package/dist-server/service/tax-audit-result/tax-audit-result-type.js.map +1 -1
- package/dist-server/service/tax-audit-result/tax-audit-result.d.ts +25 -0
- package/dist-server/service/tax-audit-result/tax-audit-result.js +4 -4
- package/dist-server/service/tax-audit-result/tax-audit-result.js.map +1 -1
- package/dist-server/service/tax-invoice/index.d.ts +5 -0
- package/dist-server/service/tax-invoice/tax-invoice-mutation.d.ts +10 -0
- package/dist-server/service/tax-invoice/tax-invoice-mutation.js +2 -6
- package/dist-server/service/tax-invoice/tax-invoice-mutation.js.map +1 -1
- package/dist-server/service/tax-invoice/tax-invoice-query.d.ts +14 -0
- package/dist-server/service/tax-invoice/tax-invoice-query.js +22 -10
- package/dist-server/service/tax-invoice/tax-invoice-query.js.map +1 -1
- package/dist-server/service/tax-invoice/tax-invoice-type.d.ts +86 -0
- package/dist-server/service/tax-invoice/tax-invoice-type.js +12 -8
- package/dist-server/service/tax-invoice/tax-invoice-type.js.map +1 -1
- package/dist-server/service/tax-invoice/tax-invoice-util.d.ts +133 -0
- package/dist-server/service/tax-invoice/tax-invoice-util.js +2 -2
- package/dist-server/service/tax-invoice/tax-invoice-util.js.map +1 -1
- package/dist-server/service/tax-invoice/tax-invoice.d.ts +120 -0
- package/dist-server/service/tax-invoice/tax-invoice.js +15 -10
- package/dist-server/service/tax-invoice/tax-invoice.js.map +1 -1
- package/dist-server/service/tax-invoice-api/index.d.ts +5 -0
- package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.d.ts +8 -0
- package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js +46 -16
- package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js.map +1 -1
- package/dist-server/service/tax-invoice-api/tax-invoice-api-query.d.ts +10 -0
- package/dist-server/service/tax-invoice-api/tax-invoice-api-query.js +15 -9
- package/dist-server/service/tax-invoice-api/tax-invoice-api-query.js.map +1 -1
- package/dist-server/service/tax-invoice-api/tax-invoice-api-type.d.ts +32 -0
- package/dist-server/service/tax-invoice-api/tax-invoice-api-type.js +9 -13
- package/dist-server/service/tax-invoice-api/tax-invoice-api-type.js.map +1 -1
- package/dist-server/service/tax-invoice-api/tax-invoice-api.d.ts +31 -0
- package/dist-server/service/tax-invoice-api/tax-invoice-api.js +12 -24
- package/dist-server/service/tax-invoice-api/tax-invoice-api.js.map +1 -1
- package/dist-server/service/tax-invoice-company/index.d.ts +5 -0
- package/dist-server/service/tax-invoice-company/tax-invoice-company-mutation.d.ts +7 -0
- package/dist-server/service/tax-invoice-company/tax-invoice-company-mutation.js +2 -2
- package/dist-server/service/tax-invoice-company/tax-invoice-company-mutation.js.map +1 -1
- package/dist-server/service/tax-invoice-company/tax-invoice-company-query.d.ts +14 -0
- package/dist-server/service/tax-invoice-company/tax-invoice-company-query.js +44 -9
- package/dist-server/service/tax-invoice-company/tax-invoice-company-query.js.map +1 -1
- package/dist-server/service/tax-invoice-company/tax-invoice-company-type.d.ts +38 -0
- package/dist-server/service/tax-invoice-company/tax-invoice-company-type.js +59 -9
- package/dist-server/service/tax-invoice-company/tax-invoice-company-type.js.map +1 -1
- package/dist-server/service/tax-invoice-company/tax-invoice-company.d.ts +29 -0
- package/dist-server/service/tax-invoice-company/tax-invoice-company.js +14 -24
- package/dist-server/service/tax-invoice-company/tax-invoice-company.js.map +1 -1
- package/dist-server/service/tax-invoice-item/index.d.ts +5 -0
- package/dist-server/service/tax-invoice-item/tax-invoice-item-mutation.d.ts +10 -0
- package/dist-server/service/tax-invoice-item/tax-invoice-item-mutation.js +2 -2
- package/dist-server/service/tax-invoice-item/tax-invoice-item-mutation.js.map +1 -1
- package/dist-server/service/tax-invoice-item/tax-invoice-item-query.d.ts +11 -0
- package/dist-server/service/tax-invoice-item/tax-invoice-item-query.js +3 -3
- package/dist-server/service/tax-invoice-item/tax-invoice-item-query.js.map +1 -1
- package/dist-server/service/tax-invoice-item/tax-invoice-item-type.d.ts +29 -0
- package/dist-server/service/tax-invoice-item/tax-invoice-item-type.js +6 -6
- package/dist-server/service/tax-invoice-item/tax-invoice-item-type.js.map +1 -1
- package/dist-server/service/tax-invoice-item/tax-invoice-item.d.ts +23 -0
- package/dist-server/service/tax-invoice-item/tax-invoice-item.js +7 -7
- package/dist-server/service/tax-invoice-item/tax-invoice-item.js.map +1 -1
- package/dist-server/service/unipost-api/tax-invoice-inquiry.d.ts +16 -0
- package/dist-server/service/unipost-api/tax-invoice-inquiry.js +10 -14
- package/dist-server/service/unipost-api/tax-invoice-inquiry.js.map +1 -1
- package/dist-server/service/unipost-api/tax-invoice-send.d.ts +1 -0
- package/dist-server/service/unipost-api/tax-invoice-send.js +5 -7
- package/dist-server/service/unipost-api/tax-invoice-send.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/server/service/index.ts +1 -0
- package/server/service/tax-audit-result/tax-audit-result-history.ts +10 -6
- package/server/service/tax-audit-result/tax-audit-result-query.ts +4 -1
- package/server/service/tax-audit-result/tax-audit-result.ts +6 -2
- package/server/service/tax-invoice/tax-invoice-mutation.ts +0 -3
- package/server/service/tax-invoice/tax-invoice-query.ts +36 -9
- package/server/service/tax-invoice/tax-invoice-type.ts +3 -0
- package/server/service/tax-invoice/tax-invoice-util.ts +1 -0
- package/server/service/tax-invoice/tax-invoice.ts +19 -4
- package/server/service/tax-invoice-api/tax-invoice-api-mutation.ts +63 -24
- package/server/service/tax-invoice-api/tax-invoice-api-query.ts +15 -6
- package/server/service/tax-invoice-api/tax-invoice-api-type.ts +2 -5
- package/server/service/tax-invoice-api/tax-invoice-api.ts +23 -20
- package/server/service/tax-invoice-company/tax-invoice-company-query.ts +39 -6
- package/server/service/tax-invoice-company/tax-invoice-company-type.ts +40 -4
- package/server/service/tax-invoice-company/tax-invoice-company.ts +11 -21
- package/server/service/tax-invoice-item/tax-invoice-item-query.ts +4 -1
- package/server/service/tax-invoice-item/tax-invoice-item.ts +22 -8
- package/server/service/unipost-api/tax-invoice-inquiry.ts +6 -10
- package/server/service/unipost-api/tax-invoice-send.ts +5 -5
- package/translations/ko.json +3 -0
- package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.d.ts +0 -31
- package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/tax-invoice",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@operato/graphql": "^
|
|
31
|
-
"@operato/shell": "^
|
|
32
|
-
"@things-factory/auth-base": "^7.0.0
|
|
33
|
-
"@things-factory/
|
|
34
|
-
"@things-factory/
|
|
30
|
+
"@operato/graphql": "^7.0.0",
|
|
31
|
+
"@operato/shell": "^7.0.0",
|
|
32
|
+
"@things-factory/auth-base": "^7.0.0",
|
|
33
|
+
"@things-factory/env": "^7.0.0",
|
|
34
|
+
"@things-factory/export-ui-excel": "^7.0.0",
|
|
35
|
+
"@things-factory/shell": "^7.0.0"
|
|
35
36
|
},
|
|
36
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "00f3917ca132679e3571f3f4fd16f4caf84f488e"
|
|
37
38
|
}
|
package/server/service/index.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export * from './tax-audit-result/tax-audit-result'
|
|
3
3
|
export * from './tax-invoice-item/tax-invoice-item'
|
|
4
4
|
export * from './tax-invoice/tax-invoice'
|
|
5
|
+
export * from './tax-invoice-company/tax-invoice-company'
|
|
5
6
|
|
|
6
7
|
/* IMPORT ENTITIES AND RESOLVERS */
|
|
7
8
|
import { entities as TaxAuditResultEntities, resolvers as TaxAuditResultResolvers, subscribers as TaxAuditResultSubscribers } from './tax-audit-result'
|
|
@@ -24,7 +24,11 @@ const DATABASE_TYPE = ORMCONFIG.type
|
|
|
24
24
|
)
|
|
25
25
|
@Index(
|
|
26
26
|
'ix_tax-audit-result_history_1',
|
|
27
|
-
(taxAuditResultHistory: TaxAuditResultHistory) => [
|
|
27
|
+
(taxAuditResultHistory: TaxAuditResultHistory) => [
|
|
28
|
+
taxAuditResultHistory.domain,
|
|
29
|
+
taxAuditResultHistory.originalId,
|
|
30
|
+
taxAuditResultHistory.version
|
|
31
|
+
],
|
|
28
32
|
{ unique: true }
|
|
29
33
|
)
|
|
30
34
|
@ObjectType({ description: 'History Entity of TaxAuditResult' })
|
|
@@ -38,7 +42,7 @@ export class TaxAuditResultHistory implements HistoryEntityInterface<TaxAuditRes
|
|
|
38
42
|
version?: number = 1
|
|
39
43
|
|
|
40
44
|
@ManyToOne(type => Domain)
|
|
41
|
-
@Field(
|
|
45
|
+
@Field(type => Domain)
|
|
42
46
|
domain?: Domain
|
|
43
47
|
|
|
44
48
|
@RelationId((taxAuditResult: TaxAuditResult) => taxAuditResult.domain)
|
|
@@ -77,14 +81,14 @@ export class TaxAuditResultHistory implements HistoryEntityInterface<TaxAuditRes
|
|
|
77
81
|
deletedAt?: Date
|
|
78
82
|
|
|
79
83
|
@ManyToOne(type => User, { nullable: true })
|
|
80
|
-
@Field({ nullable: true })
|
|
84
|
+
@Field(type => User, { nullable: true })
|
|
81
85
|
creator?: User
|
|
82
86
|
|
|
83
87
|
@RelationId((taxAuditResult: TaxAuditResult) => taxAuditResult.creator)
|
|
84
88
|
creatorId?: string
|
|
85
89
|
|
|
86
90
|
@ManyToOne(type => User, { nullable: true })
|
|
87
|
-
@Field({ nullable: true })
|
|
91
|
+
@Field(type => User, { nullable: true })
|
|
88
92
|
updater?: User
|
|
89
93
|
|
|
90
94
|
@RelationId((taxAuditResult: TaxAuditResult) => taxAuditResult.updater)
|
|
@@ -102,8 +106,8 @@ export class TaxAuditResultHistory implements HistoryEntityInterface<TaxAuditRes
|
|
|
102
106
|
DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
103
107
|
? 'enum'
|
|
104
108
|
: DATABASE_TYPE == 'oracle'
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
? 'varchar2'
|
|
110
|
+
: 'smallint',
|
|
107
111
|
enum: HistoryActionType
|
|
108
112
|
})
|
|
109
113
|
public action!: HistoryActionType
|
|
@@ -17,7 +17,10 @@ export class TaxAuditResultQuery {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
@Query(returns => TaxAuditResultList, { description: 'To fetch multiple TaxAuditResults' })
|
|
20
|
-
async taxAuditResults(
|
|
20
|
+
async taxAuditResults(
|
|
21
|
+
@Args(type => ListParam) params: ListParam,
|
|
22
|
+
@Ctx() context: ResolverContext
|
|
23
|
+
): Promise<TaxAuditResultList> {
|
|
21
24
|
const { domain } = context.state
|
|
22
25
|
|
|
23
26
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
@@ -26,7 +26,11 @@ registerEnumType(TaxAuditResultStatus, {
|
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
@Entity()
|
|
29
|
-
@Index(
|
|
29
|
+
@Index(
|
|
30
|
+
'ix_tax_audit_result_0',
|
|
31
|
+
(taxAuditResult: TaxAuditResult) => [taxAuditResult.domain, taxAuditResult.name, taxAuditResult.deletedAt],
|
|
32
|
+
{ unique: true }
|
|
33
|
+
)
|
|
30
34
|
@ObjectType({ description: 'Entity for TaxAuditResult' })
|
|
31
35
|
export class TaxAuditResult {
|
|
32
36
|
@PrimaryGeneratedColumn('uuid')
|
|
@@ -38,7 +42,7 @@ export class TaxAuditResult {
|
|
|
38
42
|
version?: number = 1
|
|
39
43
|
|
|
40
44
|
@ManyToOne(type => Domain)
|
|
41
|
-
@Field(
|
|
45
|
+
@Field(type => Domain)
|
|
42
46
|
domain?: Domain
|
|
43
47
|
|
|
44
48
|
@RelationId((taxAuditResult: TaxAuditResult) => taxAuditResult.domain)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx } from 'type-graphql'
|
|
2
2
|
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
3
3
|
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import { TaxInvoice } from './tax-invoice'
|
|
4
|
+
import { Category, Purpose, TaxInvoice } from './tax-invoice'
|
|
5
5
|
import { TaxInvoiceList, TaxInvoiceSummary } from './tax-invoice-type'
|
|
6
6
|
import { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'
|
|
7
7
|
|
|
@@ -17,7 +17,10 @@ export class TaxInvoiceQuery {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
@Query(returns => TaxInvoiceList, { description: 'To fetch multiple TaxInvoices' })
|
|
20
|
-
async taxInvoices(
|
|
20
|
+
async taxInvoices(
|
|
21
|
+
@Args(type => ListParam) params: ListParam,
|
|
22
|
+
@Ctx() context: ResolverContext
|
|
23
|
+
): Promise<TaxInvoiceList> {
|
|
21
24
|
const { domain } = context.state
|
|
22
25
|
|
|
23
26
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
@@ -32,20 +35,44 @@ export class TaxInvoiceQuery {
|
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
@Query(returns => TaxInvoiceSummary, { description: 'To fetch TaxInvoices Summary' })
|
|
35
|
-
async taxInvoicesSummary(
|
|
38
|
+
async taxInvoicesSummary(
|
|
39
|
+
@Args(type => ListParam) params: ListParam,
|
|
40
|
+
@Ctx() context: ResolverContext
|
|
41
|
+
): Promise<TaxInvoiceSummary> {
|
|
36
42
|
const { domain } = context.state
|
|
43
|
+
let category = params.filters.filter(v => v.name === 'category')?.[0]?.value
|
|
37
44
|
|
|
38
45
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
39
46
|
domain,
|
|
40
47
|
params: { ...params, pagination: {} },
|
|
41
48
|
repository: await getRepository(TaxInvoice)
|
|
42
49
|
})
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
|
|
51
|
+
// 매입/매출이 있으면 그냥 가격으로 표시, 전체 조회면 매출-매입 으로 계산
|
|
52
|
+
if (category) {
|
|
53
|
+
queryBuilder
|
|
54
|
+
.select('COUNT(id)', 'cnt')
|
|
55
|
+
.addSelect('SUM(supply_amount)', 'supply_amount')
|
|
56
|
+
.addSelect('SUM(tax_amount)', 'tax_amount')
|
|
57
|
+
.addSelect('SUM(total_amount)', 'total_amount')
|
|
58
|
+
} else {
|
|
59
|
+
queryBuilder
|
|
60
|
+
.select('COUNT(id)', 'cnt')
|
|
61
|
+
.addSelect(
|
|
62
|
+
`SUM(CASE WHEN category = \'${Category.EXPORT}\' THEN supply_amount ELSE -1 * supply_amount END)`,
|
|
63
|
+
'supply_amount'
|
|
64
|
+
)
|
|
65
|
+
.addSelect(
|
|
66
|
+
`SUM(CASE WHEN category = \'${Category.EXPORT}\' THEN tax_amount ELSE -1 * tax_amount END)`,
|
|
67
|
+
'tax_amount'
|
|
68
|
+
)
|
|
69
|
+
.addSelect(
|
|
70
|
+
`SUM(CASE WHEN category = \'${Category.EXPORT}\' THEN total_amount ELSE -1 * total_amount END)`,
|
|
71
|
+
'total_amount'
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const summary = await queryBuilder.getRawOne()
|
|
49
76
|
|
|
50
77
|
return { summary }
|
|
51
78
|
}
|
|
@@ -150,6 +150,7 @@ export function parseTaxInvoiceByUnipostFormat(unipostTaxInvoice: UnipostTaxInvo
|
|
|
150
150
|
remark0: unipostTaxInvoice.tid_desc0,
|
|
151
151
|
remark1: unipostTaxInvoice.tid_desc1,
|
|
152
152
|
remark2: unipostTaxInvoice.tid_desc2,
|
|
153
|
+
isSentByApi: true,
|
|
153
154
|
category: category,
|
|
154
155
|
supplierBusinessRegistrationCategory: unipostTaxInvoice.tit_alice_specorg_biztypecode,
|
|
155
156
|
supplierBusinessRegistrationNumber: unipostTaxInvoice.tit_alice_id,
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CreateDateColumn,
|
|
3
|
+
UpdateDateColumn,
|
|
4
|
+
DeleteDateColumn,
|
|
5
|
+
Entity,
|
|
6
|
+
Index,
|
|
7
|
+
Column,
|
|
8
|
+
RelationId,
|
|
9
|
+
ManyToOne,
|
|
10
|
+
OneToMany,
|
|
11
|
+
PrimaryGeneratedColumn
|
|
12
|
+
} from 'typeorm'
|
|
2
13
|
import { ObjectType, Field, ID, registerEnumType } from 'type-graphql'
|
|
3
14
|
import { encryptTransformer } from '@things-factory/shell'
|
|
4
15
|
|
|
@@ -84,7 +95,7 @@ export class TaxInvoice {
|
|
|
84
95
|
readonly id!: string
|
|
85
96
|
|
|
86
97
|
@ManyToOne(type => Domain)
|
|
87
|
-
@Field(
|
|
98
|
+
@Field(type => Domain)
|
|
88
99
|
domain?: Domain
|
|
89
100
|
|
|
90
101
|
@RelationId((taxInvoice: TaxInvoice) => taxInvoice.domain)
|
|
@@ -114,8 +125,8 @@ export class TaxInvoice {
|
|
|
114
125
|
@Field({ nullable: true, description: '원 승인 번호 (계산서 수정시 원래의 승인 번호)' })
|
|
115
126
|
originalApprovalNo?: string
|
|
116
127
|
|
|
117
|
-
@Column({ nullable:
|
|
118
|
-
@Field({ nullable:
|
|
128
|
+
@Column({ nullable: true, comment: '세금계산서 작성 일자 (YYYY-MM-DD)' })
|
|
129
|
+
@Field({ nullable: true, description: '세금계산서 작성 일자 (YYYY-MM-DD)' })
|
|
119
130
|
issueDate!: Date
|
|
120
131
|
|
|
121
132
|
@Column({ nullable: true, comment: '세금계산서 전자 서명 일자 (YYYY-MM-DD)' })
|
|
@@ -146,6 +157,10 @@ export class TaxInvoice {
|
|
|
146
157
|
@Field({ nullable: true, description: '비고2' })
|
|
147
158
|
remark2?: string
|
|
148
159
|
|
|
160
|
+
@Column({ nullable: true, default: false, comment: 'API를 통한 발행 여부' })
|
|
161
|
+
@Field({ nullable: true, description: 'API를 통한 발행 여부' })
|
|
162
|
+
isSentByApi?: boolean
|
|
163
|
+
|
|
149
164
|
@Column({ nullable: true, comment: '공급자 사업자등록번호 구분 코드' })
|
|
150
165
|
@Field({ nullable: true, description: '공급자 사업자등록번호 구분 코드' })
|
|
151
166
|
supplierBusinessRegistrationCategory?: BusinessRegistrationCategory
|
|
@@ -4,39 +4,53 @@ import { In } from 'typeorm'
|
|
|
4
4
|
import { TaxInvoiceApi } from './tax-invoice-api'
|
|
5
5
|
import { TaxInvoiceApiPatch, TaxInvoiceSend } from './tax-invoice-api-type'
|
|
6
6
|
import { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'
|
|
7
|
-
import { Category, TaxInvoice } from '../tax-invoice/tax-invoice'
|
|
7
|
+
import { Category, InvoiceType, TaxInvoice } from '../tax-invoice/tax-invoice'
|
|
8
8
|
import { sendTaxInvoiceByUniposApi } from '../unipost-api/tax-invoice-send'
|
|
9
9
|
import { parseTaxInvoiceByUnipostFormat } from '../tax-invoice/tax-invoice-util'
|
|
10
10
|
|
|
11
11
|
@Resolver(TaxInvoiceApi)
|
|
12
12
|
export class TaxInvoiceApiMutation {
|
|
13
13
|
@Directive('@transaction')
|
|
14
|
-
@Mutation(returns => TaxInvoiceApi, { description: 'To modify Tax Invoice Api information' })
|
|
15
|
-
async updateMultipleTaxInvoiceApi(
|
|
14
|
+
@Mutation(returns => [TaxInvoiceApi], { description: 'To modify Tax Invoice Api information' })
|
|
15
|
+
async updateMultipleTaxInvoiceApi(
|
|
16
|
+
@Arg('patches', type => [TaxInvoiceApiPatch]) patches: TaxInvoiceApiPatch[],
|
|
17
|
+
@Ctx() context: ResolverContext
|
|
18
|
+
): Promise<TaxInvoiceApi[]> {
|
|
16
19
|
const { domain, user, tx } = context.state
|
|
20
|
+
|
|
21
|
+
let results = []
|
|
22
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
23
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
17
24
|
const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)
|
|
18
|
-
let results
|
|
19
|
-
|
|
20
|
-
if (patch.cuFlag.toUpperCase() === '+') {
|
|
21
|
-
const result = await taxInvoiceApiRepo.save({
|
|
22
|
-
...patch,
|
|
23
|
-
domain,
|
|
24
|
-
creator: user,
|
|
25
|
-
updater: user
|
|
26
|
-
})
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
if (_createRecords.length > 0) {
|
|
27
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
28
|
+
const newRecord = _createRecords[i]
|
|
29
|
+
|
|
30
|
+
const result = await taxInvoiceApiRepo.save({
|
|
31
|
+
...newRecord,
|
|
32
|
+
domain,
|
|
33
|
+
creator: user,
|
|
34
|
+
updater: user
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
results.push({ ...result, cuFlag: '+' })
|
|
38
|
+
}
|
|
29
39
|
}
|
|
30
40
|
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
...patch,
|
|
36
|
-
updater: user
|
|
37
|
-
})
|
|
41
|
+
if (_updateRecords.length > 0) {
|
|
42
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
43
|
+
const updateRecord = _updateRecords[i]
|
|
44
|
+
const taxAuditResult = await taxInvoiceApiRepo.findOneBy({ id: updateRecord.id })
|
|
38
45
|
|
|
39
|
-
|
|
46
|
+
const result = await taxInvoiceApiRepo.save({
|
|
47
|
+
...taxAuditResult,
|
|
48
|
+
...updateRecord,
|
|
49
|
+
updater: user
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
results.push({ ...result, cuFlag: 'M' })
|
|
53
|
+
}
|
|
40
54
|
}
|
|
41
55
|
|
|
42
56
|
return results
|
|
@@ -68,16 +82,21 @@ export class TaxInvoiceApiMutation {
|
|
|
68
82
|
const taxInvoiceItemRepo = tx.getRepository(TaxInvoiceItem)
|
|
69
83
|
const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)
|
|
70
84
|
|
|
71
|
-
const apiInfo =
|
|
85
|
+
const apiInfo = await taxInvoiceApiRepo.findOneBy({ isDefault: true })
|
|
72
86
|
const businessRegistrationNumber = apiInfo.businessRegistrationNumber
|
|
73
87
|
const { aid = '', bearer = '', customer_no = '' } = apiInfo?.attributes
|
|
74
88
|
let failCount = 0
|
|
89
|
+
let failMessage = []
|
|
75
90
|
|
|
76
91
|
// 1. 밸리데이션 및 데이터 파싱
|
|
77
92
|
let newTaxInvoiceSendList = taxInvoiceSendList.map(taxInvoiceSend => this._parseTaxInvoiceSendForApi(taxInvoiceSend, aid, customer_no))
|
|
78
93
|
|
|
79
94
|
// 2. 세금계산서 발행 API 호출
|
|
80
95
|
const apiResult = await sendTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer, newTaxInvoiceSendList)
|
|
96
|
+
if (apiResult === false) {
|
|
97
|
+
// TODO 로그 찍기
|
|
98
|
+
throw new Error('tax invoice send exception: api error')
|
|
99
|
+
}
|
|
81
100
|
|
|
82
101
|
// 3. 성공하면 세금계산서 DB에 저장
|
|
83
102
|
for (let item of apiResult) {
|
|
@@ -98,12 +117,13 @@ export class TaxInvoiceApiMutation {
|
|
|
98
117
|
}
|
|
99
118
|
} else {
|
|
100
119
|
failCount++
|
|
120
|
+
failMessage.push(`${item.inv_seq}: ${item.message}`)
|
|
101
121
|
}
|
|
102
122
|
}
|
|
103
123
|
|
|
104
124
|
// 실패가 1개라도 있으면 에러
|
|
105
125
|
if (failCount > 0) {
|
|
106
|
-
throw new Error(failCount + '개의 계산서 등록에
|
|
126
|
+
throw new Error(failCount + '개의 계산서 등록에 실패하였습니다.\n' + failMessage.join('\n'))
|
|
107
127
|
}
|
|
108
128
|
|
|
109
129
|
return true
|
|
@@ -128,6 +148,16 @@ export class TaxInvoiceApiMutation {
|
|
|
128
148
|
throw new Error('tax invoice send exception: no essential value')
|
|
129
149
|
}
|
|
130
150
|
|
|
151
|
+
// 공급자 사업자 등록번호가 전부 숫자이며 10자리 인지 체크
|
|
152
|
+
if (isNaN(taxInvoice.supplierBusinessRegistrationNumber) || taxInvoice.supplierBusinessRegistrationNumber.length !== 10) {
|
|
153
|
+
throw new Error('tax invoice send exception: Supplier Business Registration Number is wrong')
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 공급받는자 사업자 등록번호가 전부 숫자이며 10자리 인지 체크
|
|
157
|
+
if (isNaN(taxInvoice.buyerBusinessRegistrationNumber) || taxInvoice.buyerBusinessRegistrationNumber.length !== 10) {
|
|
158
|
+
throw new Error('tax invoice send exception: Buyer Business Registration Number is wrong')
|
|
159
|
+
}
|
|
160
|
+
|
|
131
161
|
// 작성일자가 오늘 날짜를 넘어가면 에러
|
|
132
162
|
if (taxInvoice.issueDate > today) {
|
|
133
163
|
throw new Error('tax invoice send exception: issueDate error')
|
|
@@ -136,11 +166,15 @@ export class TaxInvoiceApiMutation {
|
|
|
136
166
|
// 현금, 수표, 어음, 외상미수금이 있을시 총 합계금액과 금액 동일 체크
|
|
137
167
|
const paymentAmount: number =
|
|
138
168
|
taxInvoice.paymentAmountCash + taxInvoice.paymentAmountCheck + taxInvoice.paymentAmountPromissoryNote + taxInvoice.paymentAmountAccountsReceivable
|
|
139
|
-
|
|
140
169
|
if (paymentAmount > 0 && paymentAmount !== taxInvoice.totalAmount) {
|
|
141
170
|
throw new Error('tax invoice send exception: summary is not same')
|
|
142
171
|
}
|
|
143
172
|
|
|
173
|
+
// 영세업자인데 세금이 있으면 에러
|
|
174
|
+
if (taxInvoice.invoiceType === InvoiceType.ZERO_RATED_TAX_INVOICE && taxInvoice.taxAmount > 0) {
|
|
175
|
+
throw new Error('tax invoice send exception: tax price is exist')
|
|
176
|
+
}
|
|
177
|
+
|
|
144
178
|
for (let item of taxInvoiceItems) {
|
|
145
179
|
// 아이템 필수값 체크
|
|
146
180
|
if (!item.supplyDate || !item.itemName || !item.quantity || !item.unitPrice) {
|
|
@@ -152,6 +186,11 @@ export class TaxInvoiceApiMutation {
|
|
|
152
186
|
throw new Error('tax invoice send exception: item supplyDate is bigger than issueDate')
|
|
153
187
|
}
|
|
154
188
|
|
|
189
|
+
// 영세업자인데 아이템 세금이 있으면 에러
|
|
190
|
+
if (taxInvoice.invoiceType === InvoiceType.ZERO_RATED_TAX_INVOICE && item.taxPrice > 0) {
|
|
191
|
+
throw new Error('tax invoice send exception: item tax price is exist')
|
|
192
|
+
}
|
|
193
|
+
|
|
155
194
|
newTaxInvoiceItems.push({
|
|
156
195
|
tii_seqnumeric: item.sequence,
|
|
157
196
|
tii_purchaseexpirydatetime: item.supplyDate.replace(/-/g, ''),
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import { Resolver, Query, FieldResolver, Root, Ctx } from 'type-graphql'
|
|
2
|
-
import { Domain, getRepository } from '@things-factory/shell'
|
|
1
|
+
import { Resolver, Query, FieldResolver, Root, Args, Ctx } from 'type-graphql'
|
|
2
|
+
import { Domain, ListParam, getQueryBuilderFromListParams, getRepository } from '@things-factory/shell'
|
|
3
3
|
import { User } from '@things-factory/auth-base'
|
|
4
4
|
import { TaxInvoiceApi } from './tax-invoice-api'
|
|
5
|
+
import { TaxInvoiceApiList } from './tax-invoice-api-type'
|
|
5
6
|
|
|
6
7
|
@Resolver(TaxInvoiceApi)
|
|
7
8
|
export class TaxInvoiceApiQuery {
|
|
8
|
-
@Query(returns =>
|
|
9
|
-
async
|
|
9
|
+
@Query(returns => TaxInvoiceApiList!, { nullable: true, description: 'To fetch a Tax Invoice Api List' })
|
|
10
|
+
async taxInvoiceApis(
|
|
11
|
+
@Args(type => ListParam) params: ListParam,
|
|
12
|
+
@Ctx() context: ResolverContext
|
|
13
|
+
): Promise<TaxInvoiceApiList> {
|
|
10
14
|
const { domain } = context.state
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
17
|
+
domain,
|
|
18
|
+
params,
|
|
19
|
+
repository: await getRepository(TaxInvoiceApi)
|
|
14
20
|
})
|
|
21
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
22
|
+
|
|
23
|
+
return { items, total }
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
@FieldResolver(type => Domain)
|
|
@@ -10,13 +10,10 @@ export class TaxInvoiceApiPatch {
|
|
|
10
10
|
id?: string
|
|
11
11
|
|
|
12
12
|
@Field({ nullable: true })
|
|
13
|
-
|
|
13
|
+
isDefault?: boolean
|
|
14
14
|
|
|
15
15
|
@Field({ nullable: true })
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@Field({ nullable: true })
|
|
19
|
-
apiKey?: string
|
|
16
|
+
provider?: string
|
|
20
17
|
|
|
21
18
|
@Field({ nullable: true })
|
|
22
19
|
apiAccountId?: string
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CreateDateColumn,
|
|
3
|
+
UpdateDateColumn,
|
|
4
|
+
Entity,
|
|
5
|
+
Index,
|
|
6
|
+
Column,
|
|
7
|
+
RelationId,
|
|
8
|
+
ManyToOne,
|
|
9
|
+
PrimaryGeneratedColumn
|
|
10
|
+
} from 'typeorm'
|
|
2
11
|
import { ObjectType, Field, ID } from 'type-graphql'
|
|
3
12
|
|
|
4
13
|
import { Domain, ScalarObject, encryptTransformer } from '@things-factory/shell'
|
|
5
14
|
import { User } from '@things-factory/auth-base'
|
|
6
15
|
|
|
7
|
-
@Entity(
|
|
8
|
-
@Index(
|
|
9
|
-
|
|
16
|
+
@Entity()
|
|
17
|
+
@Index(
|
|
18
|
+
'ix_tax_invoice_api_provider',
|
|
19
|
+
(taxInvoiceApi: TaxInvoiceApi) => [taxInvoiceApi.domain, taxInvoiceApi.provider],
|
|
20
|
+
{ unique: true }
|
|
21
|
+
)
|
|
10
22
|
@ObjectType({ description: 'Entity for Tax Invoice Api' })
|
|
11
23
|
export class TaxInvoiceApi {
|
|
12
24
|
@PrimaryGeneratedColumn('uuid')
|
|
@@ -14,24 +26,19 @@ export class TaxInvoiceApi {
|
|
|
14
26
|
readonly id!: string
|
|
15
27
|
|
|
16
28
|
@ManyToOne(type => Domain)
|
|
17
|
-
@Field(
|
|
29
|
+
@Field(type => Domain)
|
|
18
30
|
domain?: Domain
|
|
19
31
|
|
|
20
32
|
@RelationId((taxInvoiceApi: TaxInvoiceApi) => taxInvoiceApi.domain)
|
|
21
33
|
domainId?: string
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
@Field({ nullable:
|
|
25
|
-
|
|
26
|
-
uniqueSequence!: number
|
|
27
|
-
|
|
28
|
-
@Field({ nullable: false })
|
|
29
|
-
@Column({ nullable: false })
|
|
30
|
-
name!: string
|
|
35
|
+
@Column({ nullable: true, comment: '디폴트 여부' })
|
|
36
|
+
@Field({ nullable: true, description: '디폴트 여부' })
|
|
37
|
+
isDefault?: boolean
|
|
31
38
|
|
|
32
|
-
@
|
|
33
|
-
@
|
|
34
|
-
|
|
39
|
+
@Column({ nullable: false, comment: '공급자' })
|
|
40
|
+
@Field({ nullable: false, description: '공급자' })
|
|
41
|
+
provider!: string
|
|
35
42
|
|
|
36
43
|
@Column({ nullable: true, comment: 'API Key', transformer: encryptTransformer })
|
|
37
44
|
@Field({ nullable: true, description: 'API Key' })
|
|
@@ -105,10 +112,6 @@ export class TaxInvoiceApi {
|
|
|
105
112
|
@Field({ nullable: true })
|
|
106
113
|
updatedAt?: Date
|
|
107
114
|
|
|
108
|
-
@DeleteDateColumn()
|
|
109
|
-
@Field({ nullable: true })
|
|
110
|
-
deletedAt?: Date
|
|
111
|
-
|
|
112
115
|
@ManyToOne(type => User, { nullable: true })
|
|
113
116
|
@Field(type => User, { nullable: true })
|
|
114
117
|
creator?: User
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx } from 'type-graphql'
|
|
2
2
|
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
3
3
|
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import { TaxInvoiceCompany
|
|
5
|
-
import { TaxInvoiceCompanyList } from './tax-invoice-company-type'
|
|
4
|
+
import { TaxInvoiceCompany } from './tax-invoice-company'
|
|
5
|
+
import { TaxInvoiceCompanyList, TaxInvoiceMyCompany } from './tax-invoice-company-type'
|
|
6
|
+
import { TaxInvoiceApi } from '../tax-invoice-api/tax-invoice-api'
|
|
6
7
|
|
|
7
8
|
@Resolver(TaxInvoiceCompany)
|
|
8
9
|
export class TaxInvoiceCompanyQuery {
|
|
@@ -16,7 +17,10 @@ export class TaxInvoiceCompanyQuery {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
@Query(returns => TaxInvoiceCompanyList, { description: 'To fetch multiple Tax Invoice Companies' })
|
|
19
|
-
async taxInvoiceCompanies(
|
|
20
|
+
async taxInvoiceCompanies(
|
|
21
|
+
@Args(type => ListParam) params: ListParam,
|
|
22
|
+
@Ctx() context: ResolverContext
|
|
23
|
+
): Promise<TaxInvoiceCompanyList> {
|
|
20
24
|
const { domain } = context.state
|
|
21
25
|
|
|
22
26
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
@@ -31,9 +35,38 @@ export class TaxInvoiceCompanyQuery {
|
|
|
31
35
|
return { items, total }
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
// 프로젝트 마다 구현 (기본 공급자 정보를 리턴하는 리졸버)
|
|
39
|
+
@Query(returns => TaxInvoiceMyCompany, { nullable: true, description: 'To fetch a Tax Invoice My Company' })
|
|
40
|
+
async taxInvoiceDefaultCompany(@Ctx() context: ResolverContext): Promise<TaxInvoiceMyCompany> {
|
|
41
|
+
const { domain } = context.state
|
|
42
|
+
const taxInvoiceApi = await getRepository(TaxInvoiceApi).findOne({
|
|
43
|
+
where: { domain: { id: domain.id }, isDefault: true }
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const taxInvoiceCompany: TaxInvoiceMyCompany = { ...taxInvoiceApi }
|
|
47
|
+
|
|
48
|
+
return taxInvoiceCompany
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Query(returns => TaxInvoiceMyCompany, { nullable: true, description: 'To fetch a Tax Invoice My Companies' })
|
|
52
|
+
async taxInvoiceMyCompanies(@Ctx() context: ResolverContext): Promise<TaxInvoiceMyCompany> {
|
|
53
|
+
const { domain } = context.state
|
|
54
|
+
const taxInvoiceApi = await getRepository(TaxInvoiceApi).find({
|
|
55
|
+
where: { domain: { id: domain.id } }
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Query(returns => [TaxInvoiceCompany], { nullable: true, description: 'To fetch a Tax Invoice Buyer List' })
|
|
62
|
+
async taxInvoiceBuyerList(@Ctx() context: ResolverContext): Promise<TaxInvoiceCompany[]> {
|
|
63
|
+
const { domain } = context.state
|
|
64
|
+
|
|
65
|
+
const taxInvoiceCompanyList = await getRepository(TaxInvoiceCompany).find({
|
|
66
|
+
where: { domain: { id: domain.id } }
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return taxInvoiceCompanyList
|
|
37
70
|
}
|
|
38
71
|
|
|
39
72
|
@FieldResolver(type => Domain)
|