@things-factory/sales-base 4.0.10 → 4.0.14
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/dist-server/constants/order.js +9 -1
- package/dist-server/constants/order.js.map +1 -1
- package/dist-server/constants/validation-error-code.js +2 -1
- package/dist-server/constants/validation-error-code.js.map +1 -1
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +3 -3
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js +21 -0
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-query.js +74 -77
- package/dist-server/service/arrival-notice/arrival-notice-query.js.map +1 -1
- package/dist-server/service/delivery-order/delivery-order-query.js +21 -5
- package/dist-server/service/delivery-order/delivery-order-query.js.map +1 -1
- package/dist-server/service/goods-receival-note/goods-receival-note-query.js +93 -43
- package/dist-server/service/goods-receival-note/goods-receival-note-query.js.map +1 -1
- package/dist-server/service/index.js +4 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/manifest/index.js +9 -0
- package/dist-server/service/manifest/index.js.map +1 -0
- package/dist-server/service/manifest/manifest-mutation.js +111 -0
- package/dist-server/service/manifest/manifest-mutation.js.map +1 -0
- package/dist-server/service/manifest/manifest-query.js +128 -0
- package/dist-server/service/manifest/manifest-query.js.map +1 -0
- package/dist-server/service/manifest/manifest-type.js +125 -0
- package/dist-server/service/manifest/manifest-type.js.map +1 -0
- package/dist-server/service/manifest/manifest.js +122 -0
- package/dist-server/service/manifest/manifest.js.map +1 -0
- package/dist-server/service/order-inventory/order-inventory-mutation.js +24 -0
- package/dist-server/service/order-inventory/order-inventory-mutation.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-query.js +20 -19
- package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-types.js +17 -13
- package/dist-server/service/order-inventory/order-inventory-types.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory.js +24 -2
- package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
- package/dist-server/service/others/other-query.js +1 -0
- package/dist-server/service/others/other-query.js.map +1 -1
- package/dist-server/service/others/other-types.js +4 -0
- package/dist-server/service/others/other-types.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +393 -1
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-query.js +160 -0
- package/dist-server/service/release-good/release-good-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-types.js +34 -2
- package/dist-server/service/release-good/release-good-types.js.map +1 -1
- package/dist-server/service/release-good/release-good.js +28 -1
- package/dist-server/service/release-good/release-good.js.map +1 -1
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-mutation.js +110 -30
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-mutation.js.map +1 -1
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-query.js +94 -21
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-query.js.map +1 -1
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-type.js +144 -1
- package/dist-server/service/reverse-kitting-order/reverse-kitting-order-type.js.map +1 -1
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.js +17 -7
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.js.map +1 -1
- package/dist-server/utils/inventory-util.js +26 -7
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/dist-server/utils/order-no-generator.js +35 -31
- package/dist-server/utils/order-no-generator.js.map +1 -1
- package/package.json +12 -12
- package/server/constants/index.ts +1 -1
- package/server/constants/order.ts +10 -0
- package/server/constants/validation-error-code.ts +3 -2
- package/server/controllers/ecommerce/sellercraft-controller.ts +4 -3
- package/server/service/arrival-notice/arrival-notice-mutation.ts +20 -0
- package/server/service/arrival-notice/arrival-notice-query.ts +82 -78
- package/server/service/delivery-order/delivery-order-query.ts +26 -7
- package/server/service/goods-receival-note/goods-receival-note-query.ts +116 -53
- package/server/service/index.ts +4 -0
- package/server/service/manifest/index.ts +6 -0
- package/server/service/manifest/manifest-mutation.ts +102 -0
- package/server/service/manifest/manifest-query.ts +99 -0
- package/server/service/manifest/manifest-type.ts +78 -0
- package/server/service/manifest/manifest.ts +103 -0
- package/server/service/order-inventory/order-inventory-mutation.ts +26 -1
- package/server/service/order-inventory/order-inventory-query.ts +17 -18
- package/server/service/order-inventory/order-inventory-types.ts +15 -10
- package/server/service/order-inventory/order-inventory.ts +24 -5
- package/server/service/others/other-query.ts +2 -6
- package/server/service/others/other-types.ts +3 -0
- package/server/service/release-good/release-good-mutation.ts +557 -0
- package/server/service/release-good/release-good-query.ts +197 -2
- package/server/service/release-good/release-good-types.ts +31 -7
- package/server/service/release-good/release-good.ts +26 -0
- package/server/service/reverse-kitting-order/reverse-kitting-order-mutation.ts +145 -35
- package/server/service/reverse-kitting-order/reverse-kitting-order-query.ts +103 -19
- package/server/service/reverse-kitting-order/reverse-kitting-order-type.ts +106 -1
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.ts +31 -14
- package/server/utils/inventory-util.ts +30 -7
- package/server/utils/order-no-generator.ts +43 -36
- package/dist-server/middlewares/index.js +0 -1
- package/dist-server/middlewares/index.js.map +0 -1
- package/server/middlewares/index.ts +0 -0
|
@@ -3,13 +3,15 @@ import { getRepository, In } from 'typeorm'
|
|
|
3
3
|
|
|
4
4
|
import { User } from '@things-factory/auth-base'
|
|
5
5
|
import { Bizplace, getPermittedBizplaceIds } from '@things-factory/biz-base'
|
|
6
|
+
import { generateId } from '@things-factory/id-rule-base'
|
|
7
|
+
import { Product, ProductDetail } from '@things-factory/product-base'
|
|
6
8
|
import { convertListParams, Domain, ListParam } from '@things-factory/shell'
|
|
7
9
|
import { Inventory, INVENTORY_STATUS } from '@things-factory/warehouse-base'
|
|
8
10
|
|
|
9
11
|
import { ORDER_VAS_STATUS } from '../../constants'
|
|
10
12
|
import { ReverseKittingOrderInventory } from '../reverse-kitting-order-inventory/reverse-kitting-order-inventory'
|
|
11
13
|
import { ReverseKittingOrder } from './reverse-kitting-order'
|
|
12
|
-
import { ReverseKittingOrderList } from './reverse-kitting-order-type'
|
|
14
|
+
import { LotInfo, ReverseKittingOrderList, ReverseKittingInventoryDetail } from './reverse-kitting-order-type'
|
|
13
15
|
|
|
14
16
|
@Resolver(ReverseKittingOrder)
|
|
15
17
|
export class ReverseKittingOrderQuery {
|
|
@@ -26,13 +28,13 @@ export class ReverseKittingOrderQuery {
|
|
|
26
28
|
relations: [
|
|
27
29
|
'domain',
|
|
28
30
|
'bizplace',
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
'
|
|
31
|
+
'reverseKittingOrderInventories',
|
|
32
|
+
'reverseKittingOrderInventories.vas',
|
|
33
|
+
'reverseKittingOrderInventories.inventory',
|
|
34
|
+
'reverseKittingOrderInventories.inventory.product',
|
|
35
|
+
'reverseKittingOrderInventories.inventory.location',
|
|
36
|
+
'reverseKittingOrderInventories.inventory.warehouse',
|
|
37
|
+
'reverseKittingOrderInventories.targetProduct',
|
|
36
38
|
'creator',
|
|
37
39
|
'updater'
|
|
38
40
|
]
|
|
@@ -41,37 +43,119 @@ export class ReverseKittingOrderQuery {
|
|
|
41
43
|
|
|
42
44
|
@Query(returns => ReverseKittingOrder, { description: 'To fetch a ReverseKittingOrder' })
|
|
43
45
|
async reverseKittingInventories(
|
|
44
|
-
@Arg('
|
|
46
|
+
@Arg('reverseKittingOIName') reverseKittingOIName: string,
|
|
47
|
+
@Arg('productDetailId') productDetailId: string,
|
|
45
48
|
@Ctx() context: any
|
|
46
49
|
): Promise<Inventory[]> {
|
|
47
50
|
const { domain } = context.state
|
|
48
|
-
|
|
51
|
+
|
|
52
|
+
const productDetail: ProductDetail = await getRepository(ProductDetail).findOne({
|
|
53
|
+
where: { id: productDetailId },
|
|
54
|
+
relations: ['product']
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const product: Product = productDetail.product
|
|
58
|
+
|
|
59
|
+
const foundReverseKittingOI: ReverseKittingOrderInventory = await getRepository(
|
|
49
60
|
ReverseKittingOrderInventory
|
|
50
61
|
).findOne({
|
|
51
62
|
where: {
|
|
52
63
|
domain,
|
|
53
|
-
name:
|
|
64
|
+
name: reverseKittingOIName,
|
|
54
65
|
status: ORDER_VAS_STATUS.PROCESSING
|
|
55
66
|
},
|
|
56
67
|
relations: ['bizplace', 'reverseKittingOrder', 'inventory']
|
|
57
68
|
})
|
|
58
69
|
|
|
59
|
-
if (!
|
|
70
|
+
if (!foundReverseKittingOI) return
|
|
60
71
|
|
|
61
|
-
const reverseKittingOrder: ReverseKittingOrder =
|
|
62
|
-
const customerBizplace: Bizplace =
|
|
72
|
+
const reverseKittingOrder: ReverseKittingOrder = foundReverseKittingOI.reverseKittingOrder
|
|
73
|
+
const customerBizplace: Bizplace = foundReverseKittingOI.bizplace
|
|
63
74
|
return await getRepository(Inventory).find({
|
|
64
75
|
where: {
|
|
65
76
|
domain,
|
|
66
77
|
bizplace: customerBizplace,
|
|
67
78
|
refOrderId: reverseKittingOrder.id,
|
|
68
|
-
orderVasId:
|
|
79
|
+
orderVasId: foundReverseKittingOI.id,
|
|
80
|
+
product: product,
|
|
69
81
|
status: INVENTORY_STATUS.STORED
|
|
70
82
|
},
|
|
71
|
-
relations: ['product', 'bizplace']
|
|
83
|
+
relations: ['product', 'bizplace', 'location']
|
|
72
84
|
})
|
|
73
85
|
}
|
|
74
86
|
|
|
87
|
+
@Query(returns => [ReverseKittingInventoryDetail], {
|
|
88
|
+
description: 'To generate lot id and label for reverse kitting'
|
|
89
|
+
})
|
|
90
|
+
async generateReverseKittingLotId(
|
|
91
|
+
@Arg('targets', type => [LotInfo]) targets: LotInfo[],
|
|
92
|
+
@Arg('type') type: string,
|
|
93
|
+
@Ctx() context: any
|
|
94
|
+
): Promise<ReverseKittingInventoryDetail[]> {
|
|
95
|
+
const { tx, domain } = context.state
|
|
96
|
+
// 1. get and set the date
|
|
97
|
+
const today = new Date()
|
|
98
|
+
const year = today.getFullYear()
|
|
99
|
+
const month = today.getMonth()
|
|
100
|
+
const day = today.getDate()
|
|
101
|
+
|
|
102
|
+
const yy = String(year).substr(String(year).length - 2)
|
|
103
|
+
const mm = String(month + 1).padStart(2, '0')
|
|
104
|
+
const dd = String(day).padStart(2, '0')
|
|
105
|
+
|
|
106
|
+
const date = yy + mm + dd
|
|
107
|
+
let results = []
|
|
108
|
+
|
|
109
|
+
// 2. get worksheet detail
|
|
110
|
+
let ids = targets.map(target => target.id)
|
|
111
|
+
|
|
112
|
+
// - getRepository using In(array) to pass the value to defined variable
|
|
113
|
+
const foundOrderReverseKittings: ReverseKittingOrderInventory[] = await tx
|
|
114
|
+
.getRepository(ReverseKittingOrderInventory)
|
|
115
|
+
.find({
|
|
116
|
+
where: {
|
|
117
|
+
domain,
|
|
118
|
+
id: In(ids)
|
|
119
|
+
},
|
|
120
|
+
relations: ['domain', 'bizplace']
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
// 3. from worksheet detail get product name, product type, batchid, packing type, bizplace
|
|
124
|
+
|
|
125
|
+
if (foundOrderReverseKittings.length <= 0) throw new Error('Unable to find order reverse kittings')
|
|
126
|
+
else {
|
|
127
|
+
for (let i = 0; i < foundOrderReverseKittings.length; i++) {
|
|
128
|
+
let foundORK = foundOrderReverseKittings[i]
|
|
129
|
+
for (let idx = 0; idx < targets.length; idx++) {
|
|
130
|
+
if (foundORK.id === targets[idx].id) {
|
|
131
|
+
// 4. generate pallet id based on print qty > call generateId resolver
|
|
132
|
+
for (let i = 0; i < targets[idx].printQty; i++) {
|
|
133
|
+
const generatedPalletId = await generateId({
|
|
134
|
+
domain,
|
|
135
|
+
type,
|
|
136
|
+
seed: {
|
|
137
|
+
batchId: foundORK.inventory.batchId,
|
|
138
|
+
date: date
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
// 5. map all data to be returned
|
|
143
|
+
if (foundORK != null) {
|
|
144
|
+
results.push({
|
|
145
|
+
...foundORK,
|
|
146
|
+
palletId: generatedPalletId,
|
|
147
|
+
bizplace: foundORK.bizplace
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return results
|
|
157
|
+
}
|
|
158
|
+
|
|
75
159
|
@Query(returns => ReverseKittingOrderList, { description: 'To fetch multiple ReverseKittingOrders' })
|
|
76
160
|
async reverseKittingOrders(@Args() params: ListParam, @Ctx() context: any): Promise<ReverseKittingOrderList> {
|
|
77
161
|
const { domain, user }: { domain: Domain; user: User } = context.state
|
|
@@ -84,9 +168,9 @@ export class ReverseKittingOrderQuery {
|
|
|
84
168
|
relations: [
|
|
85
169
|
'domain',
|
|
86
170
|
'bizplace',
|
|
87
|
-
'
|
|
88
|
-
'
|
|
89
|
-
'
|
|
171
|
+
'reverseKittingOrderInventories',
|
|
172
|
+
'reverseKittingOrderInventories.inventory',
|
|
173
|
+
'reverseKittingOrderInventories.inventory.product',
|
|
90
174
|
'creator',
|
|
91
175
|
'updater'
|
|
92
176
|
]
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
|
1
|
+
import { Field, ID, InputType, Int, ObjectType, Float } from 'type-graphql'
|
|
2
2
|
|
|
3
3
|
import { ObjectRef } from '@things-factory/shell'
|
|
4
|
+
import { Product } from '@things-factory/product-base'
|
|
5
|
+
import { Location } from '@things-factory/warehouse-base'
|
|
6
|
+
import { Domain } from '@things-factory/shell'
|
|
7
|
+
import { Bizplace } from '@things-factory/biz-base'
|
|
8
|
+
import { Inventory, Warehouse } from '@things-factory/warehouse-base'
|
|
9
|
+
import { User } from '@things-factory/auth-base'
|
|
4
10
|
|
|
5
11
|
import { NewReverseKittingOrderInventory } from '../reverse-kitting-order-inventory/reverse-kitting-order-inventory-type'
|
|
6
12
|
import { ReverseKittingOrder } from './reverse-kitting-order'
|
|
@@ -23,6 +29,15 @@ export class NewReverseKittingOrder {
|
|
|
23
29
|
remark?: string
|
|
24
30
|
}
|
|
25
31
|
|
|
32
|
+
@InputType()
|
|
33
|
+
export class LotInfo {
|
|
34
|
+
@Field()
|
|
35
|
+
id: string
|
|
36
|
+
|
|
37
|
+
@Field()
|
|
38
|
+
printQty: number
|
|
39
|
+
}
|
|
40
|
+
|
|
26
41
|
@InputType()
|
|
27
42
|
export class ReverseKittingOrderPatch {
|
|
28
43
|
@Field(type => ID, { nullable: true })
|
|
@@ -52,3 +67,93 @@ export class ReverseKittingOrderList {
|
|
|
52
67
|
@Field(type => Int)
|
|
53
68
|
total: number
|
|
54
69
|
}
|
|
70
|
+
|
|
71
|
+
@ObjectType()
|
|
72
|
+
export class ReverseKittingInventoryDetail {
|
|
73
|
+
@Field(type => ID)
|
|
74
|
+
readonly id: string
|
|
75
|
+
|
|
76
|
+
@Field(type => Domain, { nullable: true })
|
|
77
|
+
domain: Domain
|
|
78
|
+
|
|
79
|
+
@Field(type => Bizplace, { nullable: true })
|
|
80
|
+
bizplace: Bizplace
|
|
81
|
+
|
|
82
|
+
@Field(type => Inventory, { nullable: true })
|
|
83
|
+
refInventory: Inventory
|
|
84
|
+
|
|
85
|
+
@Field({ nullable: true })
|
|
86
|
+
name: string
|
|
87
|
+
|
|
88
|
+
@Field({ nullable: true })
|
|
89
|
+
palletId: string
|
|
90
|
+
|
|
91
|
+
@Field({ nullable: true })
|
|
92
|
+
cartonId: string
|
|
93
|
+
|
|
94
|
+
@Field({ nullable: true })
|
|
95
|
+
batchId: string
|
|
96
|
+
|
|
97
|
+
@Field(type => Product, { nullable: true })
|
|
98
|
+
product: Product
|
|
99
|
+
|
|
100
|
+
@Field(type => Location, { nullable: true })
|
|
101
|
+
location: Location
|
|
102
|
+
|
|
103
|
+
@Field(type => Warehouse, { nullable: true })
|
|
104
|
+
warehouse: Warehouse
|
|
105
|
+
|
|
106
|
+
@Field({ nullable: true })
|
|
107
|
+
zone: string
|
|
108
|
+
|
|
109
|
+
@Field({ nullable: true })
|
|
110
|
+
packingType: string
|
|
111
|
+
|
|
112
|
+
@Field(type => Float, { nullable: true })
|
|
113
|
+
packingSize: number
|
|
114
|
+
|
|
115
|
+
@Field(type => Int, { nullable: true })
|
|
116
|
+
qty: number
|
|
117
|
+
|
|
118
|
+
@Field(type => Int, { nullable: true })
|
|
119
|
+
remainQty: number
|
|
120
|
+
|
|
121
|
+
@Field({ nullable: true })
|
|
122
|
+
otherRef: string
|
|
123
|
+
|
|
124
|
+
@Field(type => Int, { nullable: true })
|
|
125
|
+
lastSeq: number
|
|
126
|
+
|
|
127
|
+
@Field(type => Float, { nullable: true })
|
|
128
|
+
uomValue: number
|
|
129
|
+
|
|
130
|
+
@Field(type => Float, { nullable: true })
|
|
131
|
+
remainUomValue: number
|
|
132
|
+
|
|
133
|
+
@Field({ nullable: true })
|
|
134
|
+
uom: string
|
|
135
|
+
|
|
136
|
+
@Field({ nullable: true })
|
|
137
|
+
status: string
|
|
138
|
+
|
|
139
|
+
@Field({ nullable: true })
|
|
140
|
+
description: string
|
|
141
|
+
|
|
142
|
+
@Field({ nullable: true })
|
|
143
|
+
remark: string
|
|
144
|
+
|
|
145
|
+
@Field({ nullable: true })
|
|
146
|
+
batchIdRef: string
|
|
147
|
+
|
|
148
|
+
@Field(type => User, { nullable: true })
|
|
149
|
+
creator: User
|
|
150
|
+
|
|
151
|
+
@Field(type => User, { nullable: true })
|
|
152
|
+
updater: User
|
|
153
|
+
|
|
154
|
+
@Field({ nullable: true })
|
|
155
|
+
createdAt: string
|
|
156
|
+
|
|
157
|
+
@Field({ nullable: true })
|
|
158
|
+
updatedAt: string
|
|
159
|
+
}
|
package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
+
import { In } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { getPermittedBizplaceIds } from '@things-factory/biz-base'
|
|
5
|
+
|
|
3
6
|
import { ReverseKittingOrderInventory } from './reverse-kitting-order-inventory'
|
|
4
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
NewReverseKittingOrderInventory,
|
|
9
|
+
ReverseKittingOrderInventoryPatch
|
|
10
|
+
} from './reverse-kitting-order-inventory-type'
|
|
5
11
|
|
|
6
12
|
@Resolver(ReverseKittingOrderInventory)
|
|
7
13
|
export class ReverseKittingOrderInventoryMutation {
|
|
8
14
|
@Directive('@transaction')
|
|
9
15
|
@Mutation(returns => ReverseKittingOrderInventory, { description: 'To create new ReverseKittingOrderInventory' })
|
|
10
|
-
async createReverseKittingOrderInventory(
|
|
16
|
+
async createReverseKittingOrderInventory(
|
|
17
|
+
@Arg('reverseKittingOrderInventory') reverseKittingOrderInventory: NewReverseKittingOrderInventory,
|
|
18
|
+
@Ctx() context: any
|
|
19
|
+
): Promise<ReverseKittingOrderInventory> {
|
|
11
20
|
const { domain, user, tx } = context.state
|
|
12
21
|
|
|
13
22
|
return await tx.getRepository(ReverseKittingOrderInventory).save({
|
|
@@ -19,28 +28,36 @@ export class ReverseKittingOrderInventoryMutation {
|
|
|
19
28
|
}
|
|
20
29
|
|
|
21
30
|
@Directive('@transaction')
|
|
22
|
-
@Mutation(returns => ReverseKittingOrderInventory, {
|
|
31
|
+
@Mutation(returns => ReverseKittingOrderInventory, {
|
|
32
|
+
description: 'To modify ReverseKittingOrderInventory information'
|
|
33
|
+
})
|
|
23
34
|
async updateReverseKittingOrderInventory(
|
|
24
35
|
@Arg('id') id: string,
|
|
25
36
|
@Arg('patch') patch: ReverseKittingOrderInventoryPatch,
|
|
26
37
|
@Ctx() context: any
|
|
27
38
|
): Promise<ReverseKittingOrderInventory> {
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
const { tx, user, domain } = context.state
|
|
40
|
+
const reverseKittingOI: ReverseKittingOrderInventory = await tx
|
|
41
|
+
.getRepository(ReverseKittingOrderInventory)
|
|
42
|
+
.findOne({
|
|
43
|
+
where: {
|
|
44
|
+
domain,
|
|
45
|
+
bizplace: In(await getPermittedBizplaceIds(domain, user)),
|
|
46
|
+
id
|
|
47
|
+
}
|
|
48
|
+
})
|
|
34
49
|
|
|
35
|
-
return await
|
|
36
|
-
...
|
|
50
|
+
return await tx.getRepository(ReverseKittingOrderInventory).save({
|
|
51
|
+
...reverseKittingOI,
|
|
37
52
|
...patch,
|
|
38
53
|
updater: user
|
|
39
54
|
})
|
|
40
55
|
}
|
|
41
56
|
|
|
42
57
|
@Directive('@transaction')
|
|
43
|
-
@Mutation(returns => [ReverseKittingOrderInventory], {
|
|
58
|
+
@Mutation(returns => [ReverseKittingOrderInventory], {
|
|
59
|
+
description: "To modify multiple ReverseKittingOrderInventories' information"
|
|
60
|
+
})
|
|
44
61
|
async updateMultipleReverseKittingOrderInventory(
|
|
45
62
|
@Arg('patches', type => [ReverseKittingOrderInventoryPatch]) patches: ReverseKittingOrderInventoryPatch[],
|
|
46
63
|
@Ctx() context: any
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
InventoryNoGenerator,
|
|
12
12
|
Location,
|
|
13
13
|
LOCATION_STATUS,
|
|
14
|
+
LOCATION_TYPE,
|
|
14
15
|
Pallet
|
|
15
16
|
} from '@things-factory/warehouse-base'
|
|
16
17
|
|
|
@@ -67,7 +68,8 @@ export const InventoryUtil = {
|
|
|
67
68
|
oi.product_id,
|
|
68
69
|
p.name AS product_name,
|
|
69
70
|
oi.packing_type,
|
|
70
|
-
oi.packing_size
|
|
71
|
+
oi.packing_size,
|
|
72
|
+
oi.uom
|
|
71
73
|
FROM
|
|
72
74
|
order_inventories oi
|
|
73
75
|
LEFT JOIN
|
|
@@ -80,12 +82,14 @@ export const InventoryUtil = {
|
|
|
80
82
|
AND oi.product_id NOTNULL
|
|
81
83
|
AND oi.packing_type NOTNULL
|
|
82
84
|
AND oi.packing_size NOTNULL
|
|
85
|
+
AND oi.inventory_id IS NULL
|
|
83
86
|
GROUP BY
|
|
84
87
|
oi.batch_id,
|
|
85
88
|
oi.batch_id_ref,
|
|
86
89
|
oi.product_id,
|
|
87
90
|
oi.packing_type,
|
|
88
91
|
oi.packing_size,
|
|
92
|
+
oi.uom,
|
|
89
93
|
p.name
|
|
90
94
|
)
|
|
91
95
|
SELECT
|
|
@@ -96,6 +100,7 @@ export const InventoryUtil = {
|
|
|
96
100
|
i.uom AS "uom",
|
|
97
101
|
concat(p.name, ' (', p.description, ')') AS "productName",
|
|
98
102
|
coalesce(p.sku, '') AS "productSKU",
|
|
103
|
+
coalesce(p.brand, '') AS "productBrand",
|
|
99
104
|
p.id AS "productId",
|
|
100
105
|
SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0)) - MAX(COALESCE(bp.bundle_product_release_qty, 0)) AS "remainQty",
|
|
101
106
|
SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)) AS "remainUomValue",
|
|
@@ -104,7 +109,8 @@ export const InventoryUtil = {
|
|
|
104
109
|
FROM
|
|
105
110
|
inventories i
|
|
106
111
|
LEFT JOIN products p ON i.product_id = p.id
|
|
107
|
-
LEFT JOIN oi ON i.batch_id = oi.batch_id AND p.name = oi.product_name AND i.packing_type = oi.packing_type AND i.packing_size = oi.packing_size
|
|
112
|
+
LEFT JOIN oi ON i.batch_id = oi.batch_id AND p.name = oi.product_name AND i.packing_type = oi.packing_type AND i.packing_size = oi.packing_size AND i.uom = oi.uom
|
|
113
|
+
LEFT JOIN locations l2 ON i.location_id = l2.id AND i.domain_id = l2.domain_id
|
|
108
114
|
LEFT JOIN (
|
|
109
115
|
SELECT pbs.product_id, SUM(pbs.bundle_qty * src.release_qty) AS bundle_product_release_qty, SUM(pbs.bundle_qty * src.release_uom_value) AS bundle_product_release_uom_value
|
|
110
116
|
FROM product_bundle_settings pbs
|
|
@@ -112,6 +118,7 @@ export const InventoryUtil = {
|
|
|
112
118
|
GROUP BY pbs.product_id
|
|
113
119
|
) bp on i.product_id = bp.product_id
|
|
114
120
|
WHERE i.domain_id = $1
|
|
121
|
+
AND l2.type NOT IN ('${LOCATION_TYPE.QUARANTINE}', '${LOCATION_TYPE.RESERVE}')
|
|
115
122
|
${productWhereClause}
|
|
116
123
|
GROUP BY
|
|
117
124
|
i.batch_id,
|
|
@@ -121,7 +128,7 @@ export const InventoryUtil = {
|
|
|
121
128
|
i.packing_size,
|
|
122
129
|
i.uom
|
|
123
130
|
UNION
|
|
124
|
-
SELECT 'BUNDLE' AS "batchId", null as "batchIdRef", packing_type, packing_size,'UNIT' AS "uom", name AS "productName", sku AS "productSKU", id AS "productId",
|
|
131
|
+
SELECT 'BUNDLE' AS "batchId", null as "batchIdRef", packing_type, packing_size,'UNIT' AS "uom", name AS "productName", sku AS "productSKU", 'brand' AS "productBrand", id AS "productId",
|
|
125
132
|
MIN(FLOOR(pbs."availableQty")) AS "remainQty",
|
|
126
133
|
MIN(FLOOR(pbs."availableUomValue")) AS "remainUomValue",
|
|
127
134
|
CONCAT(MIN(FLOOR(pbs."availableUomValue")),' UNIT') AS "remainUomValueWithUom",
|
|
@@ -189,14 +196,15 @@ export const InventoryUtil = {
|
|
|
189
196
|
product_id: x.product.id,
|
|
190
197
|
batch_id: x.batchId,
|
|
191
198
|
packing_type: x.packingType,
|
|
192
|
-
release_qty: x.releaseQty
|
|
199
|
+
release_qty: x.releaseQty,
|
|
200
|
+
uom: x.uom
|
|
193
201
|
}
|
|
194
202
|
})
|
|
195
203
|
)
|
|
196
204
|
|
|
197
205
|
let resultQb = await trxMgr.query(
|
|
198
206
|
`
|
|
199
|
-
select joi.product_id as "productId", joi.batch_id as "batchId", joi.packing_type as "packingType", joi.release_qty as "releaseQty",
|
|
207
|
+
select joi.product_id as "productId", joi.batch_id as "batchId", joi.packing_type as "packingType", joi.uom as "uom", joi.release_qty as "releaseQty",
|
|
200
208
|
sum(i.qty - coalesce(i.locked_qty,0)) - coalesce(
|
|
201
209
|
(
|
|
202
210
|
select sum(oi.release_qty) from order_inventories oi
|
|
@@ -205,6 +213,7 @@ export const InventoryUtil = {
|
|
|
205
213
|
and oi.product_id = joi.product_id
|
|
206
214
|
and oi.batch_id = joi.batch_id
|
|
207
215
|
and oi.packing_type = joi.packing_type
|
|
216
|
+
and oi.uom = joi.uom
|
|
208
217
|
and oi.domain_id = $1
|
|
209
218
|
and oi.bizplace_id = $2
|
|
210
219
|
),0) as "availableQty",
|
|
@@ -216,16 +225,18 @@ export const InventoryUtil = {
|
|
|
216
225
|
and oi.product_id = joi.product_id
|
|
217
226
|
and oi.batch_id = joi.batch_id
|
|
218
227
|
and oi.packing_type = joi.packing_type
|
|
228
|
+
and oi.uom = joi.uom
|
|
219
229
|
and oi.domain_id = $1
|
|
220
230
|
and oi.bizplace_id = $2
|
|
221
|
-
),0) as "availableUomValue"
|
|
231
|
+
),0) as "availableUomValue"
|
|
222
232
|
from json_populate_recordset(NULL::order_inventories,'${json_oi}') joi
|
|
223
233
|
left join inventories i on joi.product_id = i.product_id
|
|
224
234
|
and joi.batch_id = i.batch_id
|
|
225
235
|
and joi.packing_type = i.packing_type and i.status ='STORED'
|
|
236
|
+
and joi.uom = i.uom
|
|
226
237
|
and i.domain_id = $1
|
|
227
238
|
and i.bizplace_id = $2
|
|
228
|
-
group by joi.product_id, joi.batch_id, joi.packing_type, joi.release_qty,
|
|
239
|
+
group by joi.product_id, joi.batch_id, joi.packing_type, joi.release_qty, joi.uom
|
|
229
240
|
`,
|
|
230
241
|
[warehouseDomain.id, partnerBizplace.id]
|
|
231
242
|
)
|
|
@@ -325,6 +336,14 @@ async function getConditions(
|
|
|
325
336
|
whereClause += `AND LOWER("batchId") LIKE '${value.toLowerCase()}'`
|
|
326
337
|
break
|
|
327
338
|
|
|
339
|
+
case 'batchIdRef':
|
|
340
|
+
whereClause += `AND LOWER("batchIdRef") LIKE '${value.toLowerCase()}'`
|
|
341
|
+
break
|
|
342
|
+
|
|
343
|
+
case 'productBrand':
|
|
344
|
+
whereClause += `AND LOWER("productBrand") LIKE '${value.toLowerCase()}'`
|
|
345
|
+
break
|
|
346
|
+
|
|
328
347
|
case 'productName':
|
|
329
348
|
const products: Product[] = await trxMgr.getRepository(Product).find({
|
|
330
349
|
select: ['id'],
|
|
@@ -406,6 +425,10 @@ async function getConditions(
|
|
|
406
425
|
whereClause += `AND LOWER("groupType") LIKE 'bundle'`
|
|
407
426
|
break
|
|
408
427
|
|
|
428
|
+
case 'hideBundle':
|
|
429
|
+
whereClause += `AND LOWER("groupType") LIKE 'single'`
|
|
430
|
+
break
|
|
431
|
+
|
|
409
432
|
case 'batch_product':
|
|
410
433
|
productWhereClause += `
|
|
411
434
|
AND (i.batch_id, p.id, i.packing_type) ${operator === 'in' ? 'IN' : 'NOT IN'} (${value
|
|
@@ -8,51 +8,63 @@ export class OrderNoGenerator {
|
|
|
8
8
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
static
|
|
11
|
+
static collectionOrder() {
|
|
12
12
|
const currentDate = new Date()
|
|
13
|
-
return `
|
|
13
|
+
return `CO-${currentDate.getFullYear()}${
|
|
14
14
|
currentDate.getMonth() + 1
|
|
15
15
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
static
|
|
18
|
+
static cycleCount() {
|
|
19
19
|
const currentDate = new Date()
|
|
20
|
-
return
|
|
20
|
+
return `CC-${currentDate.getFullYear()}${
|
|
21
21
|
currentDate.getMonth() + 1
|
|
22
22
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
static
|
|
25
|
+
static deliveryOrder() {
|
|
26
26
|
const currentDate = new Date()
|
|
27
|
-
return `
|
|
27
|
+
return `DO-${currentDate.getFullYear()}${
|
|
28
28
|
currentDate.getMonth() + 1
|
|
29
29
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
static
|
|
32
|
+
static goodsReceiveNote() {
|
|
33
33
|
const currentDate = new Date()
|
|
34
|
-
return `
|
|
34
|
+
return `GRN-${currentDate.getFullYear()}${
|
|
35
35
|
currentDate.getMonth() + 1
|
|
36
36
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
static
|
|
39
|
+
static jobSheet(domainName) {
|
|
40
40
|
const currentDate = new Date()
|
|
41
|
-
return
|
|
41
|
+
return `${domainName}-${currentDate.getFullYear()}${
|
|
42
42
|
currentDate.getMonth() + 1
|
|
43
43
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
static
|
|
46
|
+
static manifest() {
|
|
47
47
|
const currentDate = new Date()
|
|
48
|
-
return `
|
|
48
|
+
return `LM-${currentDate.getFullYear()}${
|
|
49
49
|
currentDate.getMonth() + 1
|
|
50
50
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
static
|
|
53
|
+
static orderInventory() {
|
|
54
|
+
return uuid()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static orderProduct() {
|
|
58
|
+
return `OP-${uuid()}`
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static orderVas() {
|
|
62
|
+
return `OV-${uuid()}`
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static purchaseOrder() {
|
|
54
66
|
const currentDate = new Date()
|
|
55
|
-
return `
|
|
67
|
+
return `PO-${currentDate.getFullYear()}${
|
|
56
68
|
currentDate.getMonth() + 1
|
|
57
69
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
58
70
|
}
|
|
@@ -64,46 +76,34 @@ export class OrderNoGenerator {
|
|
|
64
76
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
65
77
|
}
|
|
66
78
|
|
|
67
|
-
static
|
|
68
|
-
return
|
|
79
|
+
static releaseVas() {
|
|
80
|
+
return uuid()
|
|
69
81
|
}
|
|
70
82
|
|
|
71
|
-
static
|
|
83
|
+
static retailReplenishmentOrder() {
|
|
72
84
|
const currentDate = new Date()
|
|
73
|
-
return `
|
|
85
|
+
return `RR-${currentDate.getFullYear()}${
|
|
74
86
|
currentDate.getMonth() + 1
|
|
75
87
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
76
88
|
}
|
|
77
89
|
|
|
78
|
-
static
|
|
90
|
+
static returnOrder() {
|
|
79
91
|
const currentDate = new Date()
|
|
80
|
-
return `
|
|
92
|
+
return `RTO-${currentDate.getFullYear()}${
|
|
81
93
|
currentDate.getMonth() + 1
|
|
82
94
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
83
95
|
}
|
|
84
96
|
|
|
85
|
-
static
|
|
86
|
-
return uuid()
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
static releaseVas() {
|
|
90
|
-
return uuid()
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
static vasOrder() {
|
|
97
|
+
static shippingOrder() {
|
|
94
98
|
const currentDate = new Date()
|
|
95
|
-
return `
|
|
99
|
+
return `SO-${currentDate.getFullYear()}${
|
|
96
100
|
currentDate.getMonth() + 1
|
|
97
101
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
98
102
|
}
|
|
99
103
|
|
|
100
|
-
static
|
|
101
|
-
return `OV-${uuid()}`
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
static retailReplenishmentOrder() {
|
|
104
|
+
static stockTake() {
|
|
105
105
|
const currentDate = new Date()
|
|
106
|
-
return `
|
|
106
|
+
return `ST-${currentDate.getFullYear()}${
|
|
107
107
|
currentDate.getMonth() + 1
|
|
108
108
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
109
109
|
}
|
|
@@ -114,4 +114,11 @@ export class OrderNoGenerator {
|
|
|
114
114
|
currentDate.getMonth() + 1
|
|
115
115
|
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
116
116
|
}
|
|
117
|
+
|
|
118
|
+
static vasOrder() {
|
|
119
|
+
const currentDate = new Date()
|
|
120
|
+
return `VO-${currentDate.getFullYear()}${
|
|
121
|
+
currentDate.getMonth() + 1
|
|
122
|
+
}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
|
|
123
|
+
}
|
|
117
124
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/middlewares/index.ts"],"names":[],"mappings":""}
|
|
File without changes
|