@things-factory/sales-base 3.8.25 → 3.8.29

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 (85) hide show
  1. package/dist-server/entities/index.js +6 -3
  2. package/dist-server/entities/index.js.map +1 -1
  3. package/dist-server/entities/invoice-product.js +94 -0
  4. package/dist-server/entities/invoice-product.js.map +1 -0
  5. package/dist-server/entities/invoice.js +163 -24
  6. package/dist-server/entities/invoice.js.map +1 -1
  7. package/dist-server/entities/release-good.js +3 -1
  8. package/dist-server/entities/release-good.js.map +1 -1
  9. package/dist-server/graphql/resolvers/index.js +3 -0
  10. package/dist-server/graphql/resolvers/index.js.map +1 -1
  11. package/dist-server/graphql/resolvers/invoice/create-invoice.js +17 -2
  12. package/dist-server/graphql/resolvers/invoice/create-invoice.js.map +1 -1
  13. package/dist-server/graphql/resolvers/invoice-product/create-invoice-product.js +12 -0
  14. package/dist-server/graphql/resolvers/invoice-product/create-invoice-product.js.map +1 -0
  15. package/dist-server/graphql/resolvers/invoice-product/delete-invoice-product.js +13 -0
  16. package/dist-server/graphql/resolvers/invoice-product/delete-invoice-product.js.map +1 -0
  17. package/dist-server/graphql/resolvers/invoice-product/delete-invoice-products.js +16 -0
  18. package/dist-server/graphql/resolvers/invoice-product/delete-invoice-products.js.map +1 -0
  19. package/dist-server/graphql/resolvers/invoice-product/index.js +12 -0
  20. package/dist-server/graphql/resolvers/invoice-product/index.js.map +1 -0
  21. package/dist-server/graphql/resolvers/invoice-product/invoice-product-query.js +33 -0
  22. package/dist-server/graphql/resolvers/invoice-product/invoice-product-query.js.map +1 -0
  23. package/dist-server/graphql/resolvers/invoice-product/update-invoice-product.js +16 -0
  24. package/dist-server/graphql/resolvers/invoice-product/update-invoice-product.js.map +1 -0
  25. package/dist-server/graphql/resolvers/invoice-product/update-multiple-invoice-product.js +31 -0
  26. package/dist-server/graphql/resolvers/invoice-product/update-multiple-invoice-product.js.map +1 -0
  27. package/dist-server/graphql/resolvers/purchase-order/create-purchase-order.js +5 -5
  28. package/dist-server/graphql/resolvers/purchase-order/create-purchase-order.js.map +1 -1
  29. package/dist-server/graphql/resolvers/purchase-order/update-purchase-order.js +12 -23
  30. package/dist-server/graphql/resolvers/purchase-order/update-purchase-order.js.map +1 -1
  31. package/dist-server/graphql/resolvers/purchase-order/upsert-purchase-order.js +5 -7
  32. package/dist-server/graphql/resolvers/purchase-order/upsert-purchase-order.js.map +1 -1
  33. package/dist-server/graphql/types/index.js +4 -0
  34. package/dist-server/graphql/types/index.js.map +1 -1
  35. package/dist-server/graphql/types/invoice/invoice-patch.js +38 -5
  36. package/dist-server/graphql/types/invoice/invoice-patch.js.map +1 -1
  37. package/dist-server/graphql/types/invoice/invoice.js +38 -4
  38. package/dist-server/graphql/types/invoice/invoice.js.map +1 -1
  39. package/dist-server/graphql/types/invoice/new-invoice.js +42 -8
  40. package/dist-server/graphql/types/invoice/new-invoice.js.map +1 -1
  41. package/dist-server/graphql/types/invoice-product/index.js +21 -0
  42. package/dist-server/graphql/types/invoice-product/index.js.map +1 -0
  43. package/dist-server/graphql/types/invoice-product/invoice-product-list.js +14 -0
  44. package/dist-server/graphql/types/invoice-product/invoice-product-list.js.map +1 -0
  45. package/dist-server/graphql/types/invoice-product/invoice-product-patch.js +21 -0
  46. package/dist-server/graphql/types/invoice-product/invoice-product-patch.js.map +1 -0
  47. package/dist-server/graphql/types/invoice-product/invoice-product.js +27 -0
  48. package/dist-server/graphql/types/invoice-product/invoice-product.js.map +1 -0
  49. package/dist-server/graphql/types/invoice-product/new-invoice-product.js +21 -0
  50. package/dist-server/graphql/types/invoice-product/new-invoice-product.js.map +1 -0
  51. package/dist-server/graphql/types/invoice-product/product-input.js +13 -0
  52. package/dist-server/graphql/types/invoice-product/product-input.js.map +1 -0
  53. package/dist-server/graphql/types/purchase-order/index.js +1 -1
  54. package/dist-server/graphql/types/purchase-order/index.js.map +1 -1
  55. package/dist-server/utils/order-no-generator.js +7 -0
  56. package/dist-server/utils/order-no-generator.js.map +1 -1
  57. package/package.json +6 -6
  58. package/server/entities/index.ts +6 -3
  59. package/server/entities/invoice-product.ts +64 -0
  60. package/server/entities/invoice.ts +127 -19
  61. package/server/entities/release-good.ts +2 -0
  62. package/server/graphql/resolvers/index.ts +3 -0
  63. package/server/graphql/resolvers/invoice/create-invoice.ts +43 -6
  64. package/server/graphql/resolvers/invoice-product/create-invoice-product.ts +16 -0
  65. package/server/graphql/resolvers/invoice-product/delete-invoice-product.ts +13 -0
  66. package/server/graphql/resolvers/invoice-product/delete-invoice-products.ts +16 -0
  67. package/server/graphql/resolvers/invoice-product/index.ts +18 -0
  68. package/server/graphql/resolvers/invoice-product/invoice-product-query.ts +38 -0
  69. package/server/graphql/resolvers/invoice-product/update-invoice-product.ts +19 -0
  70. package/server/graphql/resolvers/invoice-product/update-multiple-invoice-product.ts +46 -0
  71. package/server/graphql/resolvers/purchase-order/create-purchase-order.ts +33 -32
  72. package/server/graphql/resolvers/purchase-order/update-purchase-order.ts +10 -8
  73. package/server/graphql/resolvers/purchase-order/upsert-purchase-order.ts +21 -32
  74. package/server/graphql/types/index.ts +4 -0
  75. package/server/graphql/types/invoice/invoice-patch.ts +38 -5
  76. package/server/graphql/types/invoice/invoice.ts +38 -4
  77. package/server/graphql/types/invoice/new-invoice.ts +42 -8
  78. package/server/graphql/types/invoice-product/index.ts +20 -0
  79. package/server/graphql/types/invoice-product/invoice-product-list.ts +8 -0
  80. package/server/graphql/types/invoice-product/invoice-product-patch.ts +15 -0
  81. package/server/graphql/types/invoice-product/invoice-product.ts +21 -0
  82. package/server/graphql/types/invoice-product/new-invoice-product.ts +15 -0
  83. package/server/graphql/types/invoice-product/product-input.ts +7 -0
  84. package/server/graphql/types/purchase-order/index.ts +1 -4
  85. package/server/utils/order-no-generator.ts +11 -0
@@ -8,7 +8,7 @@ const purchase_order_patch_1 = require("./purchase-order-patch");
8
8
  exports.Mutation = `
9
9
  upsertPurchaseOrder (
10
10
  purchaseOrder: PurchaseOrderPatch!
11
- file: Upload
11
+ files: [Upload!]
12
12
  ): PurchaseOrder @privilege(category: "order_customer", privilege: "mutation") @transaction
13
13
 
14
14
  approvePurchaseOrder (
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/purchase-order/index.ts"],"names":[],"mappings":";;;AAEA,6DAAuD;AACvD,qDAAgD;AAChD,+DAAyD;AACzD,iEAA2D;AAG9C,QAAA,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BvB,CAAA;AAEY,QAAA,KAAK,GAAG;;;CAGpB,CAAA;AAEY,QAAA,KAAK,GAAG,CAAC,8BAAa,EAAE,qCAAgB,EAAE,yCAAkB,EAAE,uCAAiB,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/purchase-order/index.ts"],"names":[],"mappings":";;;AAAA,6DAAuD;AACvD,qDAAgD;AAChD,+DAAyD;AACzD,iEAA2D;AAE9C,QAAA,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BvB,CAAA;AAEY,QAAA,KAAK,GAAG;;;CAGpB,CAAA;AAEY,QAAA,KAAK,GAAG,CAAC,8BAAa,EAAE,qCAAgB,EAAE,yCAAkB,EAAE,uCAAiB,CAAC,CAAA"}
@@ -40,6 +40,9 @@ class OrderNoGenerator {
40
40
  static orderProduct() {
41
41
  return `OP-${(0, v4_1.default)()}`;
42
42
  }
43
+ static invoiceProduct() {
44
+ return `IP-${(0, v4_1.default)()}`;
45
+ }
43
46
  static orderVas() {
44
47
  return `OV-${(0, v4_1.default)()}`;
45
48
  }
@@ -78,6 +81,10 @@ class OrderNoGenerator {
78
81
  const currentDate = new Date();
79
82
  return `VO-${currentDate.getFullYear()}${currentDate.getMonth() + 1}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`;
80
83
  }
84
+ static invoice() {
85
+ const currentDate = new Date();
86
+ return `INV-${currentDate.getFullYear()}${currentDate.getMonth() + 1}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`;
87
+ }
81
88
  }
82
89
  exports.OrderNoGenerator = OrderNoGenerator;
83
90
  //# sourceMappingURL=order-no-generator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"order-no-generator.js","sourceRoot":"","sources":["../../server/utils/order-no-generator.ts"],"names":[],"mappings":";;;;;;AAAA,iDAA0B;AAE1B,MAAa,gBAAgB;IAC3B,MAAM,CAAC,aAAa;QAClB,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAA;QAC9B,OAAO,OAAO,WAAW,CAAC,WAAW,EAAE,GACrC,WAAW,CAAC,QAAQ,EAAE,GAAG,CAC3B,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,WAAW,CAAC,eAAe,EAAE,EAAE,CAAA;IAC3I,CAAC;IAED,MAAM,CAAC,eAAe;QACpB,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAA;QAC9B,OAAO,MAAM,WAAW,CAAC,WAAW,EAAE,GACpC,WAAW,CAAC,QAAQ,EAAE,GAAG,CAC3B,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,WAAW,CAAC,eAAe,EAAE,EAAE,CAAA;IAC3I,CAAC;IAED,MAAM,CAAC,UAAU;QACf,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAA;QAC9B,OAAO,MAAM,WAAW,CAAC,WAAW,EAAE,GACpC,WAAW,CAAC,QAAQ,EAAE,GAAG,CAC3B,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,QAAQ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W,EAAE,GACpC,WAAW,CAAC,QAAQ,EAAE,GAAG,CAC3B,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,WAAW,CAAC,eAAe,EAAE,EAAE,CAAA;IAC3I,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAA;QAC9B,OAAO,OAAO,WAAW,CAAC,WAAW,EAAE,GACrC,WAAW,CAAC,QAAQ,EAAE,GAAG,CAC3B,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,WAAW,CAAC,eAAe,EAAE,EAAE,CAAA;IAC3I,CAAC;CACF;AApID,4CAoIC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/sales-base",
3
- "version": "3.8.25",
3
+ "version": "3.8.29",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -26,14 +26,14 @@
26
26
  "dependencies": {
27
27
  "@things-factory/attachment-base": "^3.8.0",
28
28
  "@things-factory/auth-base": "^3.8.0",
29
- "@things-factory/biz-base": "^3.8.0",
29
+ "@things-factory/biz-base": "^3.8.29",
30
30
  "@things-factory/code-base": "^3.8.0",
31
31
  "@things-factory/notification": "^3.8.0",
32
- "@things-factory/product-base": "^3.8.9",
32
+ "@things-factory/product-base": "^3.8.29",
33
33
  "@things-factory/setting-base": "^3.8.0",
34
34
  "@things-factory/shell": "^3.8.0",
35
- "@things-factory/transport-base": "^3.8.0",
36
- "@things-factory/warehouse-base": "^3.8.25"
35
+ "@things-factory/transport-base": "^3.8.29",
36
+ "@things-factory/warehouse-base": "^3.8.29"
37
37
  },
38
- "gitHead": "65fc6a560f15143d908bb290e70f4f87f6575c7f"
38
+ "gitHead": "aab48875c1a169b2d75f9fe8aa6af029c3d5b3dd"
39
39
  }
@@ -1,4 +1,3 @@
1
- import { Manifest } from './manifest'
2
1
  import { ArrivalNotice } from './arrival-notice'
3
2
  import { Claim } from './claim'
4
3
  import { ClaimDetail } from './claim-detail'
@@ -8,7 +7,9 @@ import { DeliveryOrder } from './delivery-order'
8
7
  import { GoodsReceivalNote } from './goods-receival-note'
9
8
  import { InventoryCheck } from './inventory-check'
10
9
  import { Invoice } from './invoice'
10
+ import { InvoiceProduct } from './invoice-product'
11
11
  import { JobSheet } from './job-sheet'
12
+ import { Manifest } from './manifest'
12
13
  import { OrderInventory } from './order-inventory'
13
14
  import { OrderProduct } from './order-product'
14
15
  import { OrderReverseKitting } from './order-reverse-kitting'
@@ -25,7 +26,8 @@ import { Vas } from './vas'
25
26
  import { VasOrder } from './vas-order'
26
27
 
27
28
  export const entities = [
28
- Manifest,
29
+ InvoiceProduct,
30
+ Manifest,
29
31
  PurchaseOrderOtherCharge,
30
32
  ArrivalNotice,
31
33
  OrderProduct,
@@ -53,7 +55,6 @@ export const entities = [
53
55
  ]
54
56
 
55
57
  export {
56
- Manifest,
57
58
  ArrivalNotice,
58
59
  Claim,
59
60
  ClaimDetail,
@@ -63,7 +64,9 @@ export {
63
64
  GoodsReceivalNote,
64
65
  InventoryCheck,
65
66
  Invoice,
67
+ InvoiceProduct,
66
68
  JobSheet,
69
+ Manifest,
67
70
  OrderInventory,
68
71
  OrderProduct,
69
72
  OrderReverseKitting,
@@ -0,0 +1,64 @@
1
+ import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
2
+
3
+ import { User } from '@things-factory/auth-base'
4
+ import { Product } from '@things-factory/product-base'
5
+ import { Domain } from '@things-factory/shell'
6
+
7
+ import { Invoice } from './invoice'
8
+
9
+ @Entity()
10
+ @Index('ix_invoice_product_0', (invoiceProduct: InvoiceProduct) => [invoiceProduct.id], {
11
+ unique: true
12
+ })
13
+ export class InvoiceProduct {
14
+ @PrimaryGeneratedColumn('uuid')
15
+ id: string
16
+
17
+ @ManyToOne(type => Domain)
18
+ domain: Domain
19
+
20
+ @Column({ nullable: true })
21
+ sku: string
22
+
23
+ @Column()
24
+ name: string
25
+
26
+ @Column({
27
+ nullable: true
28
+ })
29
+ description: string
30
+
31
+ @ManyToOne(type => Invoice)
32
+ invoice: Invoice
33
+
34
+ @ManyToOne(type => Product, { nullable: true })
35
+ product: Product
36
+
37
+ @Column('int', { default: 0 })
38
+ qty: number
39
+
40
+ @Column('float', { default: 0 })
41
+ otherCharges: number
42
+
43
+ @Column('float', { default: 0 })
44
+ unitPrice: number
45
+
46
+ @Column('float', { default: 0 })
47
+ paidPrice: number
48
+
49
+ @CreateDateColumn()
50
+ createdAt: Date
51
+
52
+ @UpdateDateColumn()
53
+ updatedAt: Date
54
+
55
+ @ManyToOne(type => User, {
56
+ nullable: true
57
+ })
58
+ creator: User
59
+
60
+ @ManyToOne(type => User, {
61
+ nullable: true
62
+ })
63
+ updater: User
64
+ }
@@ -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 {
5
2
  Column,
6
3
  CreateDateColumn,
@@ -8,14 +5,20 @@ import {
8
5
  Index,
9
6
  JoinColumn,
10
7
  ManyToOne,
8
+ OneToMany,
11
9
  OneToOne,
12
10
  PrimaryGeneratedColumn,
13
11
  UpdateDateColumn
14
12
  } from 'typeorm'
15
- import { PurchaseOrder } from './purchase-order'
13
+
14
+ import { User } from '@things-factory/auth-base'
15
+ import { Domain } from '@things-factory/shell'
16
+
17
+ import { ReleaseGood } from '../entities'
18
+ import { InvoiceProduct } from './invoice-product'
16
19
 
17
20
  @Entity()
18
- @Index('ix_invoice_0', (invoice: Invoice) => [invoice.domain, invoice.name, invoice.customer])
21
+ @Index('ix_invoice_0', (invoice: Invoice) => [invoice.id], { unique: true })
19
22
  export class Invoice {
20
23
  @PrimaryGeneratedColumn('uuid')
21
24
  id: string
@@ -26,29 +29,134 @@ export class Invoice {
26
29
  @Column()
27
30
  name: string
28
31
 
29
- @ManyToOne(type => Bizplace)
30
- customer: Bizplace
32
+ @Column({
33
+ nullable: true
34
+ })
35
+ description: string
31
36
 
32
- @Column('date')
33
- issuedOn: Date
37
+ @OneToMany(type => InvoiceProduct, invoiceProduct => invoiceProduct.invoice)
38
+ invoiceProducts: InvoiceProduct[]
34
39
 
35
- @Column('date')
36
- paymentDue: Date
40
+ @OneToOne(type => ReleaseGood, { nullable: true })
41
+ @JoinColumn()
42
+ releaseGood: ReleaseGood
37
43
 
38
- @Column()
39
- version: string
44
+ @Column({ default: '' })
45
+ refNo1: string
40
46
 
41
- @OneToOne(type => PurchaseOrder)
42
- @JoinColumn()
43
- purchaseOrder: PurchaseOrder
47
+ @Column({ default: '' })
48
+ refNo2: string
44
49
 
45
- @Column()
46
- state: string
50
+ @Column({ default: '' })
51
+ refNo3: string
52
+
53
+ @Column({ nullable: true })
54
+ issuedOn: Date
47
55
 
48
56
  @Column({
57
+ type: 'uuid',
49
58
  nullable: true
50
59
  })
51
- description: string
60
+ contactPointRefId: string
61
+
62
+ @Column()
63
+ from: string
64
+
65
+ @Column()
66
+ fromContactPhone: string
67
+
68
+ @Column({ nullable: true })
69
+ fromAddress1: string
70
+
71
+ @Column({ nullable: true })
72
+ fromAddress2: string
73
+
74
+ @Column({ nullable: true })
75
+ fromAddress3: string
76
+
77
+ @Column({ nullable: true })
78
+ fromAddress4: string
79
+
80
+ @Column({ nullable: true })
81
+ fromAddress5: string
82
+
83
+ @Column({ nullable: true })
84
+ fromPostcode: string
85
+
86
+ @Column({ nullable: true })
87
+ fromCity: string
88
+
89
+ @Column({ nullable: true })
90
+ fromState: string
91
+
92
+ @Column({ nullable: true })
93
+ fromCountry: string
94
+
95
+ @Column()
96
+ deliverTo: string
97
+
98
+ @Column()
99
+ deliverToPhone: string
100
+
101
+ @Column()
102
+ deliveryAddress1: string
103
+
104
+ @Column({ nullable: true })
105
+ deliveryAddress2: string
106
+
107
+ @Column({ nullable: true })
108
+ deliveryAddress3: string
109
+
110
+ @Column({ nullable: true })
111
+ deliveryAddress4: string
112
+
113
+ @Column({ nullable: true })
114
+ deliveryAddress5: string
115
+
116
+ @Column()
117
+ deliveryPostcode: string
118
+
119
+ @Column()
120
+ deliveryCity: string
121
+
122
+ @Column()
123
+ deliveryState: string
124
+
125
+ @Column()
126
+ deliveryCountry: string
127
+
128
+ @Column()
129
+ billTo: string
130
+
131
+ @Column()
132
+ billToPhone: string
133
+
134
+ @Column()
135
+ billingAddress1: string
136
+
137
+ @Column({ nullable: true })
138
+ billingAddress2: string
139
+
140
+ @Column({ nullable: true })
141
+ billingAddress3: string
142
+
143
+ @Column({ nullable: true })
144
+ billingAddress4: string
145
+
146
+ @Column({ nullable: true })
147
+ billingAddress5: string
148
+
149
+ @Column()
150
+ billingPostcode: string
151
+
152
+ @Column()
153
+ billingCity: string
154
+
155
+ @Column()
156
+ billingState: string
157
+
158
+ @Column()
159
+ billingCountry: string
52
160
 
53
161
  @ManyToOne(type => User, {
54
162
  nullable: true
@@ -40,6 +40,8 @@ export enum DispatchmentStatus {
40
40
  }
41
41
  @Entity()
42
42
  @Index('ix_release-good_0', (releaseGood: ReleaseGood) => [releaseGood.domain, releaseGood.name], { unique: true })
43
+ @Index('ix_release-good_1', (releaseGood: ReleaseGood) => [releaseGood.domain, releaseGood.refNo])
44
+ @Index('ix_release-good_2', (releaseGood: ReleaseGood) => [releaseGood.domain, releaseGood.refNo2])
43
45
  export class ReleaseGood {
44
46
  @PrimaryGeneratedColumn('uuid')
45
47
  id: string
@@ -7,6 +7,7 @@ import * as DeliveryOrder from './delivery-order'
7
7
  import * as GoodsReceivalNote from './goods-receival-note'
8
8
  import * as InventoryCheck from './inventory-check'
9
9
  import * as Invoice from './invoice'
10
+ import * as InvoiceProduct from './invoice-product'
10
11
  import * as JobSheet from './job-sheet'
11
12
  import * as Manifest from './manifest'
12
13
  import * as OrderInventory from './order-inventory'
@@ -27,6 +28,7 @@ import * as VasOrder from './vas-order'
27
28
 
28
29
  export const queries = [
29
30
  Invoice.Query,
31
+ InvoiceProduct.Query,
30
32
  InventoryCheck.Query,
31
33
  JobSheet.Query,
32
34
  PurchaseOrder.Query,
@@ -55,6 +57,7 @@ export const queries = [
55
57
 
56
58
  export const mutations = [
57
59
  Invoice.Mutation,
60
+ InvoiceProduct.Mutation,
58
61
  JobSheet.Mutation,
59
62
  InventoryCheck.Mutation,
60
63
  PurchaseOrder.Mutation,
@@ -1,17 +1,54 @@
1
+ import { EntityManager, getRepository, Repository } from 'typeorm'
2
+
1
3
  import { User } from '@things-factory/auth-base'
4
+ import { Product } from '@things-factory/product-base'
2
5
  import { Domain } from '@things-factory/shell'
3
- import { EntityManager } from 'typeorm'
4
- import { Invoice } from '../../../entities'
6
+
7
+ import { Invoice, InvoiceProduct, ReleaseGood } from '../../../entities'
8
+ import { OrderNoGenerator } from '../../../utils'
5
9
 
6
10
  export const createInvoice = {
7
11
  async createInvoice(_: any, { invoice }, context: any) {
8
12
  const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
13
+ let invoiceProducts: InvoiceProduct[] = invoice.invoiceProducts
9
14
 
10
- return await tx.getRepository(Invoice).save({
11
- domain,
15
+ let createdInvoice: Invoice = await tx.getRepository(Invoice).save({
12
16
  ...invoice,
13
- creator: user,
14
- updater: user
17
+ domain,
18
+ name: OrderNoGenerator.invoice(),
19
+ releaseGood: await tx.getRepository(ReleaseGood).findOne(invoice?.releaseGood.id),
20
+ creator: user
15
21
  })
22
+
23
+ await addInvoiceProducts(domain, createdInvoice, invoiceProducts, user, tx)
24
+
25
+ return createdInvoice
16
26
  }
17
27
  }
28
+
29
+ export async function addInvoiceProducts(
30
+ domain: Domain,
31
+ invoice: Invoice,
32
+ invoiceProducts: any[],
33
+ user: User,
34
+ tx?: EntityManager
35
+ ): Promise<void> {
36
+ const productRepo: Repository<Product> = tx?.getRepository(Product) || getRepository(Product)
37
+ const invoiceProductRepo: Repository<InvoiceProduct> =
38
+ tx?.getRepository(InvoiceProduct) || getRepository(InvoiceProduct)
39
+
40
+ const createdInvoiceProducts: InvoiceProduct[] = await Promise.all(
41
+ invoiceProducts.map(async (invoiceProduct: InvoiceProduct) => {
42
+ return {
43
+ name: OrderNoGenerator.invoiceProduct(),
44
+ ...invoiceProduct,
45
+ domain,
46
+ product: await productRepo.findOne(invoiceProduct?.product.id),
47
+ invoice,
48
+ creator: user
49
+ }
50
+ })
51
+ )
52
+
53
+ await invoiceProductRepo.save(createdInvoiceProducts)
54
+ }
@@ -0,0 +1,16 @@
1
+ import { getRepository } from 'typeorm'
2
+ import { InvoiceProduct } from '../../../entities'
3
+
4
+ export const createInvoiceProduct = {
5
+ async createInvoiceProduct(_: any, { invoiceProduct }, context: any) {
6
+ const { domain, user } = context.state
7
+
8
+ return await getRepository(InvoiceProduct).save({
9
+ ...invoiceProduct,
10
+ domain,
11
+ creator: user,
12
+ updater: user
13
+ })
14
+ }
15
+ }
16
+
@@ -0,0 +1,13 @@
1
+ import { getRepository } from 'typeorm'
2
+ import { InvoiceProduct } from '../../../entities'
3
+
4
+ export const deleteInvoiceProduct = {
5
+ async deleteInvoiceProduct(_: any, { name }, context: any) {
6
+ const { domain, user } = context.state
7
+
8
+ await getRepository(InvoiceProduct).delete({ domain, name })
9
+
10
+ return true
11
+ }
12
+ }
13
+
@@ -0,0 +1,16 @@
1
+ import { getRepository, In } from 'typeorm'
2
+ import { InvoiceProduct } from '../../../entities'
3
+
4
+ export const deleteInvoiceProducts = {
5
+ async deleteInvoiceProducts(_: any, { names }, context: any) {
6
+ const { domain, user } = context.state
7
+
8
+ await getRepository(InvoiceProduct).delete({
9
+ domain,
10
+ name: In(names)
11
+ })
12
+
13
+ return true
14
+ }
15
+ }
16
+
@@ -0,0 +1,18 @@
1
+ import { createInvoiceProduct } from './create-invoice-product'
2
+ import { deleteInvoiceProduct } from './delete-invoice-product'
3
+ import { deleteInvoiceProducts } from './delete-invoice-products'
4
+ import { Query as InvoiceProductQuery } from './invoice-product-query'
5
+ import { updateInvoiceProduct } from './update-invoice-product'
6
+ import { updateMultipleInvoiceProduct } from './update-multiple-invoice-product'
7
+
8
+ export const Query = {
9
+ ...InvoiceProductQuery
10
+ }
11
+
12
+ export const Mutation = {
13
+ ...updateInvoiceProduct,
14
+ ...updateMultipleInvoiceProduct,
15
+ ...createInvoiceProduct,
16
+ ...deleteInvoiceProduct,
17
+ ...deleteInvoiceProducts
18
+ }
@@ -0,0 +1,38 @@
1
+ import { getRepository } from 'typeorm'
2
+ import { Domain, ListParam, convertListParams } from '@things-factory/shell'
3
+ import { User } from '@things-factory/auth-base'
4
+ import { InvoiceProduct as InvoiceProductEntity } from '../../../entities'
5
+
6
+ export const Query = {
7
+ async invoiceProduct(_: any, { name }, context: any) {
8
+ const { domain, user } = context.state
9
+ const repository = getRepository(InvoiceProductEntity)
10
+
11
+ return await repository.findOne({
12
+ where: { domain, name }
13
+ })
14
+ },
15
+
16
+ async invoiceProducts(_: any, params: ListParam, context: any) {
17
+ const convertedParams = convertListParams(params)
18
+ const [items, total] = await getRepository(InvoiceProductEntity).findAndCount({
19
+ ...convertedParams
20
+ })
21
+
22
+ return { items, total }
23
+ }
24
+ }
25
+
26
+ export const InvoiceProduct = {
27
+ async domain(invoiceProduct) {
28
+ return await getRepository(Domain).findOne(invoiceProduct.domainId)
29
+ },
30
+
31
+ async creator(invoiceProduct) {
32
+ return await getRepository(User).findOne(invoiceProduct.creatorId)
33
+ },
34
+
35
+ async updater(invoiceProduct) {
36
+ return await getRepository(User).findOne(invoiceProduct.updaterId)
37
+ }
38
+ }
@@ -0,0 +1,19 @@
1
+ import { getRepository } from 'typeorm'
2
+ import { InvoiceProduct } from '../../../entities'
3
+
4
+ export const updateInvoiceProduct = {
5
+ async updateInvoiceProduct(_: any, { name, patch }, context: any) {
6
+ const { domain, user } = context.state
7
+
8
+ const repository = getRepository(InvoiceProduct)
9
+ const invoiceProduct = await repository.findOne({
10
+ where: { domain, name }
11
+ })
12
+
13
+ return await repository.save({
14
+ ...invoiceProduct,
15
+ ...patch,
16
+ updater: user
17
+ })
18
+ }
19
+ }
@@ -0,0 +1,46 @@
1
+ import { getRepository } from 'typeorm'
2
+ import { InvoiceProduct } from '../../../entities'
3
+
4
+ export const updateMultipleInvoiceProduct = {
5
+ async updateMultipleInvoiceProduct(_: any, { patches }, context: any) {
6
+ const { domain, user } = context.state
7
+
8
+ let results = []
9
+ const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
10
+ const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
11
+ const invoiceProductRepo = getRepository(InvoiceProduct)
12
+
13
+ if (_createRecords.length > 0) {
14
+ for (let i = 0; i < _createRecords.length; i++) {
15
+ const newRecord = _createRecords[i]
16
+
17
+ const result = await invoiceProductRepo.save({
18
+ ...newRecord,
19
+ domain: domain,
20
+ creator: user,
21
+ updater: user,
22
+ })
23
+
24
+ results.push({ ...result, cuFlag: '+' })
25
+ }
26
+ }
27
+
28
+ if (_updateRecords.length > 0) {
29
+ for (let i = 0; i < _updateRecords.length; i++) {
30
+ const newRecord = _updateRecords[i]
31
+ const invoiceProduct = await invoiceProductRepo.findOne({ domain, id: newRecord.id})
32
+
33
+ const result = await invoiceProductRepo.save({
34
+ ...invoiceProduct,
35
+ ...newRecord,
36
+ updater: user
37
+ })
38
+
39
+ results.push({ ...result, cuFlag: 'M' })
40
+ }
41
+ }
42
+
43
+ return results
44
+ }
45
+ }
46
+