@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.
- package/client/bootstrap.ts +1 -0
- package/client/index.ts +0 -0
- package/client/pages/main.ts +25 -0
- package/client/pages/tax-audit-result/tax-audit-result-importer.ts +87 -0
- package/client/pages/tax-audit-result/tax-audit-result-list-page.ts +331 -0
- package/client/pages/tax-invoice/tax-invoice-detail-popup.ts +454 -0
- package/client/pages/tax-invoice/tax-invoice-list-page.ts +525 -0
- package/client/pages/tax-invoice-api/tax-invoice-api-page.ts +418 -0
- package/client/pages/tax-invoice-company/tax-invoice-company-list-page.ts +447 -0
- package/client/pages/tax-invoice-send/company-list-popup.ts +188 -0
- package/client/pages/tax-invoice-send/tax-invoice-send-page.ts +196 -0
- package/client/pages/tax-invoice-send/tax-invoice-send.ts +1181 -0
- package/client/route.ts +23 -0
- package/client/tsconfig.json +11 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/server/index.ts +2 -0
- package/server/routes.ts +28 -0
- package/server/service/index.ts +37 -0
- package/server/service/tax-audit-result/event-subscriber.ts +17 -0
- package/server/service/tax-audit-result/index.ts +9 -0
- package/server/service/tax-audit-result/tax-audit-result-history.ts +120 -0
- package/server/service/tax-audit-result/tax-audit-result-mutation.ts +198 -0
- package/server/service/tax-audit-result/tax-audit-result-query.ts +65 -0
- package/server/service/tax-audit-result/tax-audit-result-type.ts +61 -0
- package/server/service/tax-audit-result/tax-audit-result.ts +99 -0
- package/server/service/tax-invoice/index.ts +6 -0
- package/server/service/tax-invoice/tax-invoice-mutation.ts +138 -0
- package/server/service/tax-invoice/tax-invoice-query.ts +99 -0
- package/server/service/tax-invoice/tax-invoice-type.ts +236 -0
- package/server/service/tax-invoice/tax-invoice-util.ts +224 -0
- package/server/service/tax-invoice/tax-invoice.ts +393 -0
- package/server/service/tax-invoice-api/index.ts +6 -0
- package/server/service/tax-invoice-api/tax-invoice-api-mutation.ts +275 -0
- package/server/service/tax-invoice-api/tax-invoice-api-query.ts +40 -0
- package/server/service/tax-invoice-api/tax-invoice-api-type.ts +83 -0
- package/server/service/tax-invoice-api/tax-invoice-api.ts +128 -0
- package/server/service/tax-invoice-company/index.ts +6 -0
- package/server/service/tax-invoice-company/tax-invoice-company-mutation.ts +84 -0
- package/server/service/tax-invoice-company/tax-invoice-company-query.ts +86 -0
- package/server/service/tax-invoice-company/tax-invoice-company-type.ts +105 -0
- package/server/service/tax-invoice-company/tax-invoice-company.ts +128 -0
- package/server/service/tax-invoice-item/index.ts +6 -0
- package/server/service/tax-invoice-item/tax-invoice-item-mutation.ts +128 -0
- package/server/service/tax-invoice-item/tax-invoice-item-query.ts +60 -0
- package/server/service/tax-invoice-item/tax-invoice-item-type.ts +77 -0
- package/server/service/tax-invoice-item/tax-invoice-item.ts +95 -0
- package/server/service/unipost-api/tax-invoice-inquiry.ts +99 -0
- package/server/service/unipost-api/tax-invoice-send.ts +32 -0
- package/server/tsconfig.json +10 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
import { In } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { Category, TaxInvoice } from './tax-invoice'
|
|
5
|
+
import { NewTaxInvoice, TaxInvoicePatch } from './tax-invoice-type'
|
|
6
|
+
import { NewTaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item-type'
|
|
7
|
+
import { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'
|
|
8
|
+
import { TaxInvoiceApi } from '../tax-invoice-api/tax-invoice-api'
|
|
9
|
+
import { AttributeSet } from '@things-factory/shell/dist-server/service/attribute-set/attribute-set'
|
|
10
|
+
import { ConfirmData, UnipostTaxType, callTaxInvoiceConfirm, getTaxInvoiceByUniposApi } from '../unipost-api/tax-invoice-inquiry'
|
|
11
|
+
import { parseTaxInvoiceByUnipostFormat } from './tax-invoice-util'
|
|
12
|
+
|
|
13
|
+
@Resolver(TaxInvoice)
|
|
14
|
+
export class TaxInvoiceMutation {
|
|
15
|
+
@Directive('@transaction')
|
|
16
|
+
@Mutation(returns => TaxInvoice, { description: 'To create new TaxInvoice' })
|
|
17
|
+
async createTaxInvoice(
|
|
18
|
+
@Arg('taxInvoice') taxInvoice: NewTaxInvoice,
|
|
19
|
+
@Arg('taxInvoiceItems', () => [NewTaxInvoiceItem]) taxInvoiceItems: NewTaxInvoiceItem[],
|
|
20
|
+
@Ctx() context: ResolverContext
|
|
21
|
+
): Promise<TaxInvoice> {
|
|
22
|
+
const { domain, user, tx } = context.state
|
|
23
|
+
|
|
24
|
+
const newTaxInvoice = await tx.getRepository(TaxInvoice).save({
|
|
25
|
+
...taxInvoice,
|
|
26
|
+
domain,
|
|
27
|
+
creator: user,
|
|
28
|
+
updater: user
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// 아이템 저장
|
|
32
|
+
for (const item of taxInvoiceItems) {
|
|
33
|
+
await tx.getRepository(TaxInvoiceItem).save({ ...item, taxInvoice: newTaxInvoice, domain, creator: user })
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return newTaxInvoice
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 그리드에서 메모 수정용 으로만
|
|
40
|
+
@Directive('@transaction')
|
|
41
|
+
@Mutation(returns => [TaxInvoice], { description: "To modify multiple TaxInvoices' information" })
|
|
42
|
+
async updateMultipleTaxInvoice(@Arg('patches', type => [TaxInvoicePatch]) patches: TaxInvoicePatch[], @Ctx() context: ResolverContext): Promise<TaxInvoice[]> {
|
|
43
|
+
const { domain, user, tx } = context.state
|
|
44
|
+
|
|
45
|
+
let results = []
|
|
46
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
47
|
+
const taxInvoiceRepo = tx.getRepository(TaxInvoice)
|
|
48
|
+
|
|
49
|
+
if (_updateRecords.length > 0) {
|
|
50
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
51
|
+
const updateRecord = _updateRecords[i]
|
|
52
|
+
const taxInvoice = await taxInvoiceRepo.findOneBy({ id: updateRecord.id })
|
|
53
|
+
|
|
54
|
+
const result = await taxInvoiceRepo.save({
|
|
55
|
+
...taxInvoice,
|
|
56
|
+
...updateRecord,
|
|
57
|
+
updater: user
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
results.push({ ...result, cuFlag: 'M' })
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return results
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Directive('@transaction')
|
|
68
|
+
@Mutation(returns => Boolean, { description: 'To delete TaxInvoice' })
|
|
69
|
+
async deleteTaxInvoice(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
70
|
+
const { domain, tx } = context.state
|
|
71
|
+
|
|
72
|
+
await tx.getRepository(TaxInvoice).delete({ domain: { id: domain.id }, id })
|
|
73
|
+
|
|
74
|
+
return true
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Directive('@transaction')
|
|
78
|
+
@Mutation(returns => Boolean, { description: 'To delete multiple TaxInvoices' })
|
|
79
|
+
async deleteTaxInvoices(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
|
|
80
|
+
const { domain, tx } = context.state
|
|
81
|
+
|
|
82
|
+
await tx.getRepository(TaxInvoice).delete({
|
|
83
|
+
domain: { id: domain.id },
|
|
84
|
+
id: In(ids)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Directive('@transaction')
|
|
91
|
+
@Mutation(returns => Boolean, { description: 'create tax invoice data by API' })
|
|
92
|
+
async fetchTaxInvoiceByApi(@Ctx() context: ResolverContext): Promise<boolean> {
|
|
93
|
+
const { domain, user, tx } = context.state
|
|
94
|
+
const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)
|
|
95
|
+
const taxInvoiceRepo = tx.getRepository(TaxInvoice)
|
|
96
|
+
const insertedData: ConfirmData[] = [] // API 호출 후 결과 회신용
|
|
97
|
+
|
|
98
|
+
const apiInfo = (await taxInvoiceApiRepo.find()).at(0)
|
|
99
|
+
const businessRegistrationNumber = apiInfo.businessRegistrationNumber
|
|
100
|
+
const { aid = '', bearer = '' } = apiInfo?.attributes
|
|
101
|
+
|
|
102
|
+
// API 호출하여 세금계산서 데이터 가져옴
|
|
103
|
+
const { issueNoList, taxList } = await getTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer)
|
|
104
|
+
|
|
105
|
+
// 이미 있는 데이터 아이디 검색
|
|
106
|
+
const existingTaxInvoice = await taxInvoiceRepo.find({
|
|
107
|
+
select: ['issueNo'],
|
|
108
|
+
where: { issueNo: In(issueNoList) }
|
|
109
|
+
})
|
|
110
|
+
const existingIds = existingTaxInvoice.map(taxInvoice => taxInvoice.issueNo)
|
|
111
|
+
|
|
112
|
+
// 매입, 매출 for문
|
|
113
|
+
for (let tax of taxList) {
|
|
114
|
+
// 있는지 없는지 확인 (이미 있는 세금계산서는 패스)
|
|
115
|
+
if (existingIds.includes(tax.exd_id)) continue
|
|
116
|
+
|
|
117
|
+
// api로 받은 데이터를 DB 형태로 파싱
|
|
118
|
+
const { taxInvoice, taxInvoiceItems } = parseTaxInvoiceByUnipostFormat(tax, tax.tAliceItemList, tax.category)
|
|
119
|
+
|
|
120
|
+
// Insert
|
|
121
|
+
this.createTaxInvoice(taxInvoice, taxInvoiceItems, context)
|
|
122
|
+
|
|
123
|
+
// API 결과 회신 데이터 생성
|
|
124
|
+
insertedData.push({
|
|
125
|
+
aid: aid,
|
|
126
|
+
tax_type: tax.category == Category.EXPORT ? UnipostTaxType.EXPORT : UnipostTaxType.IMPORT,
|
|
127
|
+
tid_issueid: tax.tid_issueid,
|
|
128
|
+
success: true,
|
|
129
|
+
message: ''
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 유니 포스트에 조회 후 결과 회신 API 호출
|
|
134
|
+
callTaxInvoiceConfirm(businessRegistrationNumber, aid, bearer, insertedData)
|
|
135
|
+
|
|
136
|
+
return true
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx } from 'type-graphql'
|
|
2
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { Category, Purpose, TaxInvoice } from './tax-invoice'
|
|
5
|
+
import { TaxInvoiceList, TaxInvoiceSummary } from './tax-invoice-type'
|
|
6
|
+
import { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'
|
|
7
|
+
|
|
8
|
+
@Resolver(TaxInvoice)
|
|
9
|
+
export class TaxInvoiceQuery {
|
|
10
|
+
@Query(returns => TaxInvoice!, { nullable: true, description: 'To fetch a TaxInvoice' })
|
|
11
|
+
async taxInvoice(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<TaxInvoice> {
|
|
12
|
+
const { domain } = context.state
|
|
13
|
+
|
|
14
|
+
return await getRepository(TaxInvoice).findOne({
|
|
15
|
+
where: { domain: { id: domain.id }, id }
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Query(returns => TaxInvoiceList, { description: 'To fetch multiple TaxInvoices' })
|
|
20
|
+
async taxInvoices(
|
|
21
|
+
@Args(type => ListParam) params: ListParam,
|
|
22
|
+
@Ctx() context: ResolverContext
|
|
23
|
+
): Promise<TaxInvoiceList> {
|
|
24
|
+
const { domain } = context.state
|
|
25
|
+
|
|
26
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
27
|
+
domain,
|
|
28
|
+
params,
|
|
29
|
+
repository: await getRepository(TaxInvoice),
|
|
30
|
+
searchables: ['memo']
|
|
31
|
+
})
|
|
32
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
33
|
+
|
|
34
|
+
return { items, total }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Query(returns => TaxInvoiceSummary, { description: 'To fetch TaxInvoices Summary' })
|
|
38
|
+
async taxInvoicesSummary(
|
|
39
|
+
@Args(type => ListParam) params: ListParam,
|
|
40
|
+
@Ctx() context: ResolverContext
|
|
41
|
+
): Promise<TaxInvoiceSummary> {
|
|
42
|
+
const { domain } = context.state
|
|
43
|
+
let category = params.filters.filter(v => v.name === 'category')?.[0]?.value
|
|
44
|
+
|
|
45
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
46
|
+
domain,
|
|
47
|
+
params: { ...params, pagination: {} },
|
|
48
|
+
repository: await getRepository(TaxInvoice)
|
|
49
|
+
})
|
|
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()
|
|
76
|
+
|
|
77
|
+
return { summary }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@FieldResolver(type => [TaxInvoiceItem])
|
|
81
|
+
async taxInvoiceItems(@Root() taxInvoice: TaxInvoice): Promise<TaxInvoiceItem[]> {
|
|
82
|
+
return taxInvoice.id && (await getRepository(TaxInvoiceItem).findBy({ taxInvoice: { id: taxInvoice.id } }))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@FieldResolver(type => Domain)
|
|
86
|
+
async domain(@Root() taxInvoice: TaxInvoice): Promise<Domain> {
|
|
87
|
+
return taxInvoice.domainId && (await getRepository(Domain).findOneBy({ id: taxInvoice.domainId }))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@FieldResolver(type => User)
|
|
91
|
+
async updater(@Root() taxInvoice: TaxInvoice): Promise<User> {
|
|
92
|
+
return taxInvoice.updaterId && (await getRepository(User).findOneBy({ id: taxInvoice.updaterId }))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@FieldResolver(type => User)
|
|
96
|
+
async creator(@Root() taxInvoice: TaxInvoice): Promise<User> {
|
|
97
|
+
return taxInvoice.creatorId && (await getRepository(User).findOneBy({ id: taxInvoice.creatorId }))
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
|
|
2
|
+
import { BusinessRegistrationCategory, Category, InvoiceType, Purpose, RevisedReason, TaxInvoice } from './tax-invoice'
|
|
3
|
+
import { ScalarObject } from '@things-factory/shell'
|
|
4
|
+
|
|
5
|
+
@InputType()
|
|
6
|
+
export class NewTaxInvoice {
|
|
7
|
+
@Field({ nullable: true })
|
|
8
|
+
memo?: string
|
|
9
|
+
|
|
10
|
+
@Field({ nullable: true })
|
|
11
|
+
apiRefId?: string
|
|
12
|
+
|
|
13
|
+
@Field({ nullable: false })
|
|
14
|
+
category: Category
|
|
15
|
+
|
|
16
|
+
@Field({ nullable: true })
|
|
17
|
+
issueNo?: string
|
|
18
|
+
|
|
19
|
+
@Field({ nullable: true })
|
|
20
|
+
approvalNo?: string
|
|
21
|
+
|
|
22
|
+
@Field({ nullable: true })
|
|
23
|
+
originalApprovalNo?: string
|
|
24
|
+
|
|
25
|
+
@Field({ nullable: false })
|
|
26
|
+
issueDate: string
|
|
27
|
+
|
|
28
|
+
@Field({ nullable: true })
|
|
29
|
+
signatureDate: string
|
|
30
|
+
|
|
31
|
+
@Field({ nullable: false })
|
|
32
|
+
invoiceType: InvoiceType
|
|
33
|
+
|
|
34
|
+
@Field({ nullable: false })
|
|
35
|
+
purpose: Purpose
|
|
36
|
+
|
|
37
|
+
@Field({ nullable: true })
|
|
38
|
+
revisedReason?: RevisedReason
|
|
39
|
+
|
|
40
|
+
@Field({ nullable: true })
|
|
41
|
+
remark0?: string
|
|
42
|
+
|
|
43
|
+
@Field({ nullable: true })
|
|
44
|
+
remark1?: string
|
|
45
|
+
|
|
46
|
+
@Field({ nullable: true })
|
|
47
|
+
remark2?: string
|
|
48
|
+
|
|
49
|
+
@Field({ nullable: true })
|
|
50
|
+
isSentByApi?: boolean
|
|
51
|
+
|
|
52
|
+
@Field({ nullable: true })
|
|
53
|
+
supplierBusinessRegistrationCategory: BusinessRegistrationCategory
|
|
54
|
+
|
|
55
|
+
@Field({ nullable: false })
|
|
56
|
+
supplierBusinessRegistrationNumber: string
|
|
57
|
+
|
|
58
|
+
@Field({ nullable: true })
|
|
59
|
+
supplierBranchIdentification?: string
|
|
60
|
+
|
|
61
|
+
@Field({ nullable: false })
|
|
62
|
+
supplierBusinessName: string
|
|
63
|
+
|
|
64
|
+
@Field({ nullable: false })
|
|
65
|
+
supplierRepresentativeName: string
|
|
66
|
+
|
|
67
|
+
@Field({ nullable: true })
|
|
68
|
+
supplierAddress?: string
|
|
69
|
+
|
|
70
|
+
@Field({ nullable: true })
|
|
71
|
+
supplierBusinessType?: string
|
|
72
|
+
|
|
73
|
+
@Field({ nullable: true })
|
|
74
|
+
supplierIndustryType?: string
|
|
75
|
+
|
|
76
|
+
@Field({ nullable: true })
|
|
77
|
+
supplierDepartment?: string
|
|
78
|
+
|
|
79
|
+
@Field({ nullable: true })
|
|
80
|
+
supplierContactName?: string
|
|
81
|
+
|
|
82
|
+
@Field({ nullable: true })
|
|
83
|
+
supplierContactPhone?: string
|
|
84
|
+
|
|
85
|
+
@Field({ nullable: true })
|
|
86
|
+
supplierContactEmail?: string
|
|
87
|
+
|
|
88
|
+
@Field({ nullable: true })
|
|
89
|
+
supplierContactCellPhone?: string
|
|
90
|
+
|
|
91
|
+
@Field({ nullable: true })
|
|
92
|
+
buyerBusinessRegistrationCategory: BusinessRegistrationCategory
|
|
93
|
+
|
|
94
|
+
@Field({ nullable: false })
|
|
95
|
+
buyerBusinessRegistrationNumber: string
|
|
96
|
+
|
|
97
|
+
@Field({ nullable: true })
|
|
98
|
+
buyerBranchIdentification?: string
|
|
99
|
+
|
|
100
|
+
@Field({ nullable: false })
|
|
101
|
+
buyerBusinessName: string
|
|
102
|
+
|
|
103
|
+
@Field({ nullable: false })
|
|
104
|
+
buyerRepresentativeName: string
|
|
105
|
+
|
|
106
|
+
@Field({ nullable: true })
|
|
107
|
+
buyerAddress?: string
|
|
108
|
+
|
|
109
|
+
@Field({ nullable: true })
|
|
110
|
+
buyerBusinessType?: string
|
|
111
|
+
|
|
112
|
+
@Field({ nullable: true })
|
|
113
|
+
buyerIndustryType?: string
|
|
114
|
+
|
|
115
|
+
@Field({ nullable: true })
|
|
116
|
+
buyer1stDepartment?: string
|
|
117
|
+
|
|
118
|
+
@Field({ nullable: true })
|
|
119
|
+
buyer1stContactName?: string
|
|
120
|
+
|
|
121
|
+
@Field({ nullable: true })
|
|
122
|
+
buyer1stContactPhone?: string
|
|
123
|
+
|
|
124
|
+
@Field({ nullable: true })
|
|
125
|
+
buyer1stContactEmail?: string
|
|
126
|
+
|
|
127
|
+
@Field({ nullable: true })
|
|
128
|
+
buyer1stContactCellPhone?: string
|
|
129
|
+
|
|
130
|
+
@Field({ nullable: true })
|
|
131
|
+
buyer2ndDepartment?: string
|
|
132
|
+
|
|
133
|
+
@Field({ nullable: true })
|
|
134
|
+
buyer2ndContactName?: string
|
|
135
|
+
|
|
136
|
+
@Field({ nullable: true })
|
|
137
|
+
buyer2ndContactPhone?: string
|
|
138
|
+
|
|
139
|
+
@Field({ nullable: true })
|
|
140
|
+
buyer2ndContactEmail?: string
|
|
141
|
+
|
|
142
|
+
@Field({ nullable: true })
|
|
143
|
+
buyer2ndContactCellPhone?: string
|
|
144
|
+
|
|
145
|
+
@Field({ nullable: true })
|
|
146
|
+
agentBusinessRegistrationCategory?: BusinessRegistrationCategory
|
|
147
|
+
|
|
148
|
+
@Field({ nullable: true })
|
|
149
|
+
agentBusinessRegistrationNumber?: string
|
|
150
|
+
|
|
151
|
+
@Field({ nullable: true })
|
|
152
|
+
agentBranchIdentification?: string
|
|
153
|
+
|
|
154
|
+
@Field({ nullable: true })
|
|
155
|
+
agentBusinessName?: string
|
|
156
|
+
|
|
157
|
+
@Field({ nullable: true })
|
|
158
|
+
agentRepresentativeName?: string
|
|
159
|
+
|
|
160
|
+
@Field({ nullable: true })
|
|
161
|
+
agentAddress?: string
|
|
162
|
+
|
|
163
|
+
@Field({ nullable: true })
|
|
164
|
+
agentBusinessType?: string
|
|
165
|
+
|
|
166
|
+
@Field({ nullable: true })
|
|
167
|
+
agentIndustryType?: string
|
|
168
|
+
|
|
169
|
+
@Field({ nullable: true })
|
|
170
|
+
agentDepartment?: string
|
|
171
|
+
|
|
172
|
+
@Field({ nullable: true })
|
|
173
|
+
agentContactName?: string
|
|
174
|
+
|
|
175
|
+
@Field({ nullable: true })
|
|
176
|
+
agentContactPhone?: string
|
|
177
|
+
|
|
178
|
+
@Field({ nullable: true })
|
|
179
|
+
agentContactEmail?: string
|
|
180
|
+
|
|
181
|
+
@Field({ nullable: true })
|
|
182
|
+
agentContactCellPhone?: string
|
|
183
|
+
|
|
184
|
+
@Field(type => Int, { nullable: true })
|
|
185
|
+
paymentAmountCash?: number
|
|
186
|
+
|
|
187
|
+
@Field(type => Int, { nullable: true })
|
|
188
|
+
paymentAmountCheck?: number
|
|
189
|
+
|
|
190
|
+
@Field(type => Int, { nullable: true })
|
|
191
|
+
paymentAmountPromissoryNote?: number
|
|
192
|
+
|
|
193
|
+
@Field(type => Int, { nullable: true })
|
|
194
|
+
paymentAmountAccountsReceivable?: number
|
|
195
|
+
|
|
196
|
+
@Field(type => Int, { nullable: false })
|
|
197
|
+
supplyAmount: number
|
|
198
|
+
|
|
199
|
+
@Field(type => Int, { nullable: true })
|
|
200
|
+
taxAmount: number
|
|
201
|
+
|
|
202
|
+
@Field(type => Int, { nullable: false })
|
|
203
|
+
totalAmount: number
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@InputType()
|
|
207
|
+
export class TaxInvoicePatch {
|
|
208
|
+
@Field(type => ID, { nullable: false })
|
|
209
|
+
id?: string
|
|
210
|
+
|
|
211
|
+
@Field({ nullable: true })
|
|
212
|
+
memo?: string
|
|
213
|
+
|
|
214
|
+
@Field({ nullable: true })
|
|
215
|
+
cuFlag?: string
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@ObjectType()
|
|
219
|
+
export class TaxInvoiceList {
|
|
220
|
+
@Field(type => [TaxInvoice])
|
|
221
|
+
items: TaxInvoice[]
|
|
222
|
+
|
|
223
|
+
@Field(type => Int)
|
|
224
|
+
total: number
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@ObjectType()
|
|
228
|
+
export class TaxInvoiceSummary {
|
|
229
|
+
@Field(type => ScalarObject)
|
|
230
|
+
summary: {
|
|
231
|
+
supply_amount: number
|
|
232
|
+
tax_amount: number
|
|
233
|
+
total_amount: number
|
|
234
|
+
cnt: number
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { NewTaxInvoiceItem } from 'service/tax-invoice-item/tax-invoice-item-type'
|
|
2
|
+
import { NewTaxInvoice } from './tax-invoice-type'
|
|
3
|
+
import { BusinessRegistrationCategory, Category, InvoiceType, Purpose, RevisedReason } from './tax-invoice'
|
|
4
|
+
|
|
5
|
+
interface UnipostTaxInvoice {
|
|
6
|
+
offset?: string
|
|
7
|
+
limit?: string
|
|
8
|
+
aid?: string
|
|
9
|
+
exd_id?: string
|
|
10
|
+
exd_refdoc_id?: string
|
|
11
|
+
exd_issuedatetime?: string
|
|
12
|
+
exd_issuedatetime_format?: string
|
|
13
|
+
tid_issueid?: string
|
|
14
|
+
tid_issuedatetime?: string
|
|
15
|
+
tid_issuedatetime_format?: string
|
|
16
|
+
tid_typecode?: InvoiceType
|
|
17
|
+
tid_typecode_desc?: string
|
|
18
|
+
tid_purposecode?: Purpose
|
|
19
|
+
tid_purposecode_desc?: string
|
|
20
|
+
tid_amendcode?: RevisedReason
|
|
21
|
+
tid_amendcode_desc?: string
|
|
22
|
+
tid_originalissueid?: string
|
|
23
|
+
tid_desc0?: string
|
|
24
|
+
tid_desc1?: string
|
|
25
|
+
tid_desc2?: string
|
|
26
|
+
tid_refimpdoc_id?: string
|
|
27
|
+
tid_refimpdoc_itemquantity?: string
|
|
28
|
+
tid_refimpdoc_accept_sdate?: string
|
|
29
|
+
tid_refimpdoc_accept_edate?: string
|
|
30
|
+
tit_alice_specorg_biztypecode?: BusinessRegistrationCategory
|
|
31
|
+
tit_alice_id?: string
|
|
32
|
+
tit_alice_specorg_taxregid?: string
|
|
33
|
+
tit_alice_name?: string
|
|
34
|
+
tit_alice_specperson_name?: string
|
|
35
|
+
tit_alice_specaddr_lineone?: string
|
|
36
|
+
tit_alice_typecode?: string
|
|
37
|
+
tit_alice_classcode?: string
|
|
38
|
+
tit_alice_defcont_deptname?: string
|
|
39
|
+
tit_alice_defcont_personname?: string
|
|
40
|
+
tit_alice_defcont_telcomm?: string
|
|
41
|
+
tit_alice_defcont_uricomm?: string
|
|
42
|
+
tit_alice_defcont_cellphone?: string
|
|
43
|
+
tit_bob_specorg_biztypecode?: BusinessRegistrationCategory
|
|
44
|
+
tit_bob_id?: string
|
|
45
|
+
tit_bob_specorg_taxregid?: string
|
|
46
|
+
tit_bob_name?: string
|
|
47
|
+
tit_bob_specperson_name?: string
|
|
48
|
+
tit_bob_specaddr_lineone?: string
|
|
49
|
+
tit_bob_typecode?: string
|
|
50
|
+
tit_bob_classcode?: string
|
|
51
|
+
tit_bob_1stdefcont_deptname?: string
|
|
52
|
+
tit_bob_1stdefcont_personname?: string
|
|
53
|
+
tit_bob_1stdefcont_telcomm?: string
|
|
54
|
+
tit_bob_1stdefcont_uricomm?: string
|
|
55
|
+
tit_bob_1stdefcont_cellphone?: string
|
|
56
|
+
tit_bob_2nddefcont_deptname?: string
|
|
57
|
+
tit_bob_2nddefcont_personname?: string
|
|
58
|
+
tit_bob_2nddefcont_telcomm?: string
|
|
59
|
+
tit_bob_2nddefcont_uricomm?: string
|
|
60
|
+
tit_bob_2nddefcont_cellphone?: string
|
|
61
|
+
tit_broker_specorg_biztypecode?: BusinessRegistrationCategory
|
|
62
|
+
tit_broker_id?: string
|
|
63
|
+
tit_broker_specorg_taxregid?: string
|
|
64
|
+
tit_broker_name?: string
|
|
65
|
+
tit_broker_specperson_name?: string
|
|
66
|
+
tit_broker_specaddr_lineone?: string
|
|
67
|
+
tit_broker_typecode?: string
|
|
68
|
+
tit_broker_classcode?: string
|
|
69
|
+
tit_broker_defcont_deptname?: string
|
|
70
|
+
tit_broker_defcont_personname?: string
|
|
71
|
+
tit_broker_defcont_telcomm?: string
|
|
72
|
+
tit_broker_defcont_uricomm?: string
|
|
73
|
+
tit_broker_defcont_cellphone?: string
|
|
74
|
+
tit_specpay_paidamount10?: number
|
|
75
|
+
tit_specpay_paidamount20?: number
|
|
76
|
+
tit_specpay_paidamount30?: number
|
|
77
|
+
tit_specpay_paidamount40?: number
|
|
78
|
+
tit_specpay_paidamount10_format?: string
|
|
79
|
+
tit_specpay_paidamount20_format?: string
|
|
80
|
+
tit_specpay_paidamount30_format?: string
|
|
81
|
+
tit_specpay_paidamount40_format?: string
|
|
82
|
+
tit_specsum_chargeamount?: number
|
|
83
|
+
tit_specsum_taxamount?: number
|
|
84
|
+
tit_specsum_grandamount?: number
|
|
85
|
+
tit_specsum_chargeamount_format?: string
|
|
86
|
+
tit_specsum_taxamount_format?: string
|
|
87
|
+
tit_specsum_grandamount_format?: string
|
|
88
|
+
biz_tocharlesconfirmstatus?: string
|
|
89
|
+
inv_sign?: string
|
|
90
|
+
mbill_send_status?: string
|
|
91
|
+
erp_sync_yn?: string
|
|
92
|
+
prt_yn?: string
|
|
93
|
+
prt_yn_desc?: string
|
|
94
|
+
inv_seq?: string
|
|
95
|
+
view_date?: string
|
|
96
|
+
reg_date?: string
|
|
97
|
+
sot_yn?: string
|
|
98
|
+
table_alias?: string
|
|
99
|
+
biz_no?: string
|
|
100
|
+
tAliceItemList?: Array<any>
|
|
101
|
+
tcTrItemList?: Array<any>
|
|
102
|
+
tAliceFileList?: Array<any>
|
|
103
|
+
tAliceDSig?: Object
|
|
104
|
+
tAliceStat?: Object
|
|
105
|
+
biz_tocharlesconfirmstatus_desc?: string
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface UnipostTaxInvoiceItem {
|
|
109
|
+
offset?: number
|
|
110
|
+
limit?: number
|
|
111
|
+
aid?: string
|
|
112
|
+
exd_id?: string
|
|
113
|
+
tii_seqnumeric?: number
|
|
114
|
+
tii_purchaseexpirydatetime?: string
|
|
115
|
+
tii_purchaseexpirydatetime_format?: string
|
|
116
|
+
tii_purchaseexpirydatetime_format_month?: string
|
|
117
|
+
tii_purchaseexpirydatetime_format_day?: string
|
|
118
|
+
tii_nametext?: string
|
|
119
|
+
tii_informationtext?: string
|
|
120
|
+
tii_chargeableunitquantity?: number
|
|
121
|
+
tii_chargeableunitquantity_format?: string
|
|
122
|
+
tii_chargeableunittext?: string
|
|
123
|
+
tii_unitprice_unitamount?: number
|
|
124
|
+
tii_unitprice_unitamount_format?: string
|
|
125
|
+
tii_invoiceamount?: number
|
|
126
|
+
tii_invoiceamount_format?: string
|
|
127
|
+
tii_totaltax_calcamount?: number
|
|
128
|
+
tii_totaltax_calcamount_format?: string
|
|
129
|
+
tii_descriptiontext?: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 유니포스트 데이터 포맷을 DB에 넣을수 있는 포맷으로 변경
|
|
133
|
+
export function parseTaxInvoiceByUnipostFormat(unipostTaxInvoice: UnipostTaxInvoice, unipostTaxInvoiceItems: UnipostTaxInvoiceItem[], category: Category) {
|
|
134
|
+
let taxInvoice: NewTaxInvoice
|
|
135
|
+
let taxInvoiceItems: NewTaxInvoiceItem[]
|
|
136
|
+
|
|
137
|
+
// 한개 라도 없으면 전부 빈값으로 리턴
|
|
138
|
+
if (!unipostTaxInvoice || !unipostTaxInvoiceItems) return { taxInvoice, taxInvoiceItems }
|
|
139
|
+
|
|
140
|
+
// exd_issuedatetime 이 두개는 조회 API에서는 yyyymmdd 로 오지만 발행에서는 yyyymmddhhmmss로 옴
|
|
141
|
+
taxInvoice = {
|
|
142
|
+
issueNo: unipostTaxInvoice.exd_id,
|
|
143
|
+
approvalNo: unipostTaxInvoice.tid_issueid,
|
|
144
|
+
originalApprovalNo: unipostTaxInvoice.tid_originalissueid,
|
|
145
|
+
issueDate: _dateFormat(unipostTaxInvoice.tid_issuedatetime),
|
|
146
|
+
signatureDate: _dateFormat(unipostTaxInvoice.exd_issuedatetime.substring(0, 8)),
|
|
147
|
+
invoiceType: unipostTaxInvoice.tid_typecode,
|
|
148
|
+
purpose: unipostTaxInvoice.tid_purposecode,
|
|
149
|
+
revisedReason: unipostTaxInvoice.tid_amendcode,
|
|
150
|
+
remark0: unipostTaxInvoice.tid_desc0,
|
|
151
|
+
remark1: unipostTaxInvoice.tid_desc1,
|
|
152
|
+
remark2: unipostTaxInvoice.tid_desc2,
|
|
153
|
+
isSentByApi: true,
|
|
154
|
+
category: category,
|
|
155
|
+
supplierBusinessRegistrationCategory: unipostTaxInvoice.tit_alice_specorg_biztypecode,
|
|
156
|
+
supplierBusinessRegistrationNumber: unipostTaxInvoice.tit_alice_id,
|
|
157
|
+
supplierBranchIdentification: unipostTaxInvoice.tit_alice_specorg_taxregid,
|
|
158
|
+
supplierBusinessName: unipostTaxInvoice.tit_alice_name,
|
|
159
|
+
supplierRepresentativeName: unipostTaxInvoice.tit_alice_specperson_name,
|
|
160
|
+
supplierAddress: unipostTaxInvoice.tit_alice_specaddr_lineone,
|
|
161
|
+
supplierBusinessType: unipostTaxInvoice.tit_alice_typecode,
|
|
162
|
+
supplierIndustryType: unipostTaxInvoice.tit_alice_classcode,
|
|
163
|
+
supplierDepartment: unipostTaxInvoice.tit_alice_defcont_deptname,
|
|
164
|
+
supplierContactName: unipostTaxInvoice.tit_alice_defcont_personname,
|
|
165
|
+
supplierContactPhone: unipostTaxInvoice.tit_alice_defcont_telcomm,
|
|
166
|
+
supplierContactEmail: unipostTaxInvoice.tit_alice_defcont_uricomm,
|
|
167
|
+
supplierContactCellPhone: unipostTaxInvoice.tit_alice_defcont_cellphone,
|
|
168
|
+
buyerBusinessRegistrationCategory: unipostTaxInvoice.tit_bob_specorg_biztypecode,
|
|
169
|
+
buyerBusinessRegistrationNumber: unipostTaxInvoice.tit_bob_id,
|
|
170
|
+
buyerBranchIdentification: unipostTaxInvoice.tit_bob_specorg_taxregid,
|
|
171
|
+
buyerBusinessName: unipostTaxInvoice.tit_bob_name,
|
|
172
|
+
buyerRepresentativeName: unipostTaxInvoice.tit_bob_specperson_name,
|
|
173
|
+
buyerAddress: unipostTaxInvoice.tit_bob_specaddr_lineone,
|
|
174
|
+
buyerBusinessType: unipostTaxInvoice.tit_bob_typecode,
|
|
175
|
+
buyerIndustryType: unipostTaxInvoice.tit_bob_classcode,
|
|
176
|
+
buyer1stDepartment: unipostTaxInvoice.tit_bob_1stdefcont_deptname,
|
|
177
|
+
buyer1stContactName: unipostTaxInvoice.tit_bob_1stdefcont_personname,
|
|
178
|
+
buyer1stContactPhone: unipostTaxInvoice.tit_bob_1stdefcont_telcomm,
|
|
179
|
+
buyer1stContactEmail: unipostTaxInvoice.tit_bob_1stdefcont_uricomm,
|
|
180
|
+
buyer1stContactCellPhone: unipostTaxInvoice.tit_bob_1stdefcont_cellphone,
|
|
181
|
+
buyer2ndDepartment: unipostTaxInvoice.tit_bob_2nddefcont_deptname,
|
|
182
|
+
buyer2ndContactName: unipostTaxInvoice.tit_bob_2nddefcont_personname,
|
|
183
|
+
buyer2ndContactPhone: unipostTaxInvoice.tit_bob_2nddefcont_telcomm,
|
|
184
|
+
buyer2ndContactEmail: unipostTaxInvoice.tit_bob_2nddefcont_uricomm,
|
|
185
|
+
buyer2ndContactCellPhone: unipostTaxInvoice.tit_bob_2nddefcont_cellphone,
|
|
186
|
+
agentBusinessRegistrationCategory: unipostTaxInvoice.tit_broker_specorg_biztypecode,
|
|
187
|
+
agentBusinessRegistrationNumber: unipostTaxInvoice.tit_broker_id,
|
|
188
|
+
agentBranchIdentification: unipostTaxInvoice.tit_broker_specorg_taxregid,
|
|
189
|
+
agentBusinessName: unipostTaxInvoice.tit_broker_name,
|
|
190
|
+
agentRepresentativeName: unipostTaxInvoice.tit_broker_specperson_name,
|
|
191
|
+
agentAddress: unipostTaxInvoice.tit_broker_specaddr_lineone,
|
|
192
|
+
agentBusinessType: unipostTaxInvoice.tit_broker_typecode,
|
|
193
|
+
agentIndustryType: unipostTaxInvoice.tit_broker_classcode,
|
|
194
|
+
agentDepartment: unipostTaxInvoice.tit_broker_defcont_deptname,
|
|
195
|
+
agentContactName: unipostTaxInvoice.tit_broker_defcont_personname,
|
|
196
|
+
agentContactPhone: unipostTaxInvoice.tit_broker_defcont_telcomm,
|
|
197
|
+
agentContactEmail: unipostTaxInvoice.tit_broker_defcont_uricomm,
|
|
198
|
+
agentContactCellPhone: unipostTaxInvoice.tit_broker_defcont_cellphone,
|
|
199
|
+
paymentAmountCash: unipostTaxInvoice.tit_specpay_paidamount10,
|
|
200
|
+
paymentAmountCheck: unipostTaxInvoice.tit_specpay_paidamount20,
|
|
201
|
+
paymentAmountPromissoryNote: unipostTaxInvoice.tit_specpay_paidamount30,
|
|
202
|
+
paymentAmountAccountsReceivable: unipostTaxInvoice.tit_specpay_paidamount40,
|
|
203
|
+
supplyAmount: unipostTaxInvoice.tit_specsum_chargeamount,
|
|
204
|
+
taxAmount: unipostTaxInvoice.tit_specsum_taxamount,
|
|
205
|
+
totalAmount: unipostTaxInvoice.tit_specsum_grandamount
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
taxInvoiceItems = unipostTaxInvoiceItems.map(item => ({
|
|
209
|
+
sequence: item.tii_seqnumeric,
|
|
210
|
+
supplyDate: _dateFormat(item.tii_purchaseexpirydatetime),
|
|
211
|
+
itemName: item.tii_nametext,
|
|
212
|
+
specification: item.tii_informationtext,
|
|
213
|
+
quantity: item.tii_chargeableunitquantity,
|
|
214
|
+
unitPrice: item.tii_unitprice_unitamount,
|
|
215
|
+
supplyPrice: item.tii_invoiceamount,
|
|
216
|
+
taxPrice: item.tii_totaltax_calcamount,
|
|
217
|
+
remark: item.tii_descriptiontext
|
|
218
|
+
}))
|
|
219
|
+
|
|
220
|
+
return { taxInvoice, taxInvoiceItems }
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// YYYYMMDD => YYYY-MM-DD
|
|
224
|
+
const _dateFormat = date => date.replace(/(\d{4})(\d{2})(\d{2})/g, '$1-$2-$3')
|