@things-factory/sales-base 4.0.38 → 4.0.42

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 (97) hide show
  1. package/dist-server/controllers/ecommerce/sellercraft-controller.js +4 -3
  2. package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
  3. package/dist-server/service/arrival-notice/arrival-notice-mutation.js +42 -35
  4. package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
  5. package/dist-server/service/arrival-notice/arrival-notice-query.js +91 -79
  6. package/dist-server/service/arrival-notice/arrival-notice-query.js.map +1 -1
  7. package/dist-server/service/arrival-notice/arrival-notice-types.js +8 -0
  8. package/dist-server/service/arrival-notice/arrival-notice-types.js.map +1 -1
  9. package/dist-server/service/arrival-notice/arrival-notice.js +20 -15
  10. package/dist-server/service/arrival-notice/arrival-notice.js.map +1 -1
  11. package/dist-server/service/delivery-order/delivery-order-mutation.js +28 -26
  12. package/dist-server/service/delivery-order/delivery-order-mutation.js.map +1 -1
  13. package/dist-server/service/delivery-order/delivery-order-query.js +14 -14
  14. package/dist-server/service/delivery-order/delivery-order-query.js.map +1 -1
  15. package/dist-server/service/delivery-order/delivery-order-summary-report.js +145 -0
  16. package/dist-server/service/delivery-order/delivery-order-summary-report.js.map +1 -0
  17. package/dist-server/service/delivery-order/delivery-order.js +16 -13
  18. package/dist-server/service/delivery-order/delivery-order.js.map +1 -1
  19. package/dist-server/service/delivery-order/index.js +3 -1
  20. package/dist-server/service/delivery-order/index.js.map +1 -1
  21. package/dist-server/service/index.js +12 -4
  22. package/dist-server/service/index.js.map +1 -1
  23. package/dist-server/service/invoice/invoice-mutation.js +21 -3
  24. package/dist-server/service/invoice/invoice-mutation.js.map +1 -1
  25. package/dist-server/service/invoice/invoice-query.js +5 -7
  26. package/dist-server/service/invoice/invoice-query.js.map +1 -1
  27. package/dist-server/service/invoice/invoice-types.js +302 -20
  28. package/dist-server/service/invoice/invoice-types.js.map +1 -1
  29. package/dist-server/service/invoice/invoice.js +190 -26
  30. package/dist-server/service/invoice/invoice.js.map +1 -1
  31. package/dist-server/service/invoice-product/index.js +21 -0
  32. package/dist-server/service/invoice-product/index.js.map +1 -0
  33. package/dist-server/service/invoice-product/invoice-product-mutation.js +70 -0
  34. package/dist-server/service/invoice-product/invoice-product-mutation.js.map +1 -0
  35. package/dist-server/service/invoice-product/invoice-product-query.js +95 -0
  36. package/dist-server/service/invoice-product/invoice-product-query.js.map +1 -0
  37. package/dist-server/service/invoice-product/invoice-product-types.js +125 -0
  38. package/dist-server/service/invoice-product/invoice-product-types.js.map +1 -0
  39. package/dist-server/service/invoice-product/invoice-product.js +117 -0
  40. package/dist-server/service/invoice-product/invoice-product.js.map +1 -0
  41. package/dist-server/service/order-inventory/order-inventory-query.js +9 -7
  42. package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
  43. package/dist-server/service/order-inventory/order-inventory.js +31 -25
  44. package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
  45. package/dist-server/service/order-product/order-product.js +26 -21
  46. package/dist-server/service/order-product/order-product.js.map +1 -1
  47. package/dist-server/service/order-vas/order-vas.js +34 -27
  48. package/dist-server/service/order-vas/order-vas.js.map +1 -1
  49. package/dist-server/service/others/other-query.js +4 -2
  50. package/dist-server/service/others/other-query.js.map +1 -1
  51. package/dist-server/service/others/other-types.js +42 -0
  52. package/dist-server/service/others/other-types.js.map +1 -1
  53. package/dist-server/service/purchase-order/purchase-order-mutation.js +23 -36
  54. package/dist-server/service/purchase-order/purchase-order-mutation.js.map +1 -1
  55. package/dist-server/service/release-good/release-good-mutation.js +84 -82
  56. package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
  57. package/dist-server/service/release-good/release-good-query.js +7 -9
  58. package/dist-server/service/release-good/release-good-query.js.map +1 -1
  59. package/dist-server/service/release-good/release-good.js +2 -0
  60. package/dist-server/service/release-good/release-good.js.map +1 -1
  61. package/dist-server/service/return-order/return-order-mutation.js +3 -3
  62. package/dist-server/service/return-order/return-order-mutation.js.map +1 -1
  63. package/dist-server/utils/order-no-generator.js +7 -0
  64. package/dist-server/utils/order-no-generator.js.map +1 -1
  65. package/package.json +12 -12
  66. package/server/controllers/ecommerce/sellercraft-controller.ts +2 -1
  67. package/server/service/arrival-notice/arrival-notice-mutation.ts +11 -15
  68. package/server/service/arrival-notice/arrival-notice-query.ts +94 -78
  69. package/server/service/arrival-notice/arrival-notice-types.ts +6 -0
  70. package/server/service/arrival-notice/arrival-notice.ts +6 -1
  71. package/server/service/delivery-order/delivery-order-mutation.ts +4 -8
  72. package/server/service/delivery-order/delivery-order-query.ts +4 -4
  73. package/server/service/delivery-order/delivery-order-summary-report.ts +152 -0
  74. package/server/service/delivery-order/delivery-order.ts +4 -1
  75. package/server/service/delivery-order/index.ts +3 -1
  76. package/server/service/index.ts +20 -12
  77. package/server/service/invoice/invoice-mutation.ts +45 -7
  78. package/server/service/invoice/invoice-query.ts +6 -6
  79. package/server/service/invoice/invoice-types.ts +231 -18
  80. package/server/service/invoice/invoice.ts +154 -20
  81. package/server/service/invoice-product/index.ts +9 -0
  82. package/server/service/invoice-product/invoice-product-mutation.ts +54 -0
  83. package/server/service/invoice-product/invoice-product-query.ts +55 -0
  84. package/server/service/invoice-product/invoice-product-types.ts +80 -0
  85. package/server/service/invoice-product/invoice-product.ts +93 -0
  86. package/server/service/order-inventory/order-inventory-query.ts +3 -1
  87. package/server/service/order-inventory/order-inventory.ts +11 -13
  88. package/server/service/order-product/order-product.ts +13 -13
  89. package/server/service/order-vas/order-vas.ts +15 -15
  90. package/server/service/others/other-query.ts +9 -15
  91. package/server/service/others/other-types.ts +31 -0
  92. package/server/service/purchase-order/purchase-order-mutation.ts +19 -21
  93. package/server/service/release-good/release-good-mutation.ts +64 -58
  94. package/server/service/release-good/release-good-query.ts +5 -12
  95. package/server/service/release-good/release-good.ts +2 -0
  96. package/server/service/return-order/return-order-mutation.ts +5 -4
  97. package/server/utils/order-no-generator.ts +11 -0
@@ -1,8 +1,13 @@
1
+ import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
+ import { EntityManager, getRepository, Repository } from 'typeorm'
3
+
1
4
  import { User } from '@things-factory/auth-base'
5
+ import { Product } from '@things-factory/product-base'
2
6
  import { Domain } from '@things-factory/shell'
3
- import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
4
- import { EntityManager } from 'typeorm'
7
+
5
8
  import { InvoicePatch, NewInvoice } from '../'
9
+ import { OrderNoGenerator } from '../../utils'
10
+ import { InvoiceProduct } from '../invoice-product/invoice-product'
6
11
  import { Invoice } from './invoice'
7
12
 
8
13
  @Resolver(Invoice)
@@ -10,14 +15,20 @@ export class InvoiceMutation {
10
15
  @Mutation(returns => Invoice)
11
16
  @Directive('@transaction')
12
17
  async createInvoice(@Arg('invoice', type => NewInvoice) invoice: NewInvoice, @Ctx() context: any): Promise<Invoice> {
13
- const { tx }: { tx: EntityManager } = context.state
18
+ const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
19
+ let invoiceProducts: any[] = invoice.invoiceProducts
14
20
 
15
- return await tx.getRepository(Invoice).save({
21
+ let createdInvoice: Invoice = await tx.getRepository(Invoice).save({
16
22
  ...invoice,
17
- domain: context.state.domain,
18
- creator: context.state.user,
19
- updater: context.state.user
23
+ domain,
24
+ name: OrderNoGenerator.invoice(),
25
+ // releaseGood: await tx.getRepository(ReleaseGood).findOne(invoice?.releaseGood.id),
26
+ creator: user
20
27
  })
28
+
29
+ await addInvoiceProducts(domain, createdInvoice, invoiceProducts, user, tx)
30
+
31
+ return createdInvoice
21
32
  }
22
33
 
23
34
  @Mutation(returns => Invoice)
@@ -50,3 +61,30 @@ export class InvoiceMutation {
50
61
  return true
51
62
  }
52
63
  }
64
+
65
+ export async function addInvoiceProducts(
66
+ domain: Domain,
67
+ invoice: Invoice,
68
+ invoiceProducts: any[],
69
+ user: User,
70
+ tx?: EntityManager
71
+ ): Promise<void> {
72
+ const productRepo: Repository<Product> = tx?.getRepository(Product) || getRepository(Product)
73
+ const invoiceProductRepo: Repository<InvoiceProduct> =
74
+ tx?.getRepository(InvoiceProduct) || getRepository(InvoiceProduct)
75
+
76
+ const createdInvoiceProducts: InvoiceProduct[] = await Promise.all(
77
+ invoiceProducts.map(async (invoiceProduct: InvoiceProduct) => {
78
+ return {
79
+ name: OrderNoGenerator.invoiceProduct(),
80
+ ...invoiceProduct,
81
+ domain,
82
+ product: await productRepo.findOne(invoiceProduct?.product.id),
83
+ invoice,
84
+ creator: user
85
+ }
86
+ })
87
+ )
88
+
89
+ await invoiceProductRepo.save(createdInvoiceProducts)
90
+ }
@@ -1,9 +1,11 @@
1
- import { User } from '@things-factory/auth-base'
2
- import { buildQuery, Domain, Filter, Pagination, Sorting } from '@things-factory/shell'
3
1
  import { Arg, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
4
2
  import { getRepository } from 'typeorm'
5
- import { InvoiceList } from '../'
3
+
4
+ import { User } from '@things-factory/auth-base'
5
+ import { buildQuery, Domain, Filter, Pagination, Sorting } from '@things-factory/shell'
6
+
6
7
  import { Invoice } from './invoice'
8
+ import { InvoiceList } from './invoice-types'
7
9
 
8
10
  @Resolver(Invoice)
9
11
  export class InvoiceQuery {
@@ -18,8 +20,6 @@ export class InvoiceQuery {
18
20
  buildQuery(queryBuilder, { filters, pagination, sortings }, context)
19
21
  const [items, total] = await queryBuilder
20
22
  .leftJoinAndSelect('Invoice.domain', 'Domain')
21
- .leftJoinAndSelect('Invoice.customer', 'Bizplace')
22
- .leftJoinAndSelect('Invoice.purchaseOrder', 'PurchaseOrder')
23
23
  .leftJoinAndSelect('Invoice.creator', 'Creator')
24
24
  .leftJoinAndSelect('Invoice.updater', 'Updater')
25
25
  .getManyAndCount()
@@ -33,7 +33,7 @@ export class InvoiceQuery {
33
33
 
34
34
  return await getRepository(Invoice).findOne({
35
35
  where: { domain, name },
36
- relations: ['domain', 'customer', 'purchaseOrder', 'creator', 'updater']
36
+ relations: ['domain', 'creator', 'updater']
37
37
  })
38
38
  }
39
39
 
@@ -1,5 +1,8 @@
1
1
  import { Field, InputType, Int, ObjectType } from 'type-graphql'
2
- import { PurchaseOrderPatch } from '../purchase-order/purchase-order-types'
2
+
3
+ import { ObjectRef } from '@things-factory/shell'
4
+
5
+ import { InvoiceProductPatch, NewInvoiceProduct } from '../invoice-product/invoice-product-types'
3
6
  import { Invoice } from './invoice'
4
7
 
5
8
  @ObjectType()
@@ -17,25 +20,130 @@ export class NewInvoice {
17
20
  name: string
18
21
 
19
22
  @Field()
20
- customer: string
23
+ refNo1: string
24
+
25
+ @Field()
26
+ refNo2: string
27
+
28
+ @Field()
29
+ refNo3: string
21
30
 
22
31
  @Field()
23
32
  issuedOn: string
24
33
 
25
34
  @Field()
26
- paymentDue: string
35
+ contactPointRefId: string
36
+
37
+ @Field()
38
+ from: string
39
+
40
+ @Field()
41
+ fromContactPhone: string
42
+
43
+ @Field()
44
+ fromAddress1: string
45
+
46
+ @Field()
47
+ fromAddress2: string
48
+
49
+ @Field()
50
+ fromAddress3: string
51
+
52
+ @Field()
53
+ fromAddress4: string
54
+
55
+ @Field()
56
+ fromAddress5: string
57
+
58
+ @Field()
59
+ fromPostcode: string
60
+
61
+ @Field()
62
+ fromCity: string
27
63
 
28
64
  @Field()
29
- version: string
65
+ fromState: string
30
66
 
31
- @Field(type => PurchaseOrderPatch)
32
- purchaseOrder: PurchaseOrderPatch
67
+ @Field()
68
+ fromCountry: string
69
+
70
+ @Field()
71
+ deliverTo: string
72
+
73
+ @Field()
74
+ deliverToPhone: string
33
75
 
34
76
  @Field()
35
- state: string
77
+ deliveryAddress1: string
78
+
79
+ @Field()
80
+ deliveryAddress2: string
81
+
82
+ @Field()
83
+ deliveryAddress3: string
84
+
85
+ @Field()
86
+ deliveryAddress4: string
87
+
88
+ @Field()
89
+ deliveryAddress5: string
90
+
91
+ @Field()
92
+ deliveryCity: string
93
+
94
+ @Field()
95
+ deliveryState: string
96
+
97
+ @Field()
98
+ deliveryCountry: string
99
+
100
+ @Field()
101
+ deliveryPostcode: string
102
+
103
+ @Field()
104
+ billTo: string
105
+
106
+ @Field()
107
+ billToPhone: string
108
+
109
+ @Field()
110
+ billingAddress1: string
111
+
112
+ @Field()
113
+ billingAddress2: string
114
+
115
+ @Field()
116
+ billingAddress3: string
117
+
118
+ @Field()
119
+ billingAddress4: string
120
+
121
+ @Field()
122
+ billingAddress5: string
123
+
124
+ @Field()
125
+ billingPostcode: string
126
+
127
+ @Field()
128
+ billingCity: string
129
+
130
+ @Field()
131
+ billingState: string
132
+
133
+ @Field()
134
+ billingCountry: string
135
+
136
+ @Field()
137
+ paymentDue: String
36
138
 
37
139
  @Field({ nullable: true })
38
140
  description: string
141
+
142
+ @Field(type => [NewInvoiceProduct])
143
+ invoiceProducts: NewInvoiceProduct[]
144
+
145
+ @Field(type => ObjectRef)
146
+ releaseGood: ObjectRef
39
147
  }
40
148
 
41
149
  @InputType()
@@ -43,24 +151,129 @@ export class InvoicePatch {
43
151
  @Field({ nullable: true })
44
152
  name: string
45
153
 
46
- @Field({ nullable: true })
47
- customer: string
154
+ @Field()
155
+ refNo1: string
48
156
 
49
- @Field({ nullable: true })
157
+ @Field()
158
+ refNo2: string
159
+
160
+ @Field()
161
+ refNo3: string
162
+
163
+ @Field()
50
164
  issuedOn: string
51
165
 
52
- @Field({ nullable: true })
53
- paymentDue: string
166
+ @Field()
167
+ contactPointRefId: string
54
168
 
55
- @Field({ nullable: true })
56
- version: string
169
+ @Field()
170
+ from: string
57
171
 
58
- @Field(type => PurchaseOrderPatch, { nullable: true })
59
- purchaseOrder: PurchaseOrderPatch
172
+ @Field()
173
+ fromContactPhone: string
60
174
 
61
- @Field({ nullable: true })
62
- state: string
175
+ @Field()
176
+ fromAddress1: string
177
+
178
+ @Field()
179
+ fromAddress2: string
180
+
181
+ @Field()
182
+ fromAddress3: string
183
+
184
+ @Field()
185
+ fromAddress4: string
186
+
187
+ @Field()
188
+ fromAddress5: string
189
+
190
+ @Field()
191
+ fromPostcode: string
192
+
193
+ @Field()
194
+ fromCity: string
195
+
196
+ @Field()
197
+ fromState: string
198
+
199
+ @Field()
200
+ fromCountry: string
201
+
202
+ @Field()
203
+ deliverTo: string
204
+
205
+ @Field()
206
+ deliverToPhone: string
207
+
208
+ @Field()
209
+ deliveryAddress1: string
210
+
211
+ @Field()
212
+ deliveryAddress2: string
213
+
214
+ @Field()
215
+ deliveryAddress3: string
216
+
217
+ @Field()
218
+ deliveryAddress4: string
219
+
220
+ @Field()
221
+ deliveryAddress5: string
222
+
223
+ @Field()
224
+ deliveryCity: string
225
+
226
+ @Field()
227
+ deliveryState: string
228
+
229
+ @Field()
230
+ deliveryCountry: string
231
+
232
+ @Field()
233
+ deliveryPostcode: string
234
+
235
+ @Field()
236
+ billTo: string
237
+
238
+ @Field()
239
+ billToPhone: string
240
+
241
+ @Field()
242
+ billingAddress1: string
243
+
244
+ @Field()
245
+ billingAddress2: string
246
+
247
+ @Field()
248
+ billingAddress3: string
249
+
250
+ @Field()
251
+ billingAddress4: string
252
+
253
+ @Field()
254
+ billingAddress5: string
255
+
256
+ @Field()
257
+ billingPostcode: string
258
+
259
+ @Field()
260
+ billingCity: string
261
+
262
+ @Field()
263
+ billingState: string
264
+
265
+ @Field()
266
+ billingCountry: string
267
+
268
+ @Field()
269
+ paymentDue: String
63
270
 
64
271
  @Field({ nullable: true })
65
272
  description: string
273
+
274
+ @Field(type => [InvoiceProductPatch], { nullable: true })
275
+ invoiceProducts: InvoiceProductPatch[]
276
+
277
+ @Field(type => ObjectRef, { nullable: true })
278
+ releaseGood: ObjectRef
66
279
  }
@@ -1,6 +1,3 @@
1
- import { User } from '@things-factory/auth-base'
2
- import { Bizplace } from '@things-factory/biz-base'
3
- import { Domain } from '@things-factory/shell'
4
1
  import { Field, ID, ObjectType } from 'type-graphql'
5
2
  import {
6
3
  Column,
@@ -9,15 +6,21 @@ import {
9
6
  Index,
10
7
  JoinColumn,
11
8
  ManyToOne,
9
+ OneToMany,
12
10
  OneToOne,
13
11
  PrimaryGeneratedColumn,
14
12
  RelationId,
15
13
  UpdateDateColumn
16
14
  } from 'typeorm'
17
- import { PurchaseOrder } from '../'
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'
18
21
 
19
22
  @Entity()
20
- @Index('ix_invoice_0', (invoice: Invoice) => [invoice.domain, invoice.name, invoice.customer])
23
+ @Index('ix_invoice_0', (invoice: Invoice) => [invoice.id], { unique: true })
21
24
  @ObjectType()
22
25
  export class Invoice {
23
26
  @PrimaryGeneratedColumn('uuid')
@@ -35,37 +38,168 @@ export class Invoice {
35
38
  @Field()
36
39
  name: string
37
40
 
38
- @ManyToOne(type => Bizplace)
39
- @Field(type => Bizplace, { nullable: true })
40
- customer: Bizplace
41
+ @Column({ nullable: true })
42
+ @Field({ nullable: true })
43
+ description: string
44
+
45
+ @OneToMany(type => InvoiceProduct, invoiceProduct => invoiceProduct.invoice)
46
+ invoiceProducts: InvoiceProduct[]
47
+
48
+ @OneToOne(type => ReleaseGood, { nullable: true })
49
+ @JoinColumn()
50
+ releaseGood: ReleaseGood
51
+
52
+ @Column({ default: '' })
53
+ @Field()
54
+ refNo1: string
55
+
56
+ @Column({ default: '' })
57
+ @Field()
58
+ refNo2: string
41
59
 
42
- @RelationId((invoice: Invoice) => invoice.customer)
43
- customerId: string
60
+ @Column({ default: '' })
61
+ @Field()
62
+ refNo3: string
44
63
 
45
- @Column('date')
64
+ @Column({ nullable: true })
46
65
  @Field()
47
66
  issuedOn: Date
48
67
 
49
- @Column('date')
68
+ @Column({ type: 'uuid', nullable: true })
69
+ @Field({ nullable: true })
70
+ contactPointRefId: string
71
+
72
+ @Column()
50
73
  @Field()
51
- paymentDue: Date
74
+ from: string
52
75
 
53
76
  @Column()
54
77
  @Field()
55
- version: string
78
+ fromContactPhone: string
56
79
 
57
- @OneToOne(type => PurchaseOrder)
58
- @JoinColumn()
59
- @Field(type => PurchaseOrder, { nullable: true })
60
- purchaseOrder: PurchaseOrder
80
+ @Column({ nullable: true })
81
+ @Field({ nullable: true })
82
+ fromAddress1: string
83
+
84
+ @Column({ nullable: true })
85
+ @Field({ nullable: true })
86
+ fromAddress2: string
87
+
88
+ @Column({ nullable: true })
89
+ @Field({ nullable: true })
90
+ fromAddress3: string
91
+
92
+ @Column({ nullable: true })
93
+ @Field({ nullable: true })
94
+ fromAddress4: string
95
+
96
+ @Column({ nullable: true })
97
+ @Field({ nullable: true })
98
+ fromAddress5: string
99
+
100
+ @Column({ nullable: true })
101
+ @Field({ nullable: true })
102
+ fromPostcode: string
103
+
104
+ @Column({ nullable: true })
105
+ @Field({ nullable: true })
106
+ fromCity: string
107
+
108
+ @Column({ nullable: true })
109
+ @Field({ nullable: true })
110
+ fromState: string
111
+
112
+ @Column({ nullable: true })
113
+ @Field({ nullable: true })
114
+ fromCountry: string
61
115
 
62
116
  @Column()
63
117
  @Field()
64
- state: string
118
+ deliverTo: string
119
+
120
+ @Column()
121
+ @Field()
122
+ deliverToPhone: string
123
+
124
+ @Column()
125
+ @Field()
126
+ deliveryAddress1: string
65
127
 
66
128
  @Column({ nullable: true })
67
129
  @Field({ nullable: true })
68
- description: string
130
+ deliveryAddress2: string
131
+
132
+ @Column({ nullable: true })
133
+ @Field({ nullable: true })
134
+ deliveryAddress3: string
135
+
136
+ @Column({ nullable: true })
137
+ @Field({ nullable: true })
138
+ deliveryAddress4: string
139
+
140
+ @Column({ nullable: true })
141
+ @Field({ nullable: true })
142
+ deliveryAddress5: string
143
+
144
+ @Column()
145
+ @Field()
146
+ deliveryPostcode: string
147
+
148
+ @Column()
149
+ @Field()
150
+ deliveryCity: string
151
+
152
+ @Column()
153
+ @Field()
154
+ deliveryState: string
155
+
156
+ @Column()
157
+ @Field()
158
+ deliveryCountry: string
159
+
160
+ @Column()
161
+ @Field()
162
+ billTo: string
163
+
164
+ @Column()
165
+ @Field()
166
+ billToPhone: string
167
+
168
+ @Column()
169
+ @Field()
170
+ billingAddress1: string
171
+
172
+ @Column({ nullable: true })
173
+ @Field({ nullable: true })
174
+ billingAddress2: string
175
+
176
+ @Column({ nullable: true })
177
+ @Field({ nullable: true })
178
+ billingAddress3: string
179
+
180
+ @Column({ nullable: true })
181
+ @Field({ nullable: true })
182
+ billingAddress4: string
183
+
184
+ @Column({ nullable: true })
185
+ @Field({ nullable: true })
186
+ billingAddress5: string
187
+
188
+ @Column()
189
+ @Field()
190
+ billingPostcode: string
191
+
192
+ @Column()
193
+ @Field()
194
+ billingCity: string
195
+
196
+ @Column()
197
+ @Field()
198
+ billingState: string
199
+
200
+ @Column()
201
+ @Field()
202
+ billingCountry: string
69
203
 
70
204
  @CreateDateColumn()
71
205
  @Field()
@@ -0,0 +1,9 @@
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'
@@ -0,0 +1,54 @@
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: any
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: any
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, 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: any): Promise<boolean> {
48
+ const { domain, tx } = context.state
49
+
50
+ await tx.getRepository(InvoiceProduct).delete({ domain, name })
51
+
52
+ return true
53
+ }
54
+ }