@things-factory/sales-base 8.0.2 → 8.0.5

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 (178) hide show
  1. package/dist-server/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +12 -12
  3. package/server/constants/attachment-type.ts +0 -9
  4. package/server/constants/index.ts +0 -7
  5. package/server/constants/load-type.ts +0 -4
  6. package/server/constants/order.ts +0 -203
  7. package/server/constants/product-group-type.ts +0 -4
  8. package/server/constants/release-good.ts +0 -9
  9. package/server/constants/transfer-order-type.ts +0 -6
  10. package/server/constants/validation-error-code.ts +0 -3
  11. package/server/constants/vas-target-type.ts +0 -25
  12. package/server/controllers/ecommerce/ecommerce-controller.ts +0 -122
  13. package/server/controllers/ecommerce/index.ts +0 -2
  14. package/server/controllers/ecommerce/sellercraft-controller.ts +0 -182
  15. package/server/controllers/index.ts +0 -2
  16. package/server/controllers/order-controller.ts +0 -296
  17. package/server/errors/index.ts +0 -1
  18. package/server/errors/validation-error.ts +0 -25
  19. package/server/index.ts +0 -5
  20. package/server/migrations/index.ts +0 -9
  21. package/server/service/arrival-notice/arrival-notice-mutation.ts +0 -1152
  22. package/server/service/arrival-notice/arrival-notice-query.ts +0 -549
  23. package/server/service/arrival-notice/arrival-notice-types.ts +0 -310
  24. package/server/service/arrival-notice/arrival-notice.ts +0 -202
  25. package/server/service/arrival-notice/index.ts +0 -9
  26. package/server/service/claim/claim-mutation.ts +0 -308
  27. package/server/service/claim/claim-query.ts +0 -122
  28. package/server/service/claim/claim-types.ts +0 -130
  29. package/server/service/claim/claim.ts +0 -140
  30. package/server/service/claim/index.ts +0 -9
  31. package/server/service/claim-detail/claim-detail-mutation.ts +0 -102
  32. package/server/service/claim-detail/claim-detail-query.ts +0 -55
  33. package/server/service/claim-detail/claim-detail-types.ts +0 -47
  34. package/server/service/claim-detail/claim-detail.ts +0 -69
  35. package/server/service/claim-detail/index.ts +0 -9
  36. package/server/service/claim-order/claim-order-mutation.ts +0 -101
  37. package/server/service/claim-order/claim-order-query.ts +0 -47
  38. package/server/service/claim-order/claim-order-types.ts +0 -35
  39. package/server/service/claim-order/claim-order.ts +0 -81
  40. package/server/service/claim-order/index.ts +0 -9
  41. package/server/service/collection-order/collection-order-mutation.ts +0 -245
  42. package/server/service/collection-order/collection-order-query.ts +0 -97
  43. package/server/service/collection-order/collection-order-types.ts +0 -165
  44. package/server/service/collection-order/collection-order.ts +0 -135
  45. package/server/service/collection-order/index.ts +0 -9
  46. package/server/service/delivery-order/delivery-order-mutation.ts +0 -967
  47. package/server/service/delivery-order/delivery-order-query.ts +0 -631
  48. package/server/service/delivery-order/delivery-order-types.ts +0 -268
  49. package/server/service/delivery-order/delivery-order.ts +0 -258
  50. package/server/service/delivery-order/index.ts +0 -9
  51. package/server/service/draft-release-good/draft-release-good-mutation.ts +0 -765
  52. package/server/service/draft-release-good/draft-release-good-query.ts +0 -354
  53. package/server/service/draft-release-good/draft-release-good-type.ts +0 -261
  54. package/server/service/draft-release-good/draft-release-good.ts +0 -284
  55. package/server/service/draft-release-good/index.ts +0 -9
  56. package/server/service/goods-receival-note/goods-receival-note-mutation.ts +0 -129
  57. package/server/service/goods-receival-note/goods-receival-note-query.ts +0 -280
  58. package/server/service/goods-receival-note/goods-receival-note-types.ts +0 -105
  59. package/server/service/goods-receival-note/goods-receival-note.ts +0 -127
  60. package/server/service/goods-receival-note/index.ts +0 -9
  61. package/server/service/index.ts +0 -238
  62. package/server/service/inventory-check/index.ts +0 -9
  63. package/server/service/inventory-check/inventory-check-mutation.ts +0 -149
  64. package/server/service/inventory-check/inventory-check-query.ts +0 -48
  65. package/server/service/inventory-check/inventory-check-types.ts +0 -48
  66. package/server/service/inventory-check/inventory-check.ts +0 -90
  67. package/server/service/invoice/index.ts +0 -9
  68. package/server/service/invoice/invoice-mutation.ts +0 -95
  69. package/server/service/invoice/invoice-query.ts +0 -53
  70. package/server/service/invoice/invoice-types.ts +0 -279
  71. package/server/service/invoice/invoice.ts +0 -230
  72. package/server/service/invoice-product/index.ts +0 -9
  73. package/server/service/invoice-product/invoice-product-mutation.ts +0 -54
  74. package/server/service/invoice-product/invoice-product-query.ts +0 -54
  75. package/server/service/invoice-product/invoice-product-types.ts +0 -84
  76. package/server/service/invoice-product/invoice-product.ts +0 -92
  77. package/server/service/job-sheet/index.ts +0 -9
  78. package/server/service/job-sheet/job-sheet-mutation.ts +0 -92
  79. package/server/service/job-sheet/job-sheet-query.ts +0 -112
  80. package/server/service/job-sheet/job-sheet-types.ts +0 -78
  81. package/server/service/job-sheet/job-sheet.ts +0 -102
  82. package/server/service/manifest/index.ts +0 -6
  83. package/server/service/manifest/manifest-mutation.ts +0 -190
  84. package/server/service/manifest/manifest-query.ts +0 -149
  85. package/server/service/manifest/manifest-type.ts +0 -84
  86. package/server/service/manifest/manifest.ts +0 -114
  87. package/server/service/order-inventory/index.ts +0 -9
  88. package/server/service/order-inventory/order-inventory-mutation.ts +0 -54
  89. package/server/service/order-inventory/order-inventory-query.ts +0 -722
  90. package/server/service/order-inventory/order-inventory-types.ts +0 -238
  91. package/server/service/order-inventory/order-inventory.ts +0 -401
  92. package/server/service/order-product/index.ts +0 -9
  93. package/server/service/order-product/order-product-mutation.ts +0 -48
  94. package/server/service/order-product/order-product-query.ts +0 -89
  95. package/server/service/order-product/order-product-types.ts +0 -335
  96. package/server/service/order-product/order-product.ts +0 -362
  97. package/server/service/order-tote/index.ts +0 -9
  98. package/server/service/order-tote/order-tote-mutation.ts +0 -31
  99. package/server/service/order-tote/order-tote-query.ts +0 -112
  100. package/server/service/order-tote/order-tote-types.ts +0 -47
  101. package/server/service/order-tote/order-tote.ts +0 -73
  102. package/server/service/order-tote-item/index.ts +0 -9
  103. package/server/service/order-tote-item/order-tote-item-mutation.ts +0 -31
  104. package/server/service/order-tote-item/order-tote-item-query.ts +0 -82
  105. package/server/service/order-tote-item/order-tote-item-types.ts +0 -56
  106. package/server/service/order-tote-item/order-tote-item.ts +0 -72
  107. package/server/service/order-tote-seal/index.ts +0 -9
  108. package/server/service/order-tote-seal/order-tote-seal-mutation.ts +0 -31
  109. package/server/service/order-tote-seal/order-tote-seal-query.ts +0 -59
  110. package/server/service/order-tote-seal/order-tote-seal-types.ts +0 -41
  111. package/server/service/order-tote-seal/order-tote-seal.ts +0 -46
  112. package/server/service/order-vas/index.ts +0 -9
  113. package/server/service/order-vas/order-vas-mutation.ts +0 -20
  114. package/server/service/order-vas/order-vas-query.ts +0 -72
  115. package/server/service/order-vas/order-vas-types.ts +0 -159
  116. package/server/service/order-vas/order-vas.ts +0 -207
  117. package/server/service/others/index.ts +0 -5
  118. package/server/service/others/other-query.ts +0 -563
  119. package/server/service/others/other-types.ts +0 -115
  120. package/server/service/purchase-order/index.ts +0 -9
  121. package/server/service/purchase-order/purchase-order-mutation.ts +0 -458
  122. package/server/service/purchase-order/purchase-order-query.ts +0 -90
  123. package/server/service/purchase-order/purchase-order-types.ts +0 -154
  124. package/server/service/purchase-order/purchase-order.ts +0 -172
  125. package/server/service/purchase-order-other-charge/index.ts +0 -9
  126. package/server/service/purchase-order-other-charge/purchase-order-other-charge-mutation.ts +0 -31
  127. package/server/service/purchase-order-other-charge/purchase-order-other-charge-query.ts +0 -52
  128. package/server/service/purchase-order-other-charge/purchase-order-other-charge-types.ts +0 -44
  129. package/server/service/purchase-order-other-charge/purchase-order-other-charge.ts +0 -68
  130. package/server/service/release-good/index.ts +0 -9
  131. package/server/service/release-good/release-good-mutation.ts +0 -1686
  132. package/server/service/release-good/release-good-query.ts +0 -980
  133. package/server/service/release-good/release-good-types.ts +0 -662
  134. package/server/service/release-good/release-good.ts +0 -490
  135. package/server/service/retail-replenishment-order/index.ts +0 -9
  136. package/server/service/retail-replenishment-order/retail-replenishment-order-mutation.ts +0 -382
  137. package/server/service/retail-replenishment-order/retail-replenishment-order-query.ts +0 -54
  138. package/server/service/retail-replenishment-order/retail-replenishment-order-types.ts +0 -101
  139. package/server/service/retail-replenishment-order/retail-replenishment-order.ts +0 -115
  140. package/server/service/return-order/index.ts +0 -9
  141. package/server/service/return-order/return-order-mutation.ts +0 -516
  142. package/server/service/return-order/return-order-query.ts +0 -226
  143. package/server/service/return-order/return-order-types.ts +0 -196
  144. package/server/service/return-order/return-order.ts +0 -127
  145. package/server/service/reverse-kitting-order/index.ts +0 -9
  146. package/server/service/reverse-kitting-order/reverse-kitting-order-mutation.ts +0 -500
  147. package/server/service/reverse-kitting-order/reverse-kitting-order-query.ts +0 -197
  148. package/server/service/reverse-kitting-order/reverse-kitting-order-type.ts +0 -173
  149. package/server/service/reverse-kitting-order/reverse-kitting-order.ts +0 -121
  150. package/server/service/reverse-kitting-order-inventory/index.ts +0 -9
  151. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.ts +0 -129
  152. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-query.ts +0 -52
  153. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-type.ts +0 -95
  154. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +0 -143
  155. package/server/service/shipping-order/index.ts +0 -9
  156. package/server/service/shipping-order/shipping-order-mutation.ts +0 -61
  157. package/server/service/shipping-order/shipping-order-query.ts +0 -61
  158. package/server/service/shipping-order/shipping-order-types.ts +0 -89
  159. package/server/service/shipping-order/shipping-order.ts +0 -129
  160. package/server/service/transfer-order/index.ts +0 -9
  161. package/server/service/transfer-order/transfer-order-mutation.ts +0 -309
  162. package/server/service/transfer-order/transfer-order-query.ts +0 -66
  163. package/server/service/transfer-order/transfer-order-types.ts +0 -97
  164. package/server/service/transfer-order/transfer-order.ts +0 -117
  165. package/server/service/vas/index.ts +0 -9
  166. package/server/service/vas/vas-mutation.ts +0 -106
  167. package/server/service/vas/vas-query.ts +0 -60
  168. package/server/service/vas/vas-types.ts +0 -71
  169. package/server/service/vas/vas.ts +0 -77
  170. package/server/service/vas-order/index.ts +0 -9
  171. package/server/service/vas-order/vas-order-mutation.ts +0 -259
  172. package/server/service/vas-order/vas-order-query.ts +0 -119
  173. package/server/service/vas-order/vas-order-types.ts +0 -49
  174. package/server/service/vas-order/vas-order.ts +0 -81
  175. package/server/utils/datetime-util.ts +0 -54
  176. package/server/utils/index.ts +0 -3
  177. package/server/utils/inventory-util.ts +0 -1155
  178. package/server/utils/order-no-generator.ts +0 -146
@@ -1,230 +0,0 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
2
- import {
3
- Column,
4
- CreateDateColumn,
5
- Entity,
6
- Index,
7
- JoinColumn,
8
- ManyToOne,
9
- OneToMany,
10
- OneToOne,
11
- PrimaryGeneratedColumn,
12
- RelationId,
13
- UpdateDateColumn
14
- } from 'typeorm'
15
-
16
- import { User } from '@things-factory/auth-base'
17
- import { Domain } from '@things-factory/shell'
18
-
19
- import { InvoiceProduct } from '../invoice-product/invoice-product'
20
- import { ReleaseGood } from '../release-good/release-good'
21
-
22
- @Entity()
23
- @Index('ix_invoice_0', (invoice: Invoice) => [invoice.id], { unique: true })
24
- @ObjectType()
25
- export class Invoice {
26
- @PrimaryGeneratedColumn('uuid')
27
- @Field(type => ID)
28
- readonly id: string
29
-
30
- @ManyToOne(type => Domain)
31
- @Field(type => Domain, { nullable: true })
32
- domain: Domain
33
-
34
- @RelationId((invoice: Invoice) => invoice.domain)
35
- domainId: string
36
-
37
- @Column()
38
- @Field()
39
- name: string
40
-
41
- @Column({ nullable: true })
42
- @Field({ nullable: true })
43
- description: string
44
-
45
- @OneToMany(type => InvoiceProduct, invoiceProduct => invoiceProduct.invoice)
46
- @Field(type => [InvoiceProduct], { nullable: true })
47
- invoiceProducts: InvoiceProduct[]
48
-
49
- @OneToOne(type => ReleaseGood, { nullable: true })
50
- @Field(type => ReleaseGood, { nullable: true })
51
- @JoinColumn()
52
- releaseGood: ReleaseGood
53
-
54
- @Column({ default: '' })
55
- @Field({ nullable: true })
56
- refNo1: string
57
-
58
- @Column({ default: '' })
59
- @Field({ nullable: true })
60
- refNo2: string
61
-
62
- @Column({ default: '' })
63
- @Field({ nullable: true })
64
- refNo3: string
65
-
66
- @Column({ nullable: true })
67
- @Field({ nullable: true })
68
- issuedOn: Date
69
-
70
- @Column({ type: 'uuid', nullable: true })
71
- @Field({ nullable: true })
72
- contactPointRefId: string
73
-
74
- @Column()
75
- @Field()
76
- from: string
77
-
78
- @Column()
79
- @Field()
80
- fromContactPhone: string
81
-
82
- @Column({ nullable: true })
83
- @Field({ nullable: true })
84
- fromAddress1: string
85
-
86
- @Column({ nullable: true })
87
- @Field({ nullable: true })
88
- fromAddress2: string
89
-
90
- @Column({ nullable: true })
91
- @Field({ nullable: true })
92
- fromAddress3: string
93
-
94
- @Column({ nullable: true })
95
- @Field({ nullable: true })
96
- fromAddress4: string
97
-
98
- @Column({ nullable: true })
99
- @Field({ nullable: true })
100
- fromAddress5: string
101
-
102
- @Column({ nullable: true })
103
- @Field({ nullable: true })
104
- fromPostcode: string
105
-
106
- @Column({ nullable: true })
107
- @Field({ nullable: true })
108
- fromCity: string
109
-
110
- @Column({ nullable: true })
111
- @Field({ nullable: true })
112
- fromState: string
113
-
114
- @Column({ nullable: true })
115
- @Field({ nullable: true })
116
- fromCountry: string
117
-
118
- @Column()
119
- @Field()
120
- deliverTo: string
121
-
122
- @Column()
123
- @Field()
124
- deliverToPhone: string
125
-
126
- @Column()
127
- @Field()
128
- deliveryAddress1: string
129
-
130
- @Column({ nullable: true })
131
- @Field({ nullable: true })
132
- deliveryAddress2: string
133
-
134
- @Column({ nullable: true })
135
- @Field({ nullable: true })
136
- deliveryAddress3: string
137
-
138
- @Column({ nullable: true })
139
- @Field({ nullable: true })
140
- deliveryAddress4: string
141
-
142
- @Column({ nullable: true })
143
- @Field({ nullable: true })
144
- deliveryAddress5: string
145
-
146
- @Column()
147
- @Field()
148
- deliveryPostcode: string
149
-
150
- @Column()
151
- @Field()
152
- deliveryCity: string
153
-
154
- @Column()
155
- @Field()
156
- deliveryState: string
157
-
158
- @Column()
159
- @Field()
160
- deliveryCountry: string
161
-
162
- @Column()
163
- @Field()
164
- billTo: string
165
-
166
- @Column()
167
- @Field()
168
- billToPhone: string
169
-
170
- @Column()
171
- @Field()
172
- billingAddress1: string
173
-
174
- @Column({ nullable: true })
175
- @Field({ nullable: true })
176
- billingAddress2: string
177
-
178
- @Column({ nullable: true })
179
- @Field({ nullable: true })
180
- billingAddress3: string
181
-
182
- @Column({ nullable: true })
183
- @Field({ nullable: true })
184
- billingAddress4: string
185
-
186
- @Column({ nullable: true })
187
- @Field({ nullable: true })
188
- billingAddress5: string
189
-
190
- @Column()
191
- @Field()
192
- billingPostcode: string
193
-
194
- @Column()
195
- @Field()
196
- billingCity: string
197
-
198
- @Column()
199
- @Field()
200
- billingState: string
201
-
202
- @Column()
203
- @Field()
204
- billingCountry: string
205
-
206
- @Field({ nullable: true })
207
- paymentDue: string
208
-
209
- @CreateDateColumn()
210
- @Field()
211
- createdAt: Date
212
-
213
- @UpdateDateColumn()
214
- @Field()
215
- updatedAt: Date
216
-
217
- @ManyToOne(type => User)
218
- @Field(type => User, { nullable: true })
219
- creator: User
220
-
221
- @RelationId((invoice: Invoice) => invoice.creator)
222
- creatorId: string
223
-
224
- @ManyToOne(type => User)
225
- @Field(type => User, { nullable: true })
226
- updater: User
227
-
228
- @RelationId((invoice: Invoice) => invoice.updater)
229
- updaterId: string
230
- }
@@ -1,9 +0,0 @@
1
- import { InvoiceProduct } from './invoice-product'
2
- import { InvoiceProductMutation } from './invoice-product-mutation'
3
- import { InvoiceProductQuery } from './invoice-product-query'
4
-
5
- export const entities = [InvoiceProduct]
6
- export const resolvers = [InvoiceProductQuery, InvoiceProductMutation]
7
-
8
- export * from './invoice-product-mutation'
9
- export * from './invoice-product-query'
@@ -1,54 +0,0 @@
1
- import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
-
3
- import { InvoiceProduct } from '../invoice-product/invoice-product'
4
- import { InvoiceProductPatch, NewInvoiceProduct } from './invoice-product-types'
5
-
6
- @Resolver(InvoiceProduct)
7
- export class InvoiceProductMutation {
8
- @Mutation(returns => InvoiceProduct)
9
- @Directive('@transaction')
10
- async createInvoiceProduct(
11
- @Arg('invoiceProduct', type => NewInvoiceProduct) invoiceProduct: NewInvoiceProduct,
12
- @Ctx() context: ResolverContext
13
- ): Promise<InvoiceProduct> {
14
- const { domain, user, tx } = context.state
15
-
16
- return await tx.getRepository(InvoiceProduct).save({
17
- ...invoiceProduct,
18
- domain,
19
- creator: user,
20
- updater: user
21
- })
22
- }
23
-
24
- @Mutation(returns => InvoiceProduct)
25
- @Directive('@transaction')
26
- async updateInvoiceProduct(
27
- @Arg('name') name: string,
28
- @Arg('patch', type => InvoiceProductPatch) patch: InvoiceProductPatch,
29
- @Ctx() context: ResolverContext
30
- ): Promise<InvoiceProduct> {
31
- const { domain, user, tx } = context.state
32
-
33
- const repository = tx.getRepository(InvoiceProduct)
34
- const invoiceProduct = await repository.findOne({
35
- where: { domain: { id: domain.id }, name }
36
- })
37
-
38
- return await repository.save({
39
- ...invoiceProduct,
40
- ...patch,
41
- updater: user
42
- })
43
- }
44
-
45
- @Mutation(returns => Boolean)
46
- @Directive('@transaction')
47
- async deleteInvoiceProduct(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {
48
- const { domain, tx } = context.state
49
-
50
- await tx.getRepository(InvoiceProduct).delete({ domain: { id: domain.id }, name })
51
-
52
- return true
53
- }
54
- }
@@ -1,54 +0,0 @@
1
- import { Arg, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
2
-
3
- import { User } from '@things-factory/auth-base'
4
- import { buildQuery, Domain, Filter, getRepository, Pagination, Sorting } from '@things-factory/shell'
5
-
6
- import { InvoiceProduct } from './invoice-product'
7
- import { InvoiceProductList } from './invoice-product-types'
8
-
9
- @Resolver(InvoiceProduct)
10
- export class InvoiceProductQuery {
11
- @Query(returns => InvoiceProductList)
12
- async invoiceProducts(
13
- @Ctx() context: ResolverContext,
14
- @Arg('filters', type => [Filter], { nullable: true }) filters?: Filter[],
15
- @Arg('pagination', type => Pagination, { nullable: true }) pagination?: Pagination,
16
- @Arg('sortings', type => [Sorting], { nullable: true }) sortings?: Sorting[]
17
- ): Promise<InvoiceProductList> {
18
- const queryBuilder = getRepository(InvoiceProduct).createQueryBuilder()
19
- buildQuery(queryBuilder, { filters, pagination, sortings }, context)
20
- const [items, total] = await queryBuilder
21
- .leftJoinAndSelect('InvoiceProduct.domain', 'Domain')
22
- .leftJoinAndSelect('InvoiceProduct.invoice', 'Invoice')
23
- .leftJoinAndSelect('InvoiceProduct.creator', 'Creator')
24
- .leftJoinAndSelect('InvoiceProduct.updater', 'Updater')
25
- .getManyAndCount()
26
-
27
- return { items, total }
28
- }
29
-
30
- @Query(returns => InvoiceProduct)
31
- async invoiceProduct(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<InvoiceProduct> {
32
- const { domain } = context.state
33
-
34
- return await getRepository(InvoiceProduct).findOne({
35
- where: { domain: { id: domain.id }, name },
36
- relations: ['domain', 'invoice', 'creator', 'updater']
37
- })
38
- }
39
-
40
- @FieldResolver(type => Domain)
41
- async domain(@Root() invoiceProduct: InvoiceProduct): Promise<Domain> {
42
- return await getRepository(Domain).findOneBy({ id: invoiceProduct.domainId })
43
- }
44
-
45
- @FieldResolver(type => User)
46
- async creator(@Root() invoiceProduct: InvoiceProduct): Promise<User> {
47
- return await getRepository(User).findOneBy({ id: invoiceProduct.creatorId })
48
- }
49
-
50
- @FieldResolver(type => User)
51
- async updater(@Root() invoiceProduct: InvoiceProduct): Promise<User> {
52
- return await getRepository(User).findOneBy({ id: invoiceProduct.updaterId })
53
- }
54
- }
@@ -1,84 +0,0 @@
1
- import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
2
-
3
- import { InvoiceProduct } from './invoice-product'
4
-
5
- @ObjectType()
6
- export class InvoiceProductList {
7
- @Field(type => [InvoiceProduct], { nullable: true })
8
- items: InvoiceProduct[]
9
-
10
- @Field(type => Int, { nullable: true })
11
- total: number
12
- }
13
-
14
- @InputType()
15
- export class ProductInput {
16
- @Field()
17
- sku: string
18
- }
19
-
20
- @InputType()
21
- export class NewInvoiceProduct {
22
- @Field({ nullable: true })
23
- name: string
24
-
25
- @Field({ nullable: true })
26
- sku: string
27
-
28
- @Field({ nullable: true })
29
- description: string
30
-
31
- @Field(type => ProductInput, { nullable: true })
32
- product: ProductInput
33
-
34
- @Field(type => Int)
35
- qty: number
36
-
37
- @Field(type => Float, { nullable: true })
38
- otherCharges: number
39
-
40
- @Field(type => Float)
41
- unitPrice: number
42
-
43
- @Field(type => Float)
44
- paidPrice: number
45
-
46
- @Field(type => Float, { nullable: true })
47
- discount: number
48
-
49
- @Field(type => Float, { nullable: true })
50
- shippingFeePaidByCustomer: number
51
- }
52
-
53
- @InputType()
54
- export class InvoiceProductPatch {
55
- @Field({ nullable: true })
56
- name: string
57
-
58
- @Field({ nullable: true })
59
- sku: string
60
-
61
- @Field({ nullable: true })
62
- description: string
63
-
64
- @Field(type => ProductInput)
65
- product: ProductInput
66
-
67
- @Field(type => Int)
68
- qty: number
69
-
70
- @Field(type => Float, { nullable: true })
71
- otherCharges: number
72
-
73
- @Field(type => Float)
74
- unitPrice: number
75
-
76
- @Field(type => Float)
77
- paidPrice: number
78
-
79
- @Field(type => Float, { nullable: true })
80
- discount: number
81
-
82
- @Field(type => Float, { nullable: true })
83
- shippingFeePaidByCustomer: number
84
- }
@@ -1,92 +0,0 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
2
- import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'
3
-
4
- import { User } from '@things-factory/auth-base'
5
- import { Product } from '@things-factory/product-base'
6
- import { Domain, roundTransformer } from '@things-factory/shell'
7
-
8
- import { Invoice } from '../invoice/invoice'
9
-
10
- @Entity()
11
- @Index('ix_invoice_product_0', (invoiceProduct: InvoiceProduct) => [invoiceProduct.id], {
12
- unique: true
13
- })
14
- @ObjectType()
15
- export class InvoiceProduct {
16
- @PrimaryGeneratedColumn('uuid')
17
- @Field(type => ID)
18
- readonly id: string
19
-
20
- @ManyToOne(type => Domain)
21
- @Field(type => Domain, { nullable: true })
22
- domain: Domain
23
-
24
- @RelationId((invoiceProduct: InvoiceProduct) => invoiceProduct.domain)
25
- domainId: string
26
-
27
- @Column({ nullable: true })
28
- @Field({ nullable: true })
29
- sku: string
30
-
31
- @Column()
32
- @Field()
33
- name: string
34
-
35
- @Column({ nullable: true })
36
- @Field()
37
- description: string
38
-
39
- @ManyToOne(type => Invoice)
40
- @Field(type => Invoice)
41
- invoice: Invoice
42
-
43
- @ManyToOne(type => Product, { nullable: true })
44
- @Field(type => Product, { nullable: true })
45
- product: Product
46
-
47
- @Column('int', { default: 0 })
48
- @Field()
49
- qty: number
50
-
51
- @Column('float', { default: 0, transformer: roundTransformer })
52
- @Field({ nullable: true })
53
- otherCharges: number
54
-
55
- @Column('float', { default: 0, transformer: roundTransformer })
56
- @Field()
57
- unitPrice: number
58
-
59
- @Column('float', { default: 0, transformer: roundTransformer })
60
- @Field()
61
- paidPrice: number
62
-
63
- @Column('float', { default: 0, transformer: roundTransformer })
64
- @Field({ nullable: true })
65
- discount: number
66
-
67
- @Column('float', { default: 0, transformer: roundTransformer })
68
- @Field({ nullable: true })
69
- shippingFeePaidByCustomer: number
70
-
71
- @CreateDateColumn()
72
- @Field()
73
- createdAt: Date
74
-
75
- @UpdateDateColumn()
76
- @Field({ nullable: true })
77
- updatedAt: Date
78
-
79
- @ManyToOne(type => User, { nullable: true })
80
- @Field(type => User, { nullable: true })
81
- creator: User
82
-
83
- @RelationId((invoiceProduct: InvoiceProduct) => invoiceProduct.creator)
84
- creatorId: string
85
-
86
- @ManyToOne(type => User, { nullable: true })
87
- @Field(type => User, { nullable: true })
88
- updater: User
89
-
90
- @RelationId((invoiceProduct: InvoiceProduct) => invoiceProduct.updater)
91
- updaterId: string
92
- }
@@ -1,9 +0,0 @@
1
- import { JobSheet } from './job-sheet'
2
- import { JobSheetMutation } from './job-sheet-mutation'
3
- import { JobSheetQuery } from './job-sheet-query'
4
-
5
- export const entities = [JobSheet]
6
- export const resolvers = [JobSheetQuery, JobSheetMutation]
7
-
8
- export * from './job-sheet-mutation'
9
- export * from './job-sheet-query'
@@ -1,92 +0,0 @@
1
- import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
- import { EntityManager, Repository } from 'typeorm'
3
-
4
- import { User } from '@things-factory/auth-base'
5
- import { Domain, getRepository } from '@things-factory/shell'
6
-
7
- import { ArrivalNotice, ArrivalNoticePatch, JobSheetPatch } from '../'
8
- import { OrderNoGenerator } from '../../utils/order-no-generator'
9
- import { JobSheet } from './job-sheet'
10
-
11
- @Resolver(JobSheet)
12
- export class JobSheetMutation {
13
- @Directive('@transaction')
14
- @Mutation(returns => JobSheet)
15
- async generateJobSheet(
16
- @Ctx() context: ResolverContext,
17
- @Arg('arrivalNotice', type => ArrivalNoticePatch, { nullable: true }) arrivalNotice?: ArrivalNoticePatch
18
- ): Promise<JobSheet> {
19
- const { domain, user, tx } = context.state
20
- return await generateJobSheet(domain, user, arrivalNotice, tx)
21
- }
22
-
23
- @Directive('@transaction')
24
- @Mutation(returns => JobSheet)
25
- async updateJobSheet(
26
- @Arg('name') name: string,
27
- @Arg('patch', type => JobSheetPatch) patch: JobSheetPatch,
28
- @Ctx() context: ResolverContext
29
- ): Promise<JobSheet> {
30
- const { tx, domain, user } = context.state
31
-
32
- const jobSheet = await tx.getRepository(JobSheet).findOne({ where: { domain: { id: domain.id }, name } })
33
- if (!jobSheet) throw new Error('No job sheet is found')
34
-
35
- const foundGAN: ArrivalNotice = await tx.getRepository(ArrivalNotice).findOne({
36
- where: {
37
- domain: { id: domain.id },
38
- name: jobSheet.arrivalNoticeRefNo
39
- }
40
- })
41
-
42
- await tx.getRepository(ArrivalNotice).save({
43
- ...foundGAN,
44
- ata: patch.ata,
45
- updater: user
46
- })
47
-
48
- return await tx.getRepository(JobSheet).save({
49
- ...jobSheet,
50
- containerMtDate: patch?.containerMtDate ? patch.containerMtDate : null,
51
- adviseMtDate: patch?.adviseMtDate ? patch.adviseMtDate : null,
52
- sumPalletQty: patch?.sumPalletQty ? patch.sumPalletQty : null
53
- })
54
- }
55
- }
56
-
57
- export async function generateJobSheet(
58
- domain: Domain,
59
- user: User,
60
- arrivalNotice: ArrivalNotice | ArrivalNoticePatch,
61
- tx?: EntityManager
62
- ): Promise<JobSheet> {
63
- const jobSheetRepo: Repository<JobSheet> = tx?.getRepository(JobSheet) || getRepository(JobSheet)
64
-
65
- let foundJS: JobSheet = null
66
- if (arrivalNotice?.refNo) {
67
- foundJS = await jobSheetRepo.findOne({
68
- where: { domain: { id: domain.id }, name: arrivalNotice.refNo, bizplace: { id: arrivalNotice.bizplace.id } }
69
- })
70
- }
71
-
72
- let jobName: any = null
73
- if (foundJS) {
74
- jobName = OrderNoGenerator.jobSheet(domain.name)
75
- } else {
76
- jobName = arrivalNotice?.refNo
77
- }
78
-
79
- // 1. Create job sheet
80
- const createdJobSheet: JobSheet = await jobSheetRepo.save({
81
- name: jobName ? jobName : OrderNoGenerator.jobSheet(domain.name),
82
- domain,
83
- bizplace: arrivalNotice.bizplace,
84
- containerSize: arrivalNotice?.containerSize ? arrivalNotice.containerSize : null,
85
- containerNo: arrivalNotice?.containerNo ? arrivalNotice.containerNo : null,
86
- arrivalNoticeRefNo: arrivalNotice.name,
87
- creator: user,
88
- updater: user
89
- })
90
-
91
- return createdJobSheet
92
- }