@things-factory/sales-base 4.3.449 → 4.3.453
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 +3 -1
- package/dist-server/constants/order.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-create.js +587 -0
- package/dist-server/service/draft-release-good/draft-release-good-create.js.map +1 -0
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js +3 -232
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-query.js +59 -28
- package/dist-server/service/draft-release-good/draft-release-good-query.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-type.js +33 -1
- package/dist-server/service/draft-release-good/draft-release-good-type.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good.js +2 -7
- package/dist-server/service/draft-release-good/draft-release-good.js.map +1 -1
- package/dist-server/service/draft-release-good/index.js +4 -2
- package/dist-server/service/draft-release-good/index.js.map +1 -1
- package/dist-server/service/order-vas/order-vas-mutation.js +46 -23
- package/dist-server/service/order-vas/order-vas-mutation.js.map +1 -1
- package/dist-server/service/order-vas/order-vas-query.js +34 -0
- package/dist-server/service/order-vas/order-vas-query.js.map +1 -1
- package/dist-server/service/order-vas/order-vas-types.js +4 -0
- package/dist-server/service/order-vas/order-vas-types.js.map +1 -1
- package/dist-server/service/order-vas/order-vas.js +22 -1
- package/dist-server/service/order-vas/order-vas.js.map +1 -1
- package/dist-server/service/order-vas-item/order-vas-item-type.js +8 -0
- package/dist-server/service/order-vas-item/order-vas-item-type.js.map +1 -1
- package/dist-server/service/order-vas-item/order-vas-item.js +5 -0
- package/dist-server/service/order-vas-item/order-vas-item.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +6 -4
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-query.js +4 -1
- package/dist-server/service/release-good/release-good-query.js.map +1 -1
- package/dist-server/service/release-good/release-good.js +9 -0
- package/dist-server/service/release-good/release-good.js.map +1 -1
- package/dist-server/service/vas/vas-mutation.js +5 -1
- package/dist-server/service/vas/vas-mutation.js.map +1 -1
- package/dist-server/utils/inventory-util.js +5 -3
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +15 -15
- package/server/constants/order.ts +3 -1
- package/server/service/draft-release-good/draft-release-good-create.ts +715 -0
- package/server/service/draft-release-good/draft-release-good-mutation.ts +36 -288
- package/server/service/draft-release-good/draft-release-good-query.ts +109 -89
- package/server/service/draft-release-good/draft-release-good-type.ts +28 -2
- package/server/service/draft-release-good/draft-release-good.ts +2 -8
- package/server/service/draft-release-good/index.ts +4 -2
- package/server/service/order-vas/order-vas-mutation.ts +57 -29
- package/server/service/order-vas/order-vas-query.ts +43 -1
- package/server/service/order-vas/order-vas-types.ts +5 -8
- package/server/service/order-vas/order-vas.ts +19 -10
- package/server/service/order-vas-item/order-vas-item-type.ts +6 -0
- package/server/service/order-vas-item/order-vas-item.ts +4 -0
- package/server/service/release-good/release-good-mutation.ts +10 -2
- package/server/service/release-good/release-good-query.ts +7 -2
- package/server/service/release-good/release-good.ts +8 -0
- package/server/service/vas/vas-mutation.ts +4 -1
- package/server/utils/inventory-util.ts +29 -6
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Field,
|
|
3
|
+
InputType,
|
|
4
|
+
Int,
|
|
5
|
+
ObjectType
|
|
6
|
+
} from 'type-graphql'
|
|
2
7
|
|
|
3
8
|
import { ObjectRef } from '@things-factory/shell'
|
|
4
9
|
|
|
@@ -266,8 +271,29 @@ export class DraftReleaseGoodPatch {
|
|
|
266
271
|
@ObjectType()
|
|
267
272
|
export class DraftReleaseGoodList {
|
|
268
273
|
@Field(type => [DraftReleaseGood])
|
|
269
|
-
items
|
|
274
|
+
items?: DraftReleaseGood[]
|
|
270
275
|
|
|
271
276
|
@Field(type => Int)
|
|
272
277
|
total: number
|
|
278
|
+
|
|
279
|
+
@Field({ nullable: true })
|
|
280
|
+
settingValue: string
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
@ObjectType()
|
|
284
|
+
export class SuccessReleasedDraftOrder {
|
|
285
|
+
@Field({ nullable: true })
|
|
286
|
+
draftName?: string
|
|
287
|
+
|
|
288
|
+
@Field({ nullable: true })
|
|
289
|
+
isProductBundle?: Boolean
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
@InputType()
|
|
293
|
+
export class DraftReleaseGoodInfos {
|
|
294
|
+
@Field()
|
|
295
|
+
id: String
|
|
296
|
+
|
|
297
|
+
@Field()
|
|
298
|
+
releaseType?: string
|
|
273
299
|
}
|
|
@@ -17,8 +17,8 @@ import { Attachment } from '@things-factory/attachment-base'
|
|
|
17
17
|
import { User } from '@things-factory/auth-base'
|
|
18
18
|
import { Bizplace, ContactPoint } from '@things-factory/biz-base'
|
|
19
19
|
import { config } from '@things-factory/env'
|
|
20
|
-
import { Domain } from '@things-factory/shell'
|
|
21
20
|
import { LastMileDelivery } from '@things-factory/integration-lmd'
|
|
21
|
+
import { Domain } from '@things-factory/shell'
|
|
22
22
|
|
|
23
23
|
import { OrderProduct, ReleaseGood, ShippingOrder, ShippingOrderInfo } from '../'
|
|
24
24
|
import { ReleaseOrderType } from '../../constants'
|
|
@@ -66,14 +66,9 @@ export class DraftReleaseGood {
|
|
|
66
66
|
@Field({ nullable: true })
|
|
67
67
|
name: string
|
|
68
68
|
|
|
69
|
-
@
|
|
70
|
-
@JoinColumn()
|
|
69
|
+
@OneToMany(type => ReleaseGood, releaseGood => releaseGood.draftReleaseGood)
|
|
71
70
|
@Field(type => ReleaseGood, { nullable: true })
|
|
72
71
|
releaseGood: ReleaseGood
|
|
73
|
-
|
|
74
|
-
@RelationId((draftReleaseGood: DraftReleaseGood) => draftReleaseGood.releaseGood)
|
|
75
|
-
releaseGoodId: string
|
|
76
|
-
|
|
77
72
|
@OneToOne(type => ShippingOrder)
|
|
78
73
|
@JoinColumn()
|
|
79
74
|
@Field(type => ShippingOrder, { nullable: true })
|
|
@@ -356,4 +351,3 @@ export class DraftReleaseGood {
|
|
|
356
351
|
@RelationId((draftReleaseGood: DraftReleaseGood) => draftReleaseGood.lastMileDelivery)
|
|
357
352
|
lastMileDeliveryId?: string
|
|
358
353
|
}
|
|
359
|
-
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { DraftReleaseGood } from './draft-release-good'
|
|
2
|
-
import {
|
|
2
|
+
import { DraftReleaseGoodCreate } from './draft-release-good-create'
|
|
3
3
|
import { DraftReleaseGoodMutation } from './draft-release-good-mutation'
|
|
4
|
+
import { DraftReleaseGoodQuery } from './draft-release-good-query'
|
|
4
5
|
|
|
5
6
|
export const entities = [DraftReleaseGood]
|
|
6
|
-
export const resolvers = [DraftReleaseGoodQuery, DraftReleaseGoodMutation]
|
|
7
|
+
export const resolvers = [DraftReleaseGoodQuery, DraftReleaseGoodMutation, DraftReleaseGoodCreate]
|
|
7
8
|
|
|
8
9
|
export * from './draft-release-good-mutation'
|
|
9
10
|
export * from './draft-release-good-query'
|
|
11
|
+
export * from './draft-release-good-create'
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { User } from '@things-factory/auth-base'
|
|
1
2
|
import { Domain } from '@things-factory/shell'
|
|
2
3
|
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
3
|
-
import { EntityManager, getRepository } from 'typeorm'
|
|
4
|
-
import { OrderVasPatch } from '../'
|
|
4
|
+
import { EntityManager, getRepository, In } from 'typeorm'
|
|
5
|
+
import { OrderVasPatch, OrderVasItemPatch } from '../'
|
|
5
6
|
import { OrderVas } from './order-vas'
|
|
7
|
+
import { OrderVasItem } from '../order-vas-item/order-vas-item'
|
|
8
|
+
import { ReleaseGood } from '../release-good/release-good'
|
|
9
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
6
10
|
// import { WorksheetDetail } from '@things-factory/worksheet-base'
|
|
7
11
|
|
|
8
12
|
@Resolver(OrderVas)
|
|
@@ -23,46 +27,61 @@ export class OrderVasMutation {
|
|
|
23
27
|
@Directive('@transaction')
|
|
24
28
|
@Mutation(returns => [OrderVas])
|
|
25
29
|
async updateMultipleOrderVas(
|
|
30
|
+
@Arg('orderNo') orderNo: string,
|
|
26
31
|
@Arg('patches', type => [OrderVasPatch]) patches: OrderVasPatch[],
|
|
27
32
|
@Ctx() context: any
|
|
28
|
-
): Promise<
|
|
29
|
-
const { domain, user } = context.state
|
|
33
|
+
): Promise<OrderVas[]> {
|
|
34
|
+
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
const releaseGood = await tx.getRepository(ReleaseGood).findOne({ where: { name: orderNo, domain: domain.id } })
|
|
37
|
+
|
|
38
|
+
patches.forEach(patch => (patch.releaseGood = releaseGood))
|
|
39
|
+
|
|
40
|
+
const createPatches = patches.filter(patch => patch.cuFlag.toUpperCase() === '+')
|
|
41
|
+
const updatePatches = patches.filter(patch => patch.cuFlag.toUpperCase() === 'M')
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
const orderVasRepo = tx.getRepository(OrderVas)
|
|
44
|
+
const orderVasItemRepo = tx.getRepository(OrderVasItem)
|
|
45
|
+
let results = []
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
// Handle creation
|
|
48
|
+
for (const newRecord of createPatches) {
|
|
49
|
+
const savedOrderVas = await orderVasRepo.save({
|
|
50
|
+
...newRecord,
|
|
51
|
+
name: uuidv4(),
|
|
52
|
+
releaseGood: newRecord.releaseGood,
|
|
53
|
+
domain: domain,
|
|
54
|
+
creator: user,
|
|
55
|
+
updater: user
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
results.push(savedOrderVas)
|
|
59
|
+
|
|
60
|
+
for (const itemPatch of newRecord.orderVasItemsPatch) {
|
|
61
|
+
await orderVasItemRepo.save({
|
|
62
|
+
orderVas: savedOrderVas,
|
|
63
|
+
name: `${itemPatch.vas.name} (${itemPatch.vas.description})- ${savedOrderVas.id}`,
|
|
64
|
+
vas: itemPatch.vas,
|
|
65
|
+
vasQty: itemPatch.vasQty,
|
|
66
|
+
vasRemark: itemPatch.vasRemark,
|
|
42
67
|
domain: domain,
|
|
43
|
-
creator: user
|
|
44
|
-
updater: user
|
|
68
|
+
creator: user
|
|
45
69
|
})
|
|
46
|
-
|
|
47
|
-
results.push({ ...result, cuFlag: '+' })
|
|
48
70
|
}
|
|
49
71
|
}
|
|
50
72
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
where: { domain, id: newRecord.id },
|
|
56
|
-
relations: ['product', 'productDetail', 'newProduct', 'newProductDetail', 'releaseGood', 'orderVasItems']
|
|
57
|
-
})
|
|
73
|
+
// Handle updates
|
|
74
|
+
for (const patch of updatePatches) {
|
|
75
|
+
for (const itemPatch of patch.orderVasItemsPatch) {
|
|
76
|
+
const existingOrderVasItem = await orderVasItemRepo.findOne({ where: { orderVas: patch.id } })
|
|
58
77
|
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
const updateData = {
|
|
79
|
+
vasQty: itemPatch.vasQty,
|
|
80
|
+
vasRemark: itemPatch.vasRemark,
|
|
62
81
|
updater: user
|
|
63
|
-
}
|
|
82
|
+
}
|
|
64
83
|
|
|
65
|
-
|
|
84
|
+
await orderVasItemRepo.update(existingOrderVasItem.id, updateData)
|
|
66
85
|
}
|
|
67
86
|
}
|
|
68
87
|
|
|
@@ -74,6 +93,15 @@ export class OrderVasMutation {
|
|
|
74
93
|
@Mutation(returns => Boolean)
|
|
75
94
|
async deleteOrderVas(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {
|
|
76
95
|
const { tx }: { tx: EntityManager } = context.state
|
|
96
|
+
|
|
97
|
+
// Retrieve and delete all related OrderVasItems
|
|
98
|
+
const orderVasItemRepo = tx.getRepository(OrderVasItem)
|
|
99
|
+
const orderVasItems = await orderVasItemRepo.find({ where: { orderVas: id } })
|
|
100
|
+
if (orderVasItems.length > 0) {
|
|
101
|
+
await orderVasItemRepo.remove(orderVasItems)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Delete the OrderVas
|
|
77
105
|
await tx.getRepository(OrderVas).delete(id)
|
|
78
106
|
return true
|
|
79
107
|
}
|
|
@@ -2,7 +2,7 @@ import { User } from '@things-factory/auth-base'
|
|
|
2
2
|
import { convertListParams, Domain, Filter, Pagination, Sorting } from '@things-factory/shell'
|
|
3
3
|
import { Arg, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
4
4
|
import { getRepository } from 'typeorm'
|
|
5
|
-
import { OrderVasList } from '../'
|
|
5
|
+
import { OrderVasList, ReleaseGood } from '../'
|
|
6
6
|
import { OrderVas } from './order-vas'
|
|
7
7
|
|
|
8
8
|
@Resolver(OrderVas)
|
|
@@ -34,6 +34,48 @@ export class OrderVasQuery {
|
|
|
34
34
|
return { items, total }
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
@Query(returns => OrderVasList)
|
|
38
|
+
async orderVasList(
|
|
39
|
+
@Ctx() context: any,
|
|
40
|
+
@Arg('bizplaceId') bizplaceId: string,
|
|
41
|
+
@Arg('orderNo') orderNo: string
|
|
42
|
+
): Promise<OrderVasList> {
|
|
43
|
+
const { domain }: { domain: Domain } = context.state
|
|
44
|
+
|
|
45
|
+
const releaseGood: ReleaseGood = await getRepository(ReleaseGood).findOne({
|
|
46
|
+
where: { name: orderNo, domain: domain.id, bizplace: bizplaceId }
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// Possible enhancement: Add creator type or add a new boolean column to determine is vas is added by warehouse staff
|
|
50
|
+
const qb = getRepository(OrderVas).createQueryBuilder('ov')
|
|
51
|
+
qb.innerJoinAndSelect('ov.orderVasItems', 'ovi')
|
|
52
|
+
.innerJoinAndSelect('ovi.vas', 'v')
|
|
53
|
+
.where('ov.bizplace_id = :bizplaceId AND ov.domain_id = :domainId AND ov.release_good_id = :releaseGoodId', {
|
|
54
|
+
bizplaceId,
|
|
55
|
+
domainId: domain.id,
|
|
56
|
+
releaseGoodId: releaseGood.id
|
|
57
|
+
})
|
|
58
|
+
.andWhere('ov.batch_id IS NULL')
|
|
59
|
+
.andWhere('ov.qty IS NULL')
|
|
60
|
+
.andWhere('ov.output_qty IS NULL')
|
|
61
|
+
.andWhere('ov.product_id IS NULL')
|
|
62
|
+
.andWhere('ov.product_detail_id IS NULL')
|
|
63
|
+
|
|
64
|
+
let items = await qb.getRawMany()
|
|
65
|
+
|
|
66
|
+
items = items.map(item => {
|
|
67
|
+
return {
|
|
68
|
+
...item,
|
|
69
|
+
orderVas: { id: item.ov_id },
|
|
70
|
+
vassId: item.v_id,
|
|
71
|
+
vasName: item.v_name,
|
|
72
|
+
vasQty: item?.ovi_vas_qty,
|
|
73
|
+
vasRemark: item?.ovi_vas_remark
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
return { items }
|
|
77
|
+
}
|
|
78
|
+
|
|
37
79
|
@Query(returns => OrderVas)
|
|
38
80
|
async orderVas(@Arg('name') name: string, @Ctx() context: any): Promise<OrderVas> {
|
|
39
81
|
const { domain }: { domain: Domain } = context.state
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Field,
|
|
3
|
-
Float,
|
|
4
|
-
InputType,
|
|
5
|
-
Int,
|
|
6
|
-
ObjectType
|
|
7
|
-
} from 'type-graphql'
|
|
1
|
+
import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
|
|
8
2
|
|
|
9
3
|
import { ObjectRef } from '@things-factory/shell'
|
|
10
4
|
|
|
@@ -17,7 +11,7 @@ export class OrderVasList {
|
|
|
17
11
|
items: OrderVas[]
|
|
18
12
|
|
|
19
13
|
@Field(type => Int, { nullable: true })
|
|
20
|
-
total
|
|
14
|
+
total?: number
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
@InputType()
|
|
@@ -175,6 +169,9 @@ export class OrderVasPatch {
|
|
|
175
169
|
@Field({ nullable: true })
|
|
176
170
|
newProductDetail: string
|
|
177
171
|
|
|
172
|
+
@Field({ nullable: true })
|
|
173
|
+
newBatchId: string
|
|
174
|
+
|
|
178
175
|
@Field({ nullable: true })
|
|
179
176
|
newPackingType: string
|
|
180
177
|
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Field,
|
|
3
|
-
ID,
|
|
4
|
-
ObjectType
|
|
5
|
-
} from 'type-graphql'
|
|
1
|
+
import { Field, ID, ObjectType } from 'type-graphql'
|
|
6
2
|
import {
|
|
7
3
|
Column,
|
|
8
4
|
CreateDateColumn,
|
|
@@ -17,10 +13,7 @@ import {
|
|
|
17
13
|
|
|
18
14
|
import { User } from '@things-factory/auth-base'
|
|
19
15
|
import { Bizplace } from '@things-factory/biz-base'
|
|
20
|
-
import {
|
|
21
|
-
Product,
|
|
22
|
-
ProductDetail
|
|
23
|
-
} from '@things-factory/product-base'
|
|
16
|
+
import { Product, ProductDetail } from '@things-factory/product-base'
|
|
24
17
|
import { Domain } from '@things-factory/shell'
|
|
25
18
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
26
19
|
|
|
@@ -60,7 +53,7 @@ export class OrderVas {
|
|
|
60
53
|
bizplaceId: string
|
|
61
54
|
|
|
62
55
|
@Column()
|
|
63
|
-
@Field()
|
|
56
|
+
@Field({ nullable: true })
|
|
64
57
|
name: string
|
|
65
58
|
|
|
66
59
|
@Column({ nullable: true })
|
|
@@ -259,6 +252,10 @@ export class OrderVas {
|
|
|
259
252
|
@Field({ nullable: true })
|
|
260
253
|
remark: string
|
|
261
254
|
|
|
255
|
+
@Column({ nullable: true })
|
|
256
|
+
@Field({ nullable: true })
|
|
257
|
+
newBatchId: string
|
|
258
|
+
|
|
262
259
|
@Column({ nullable: true })
|
|
263
260
|
@Field({ nullable: true })
|
|
264
261
|
newPackingType: string
|
|
@@ -304,4 +301,16 @@ export class OrderVas {
|
|
|
304
301
|
|
|
305
302
|
@RelationId((orderVas: OrderVas) => orderVas.updater)
|
|
306
303
|
updaterId: string
|
|
304
|
+
|
|
305
|
+
@Field({ nullable: true })
|
|
306
|
+
vassId: string
|
|
307
|
+
|
|
308
|
+
@Field({ nullable: true })
|
|
309
|
+
vasName?: string
|
|
310
|
+
|
|
311
|
+
@Field({ nullable: true })
|
|
312
|
+
vasQty?: number
|
|
313
|
+
|
|
314
|
+
@Field({ nullable: true })
|
|
315
|
+
vasRemark?: string
|
|
307
316
|
}
|
|
@@ -20,6 +20,9 @@ export class NewOrderVasItem {
|
|
|
20
20
|
|
|
21
21
|
@Field({ nullable: true })
|
|
22
22
|
params?: string
|
|
23
|
+
|
|
24
|
+
@Field({ nullable: true })
|
|
25
|
+
vasRemark?: string
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
@InputType()
|
|
@@ -57,6 +60,9 @@ export class OrderVasItemPatch {
|
|
|
57
60
|
@Field({ nullable: true })
|
|
58
61
|
active?: boolean
|
|
59
62
|
|
|
63
|
+
@Field({ nullable: true })
|
|
64
|
+
vasRemark?: string
|
|
65
|
+
|
|
60
66
|
@Field()
|
|
61
67
|
cuFlag: string
|
|
62
68
|
}
|
|
@@ -122,6 +122,7 @@ export class ReleaseGoodMutation {
|
|
|
122
122
|
|
|
123
123
|
// update orderInventories if availableItems are valid
|
|
124
124
|
releaseGoods[i].orderInventories = availableItems
|
|
125
|
+
|
|
125
126
|
|
|
126
127
|
const createdReleaseGood: ReleaseGood = await bulkGenerateReleaseGood(
|
|
127
128
|
releaseGoods[i],
|
|
@@ -129,6 +130,7 @@ export class ReleaseGoodMutation {
|
|
|
129
130
|
roNoSetting,
|
|
130
131
|
domain,
|
|
131
132
|
user,
|
|
133
|
+
null,
|
|
132
134
|
childTx
|
|
133
135
|
)
|
|
134
136
|
|
|
@@ -1490,6 +1492,7 @@ export async function bulkGenerateReleaseGood(
|
|
|
1490
1492
|
roNoSetting: any,
|
|
1491
1493
|
domain: Domain,
|
|
1492
1494
|
user: User,
|
|
1495
|
+
draftOrder?: any,
|
|
1493
1496
|
tx?: EntityManager
|
|
1494
1497
|
): Promise<ReleaseGood> {
|
|
1495
1498
|
try {
|
|
@@ -1536,6 +1539,7 @@ export async function bulkGenerateReleaseGood(
|
|
|
1536
1539
|
refNo: releaseGood.refNo,
|
|
1537
1540
|
refNo2: releaseGood.refNo2,
|
|
1538
1541
|
refNo3: releaseGood.refNo3,
|
|
1542
|
+
draftReleaseGood: draftOrder || null,
|
|
1539
1543
|
releaseDate: releaseGood.releaseDate,
|
|
1540
1544
|
ownTransport: releaseGood?.ownTransport || false,
|
|
1541
1545
|
orderMethod: ORDER_METHOD.SELECT_BY_PRODUCT,
|
|
@@ -1657,8 +1661,12 @@ export async function bulkGenerateReleaseGood(
|
|
|
1657
1661
|
newOrderProduct = await tx.getRepository(OrderProduct).save({
|
|
1658
1662
|
...oi.orderProduct,
|
|
1659
1663
|
totalUomValue: `${oi.orderProduct.releaseUomValue} ${oi.orderProduct.uom}`,
|
|
1660
|
-
status:
|
|
1661
|
-
|
|
1664
|
+
status:
|
|
1665
|
+
oi.orderProduct.status === 'partial-release'
|
|
1666
|
+
? ORDER_PRODUCT_STATUS.PARTIAL_RELEASED
|
|
1667
|
+
: ORDER_PRODUCT_STATUS.ASSIGNED,
|
|
1668
|
+
updater: newReleaseGood?.updater || user,
|
|
1669
|
+
releaseGood: newReleaseGood
|
|
1662
1670
|
})
|
|
1663
1671
|
}
|
|
1664
1672
|
|
|
@@ -179,6 +179,7 @@ export class ReleaseGoodQuery {
|
|
|
179
179
|
relations: [
|
|
180
180
|
'domain',
|
|
181
181
|
'bizplace',
|
|
182
|
+
'draftReleaseGood',
|
|
182
183
|
'shippingOrder',
|
|
183
184
|
'arrivalNotice',
|
|
184
185
|
'orderProducts',
|
|
@@ -494,6 +495,7 @@ export class ReleaseGoodQuery {
|
|
|
494
495
|
qb.leftJoinAndSelect('rg.creator', 'creator')
|
|
495
496
|
qb.leftJoinAndSelect('rg.updater', 'updater')
|
|
496
497
|
qb.leftJoinAndSelect('rg.acceptedBy', 'acceptedBy')
|
|
498
|
+
qb.leftJoinAndSelect('rg.draftReleaseGood', 'draftReleaseGood')
|
|
497
499
|
qb.leftJoinAndSelect('rg.deliverTo', 'deliverTo')
|
|
498
500
|
qb.leftJoin(
|
|
499
501
|
subQuery => {
|
|
@@ -567,12 +569,15 @@ export class ReleaseGoodQuery {
|
|
|
567
569
|
})
|
|
568
570
|
.join(',')
|
|
569
571
|
|
|
570
|
-
qb.andWhere(
|
|
572
|
+
qb.andWhere(
|
|
573
|
+
`(
|
|
571
574
|
lower(rg.name) like any(array[${orderInfos}])
|
|
572
575
|
or lower(rg.ref_no) like any(array[${orderInfos}])
|
|
573
576
|
or lower(rg.ref_no_2) like any(array[${orderInfos}])
|
|
574
577
|
or lower(rg.ref_no_3) like any(array[${orderInfos}])
|
|
575
|
-
|
|
578
|
+
or lower(draftReleaseGood.name) like any(array[${orderInfos}])
|
|
579
|
+
)`
|
|
580
|
+
)
|
|
576
581
|
}
|
|
577
582
|
|
|
578
583
|
const arrChildSortData = ['bizplace', 'creator']
|
|
@@ -23,6 +23,7 @@ import { Domain } from '@things-factory/shell'
|
|
|
23
23
|
import {
|
|
24
24
|
ArrivalNotice,
|
|
25
25
|
DeliveryOrder,
|
|
26
|
+
DraftReleaseGood,
|
|
26
27
|
InventoryInfos,
|
|
27
28
|
Manifest,
|
|
28
29
|
OrderInventory,
|
|
@@ -81,6 +82,13 @@ export class ReleaseGood {
|
|
|
81
82
|
@RelationId((releaseGood: ReleaseGood) => releaseGood.bizplace)
|
|
82
83
|
bizplaceId: string
|
|
83
84
|
|
|
85
|
+
@ManyToOne(() => DraftReleaseGood, draftReleaseGood => draftReleaseGood.releaseGood)
|
|
86
|
+
@Field(type => DraftReleaseGood, { nullable: true })
|
|
87
|
+
draftReleaseGood: DraftReleaseGood
|
|
88
|
+
|
|
89
|
+
@RelationId((releaseGood: ReleaseGood) => releaseGood.draftReleaseGood)
|
|
90
|
+
draftReleaseGoodId: string
|
|
91
|
+
|
|
84
92
|
@ManyToOne(type => Manifest)
|
|
85
93
|
@Field(type => Manifest, { nullable: true })
|
|
86
94
|
manifest: Manifest
|
|
@@ -166,6 +166,7 @@ export async function editVas(
|
|
|
166
166
|
name: `${newRecord.orderVasItemsPatch[ii].vas.name} (${newRecord.orderVasItemsPatch[ii].vas.description})- ${result.id}`,
|
|
167
167
|
vas: newRecord.orderVasItemsPatch[ii].vas,
|
|
168
168
|
vasQty: newRecord.orderVasItemsPatch[ii].vasQty,
|
|
169
|
+
vasRemark: newRecord.orderVasItemsPatch[ii]?.vasRemark,
|
|
169
170
|
domain: domain,
|
|
170
171
|
creator: user,
|
|
171
172
|
createdAt: new Date()
|
|
@@ -198,6 +199,7 @@ export async function editVas(
|
|
|
198
199
|
name: `${newRecord.orderVasItemsPatch[ii].vas.name}- ${result.id}`,
|
|
199
200
|
vas: newRecord.orderVasItemsPatch[ii].vas,
|
|
200
201
|
vasQty: newRecord.orderVasItemsPatch[ii].vasQty,
|
|
202
|
+
vasRemark: newRecord.orderVasItemsPatch[ii]?.vasRemark,
|
|
201
203
|
domain: domain,
|
|
202
204
|
creator: user,
|
|
203
205
|
createdAt: new Date()
|
|
@@ -232,6 +234,7 @@ export async function editVas(
|
|
|
232
234
|
name: `${newRecord.vas.name}- ${newRecord.orderVas.id}`,
|
|
233
235
|
vas: newRecord.vas,
|
|
234
236
|
vasQty: newRecord.vasQty,
|
|
237
|
+
vasRemark: newRecord?.vasRemark,
|
|
235
238
|
domain: domain,
|
|
236
239
|
creator: user,
|
|
237
240
|
createdAt: new Date()
|
|
@@ -248,7 +251,7 @@ export async function editVas(
|
|
|
248
251
|
{
|
|
249
252
|
id: newRecord.id
|
|
250
253
|
},
|
|
251
|
-
{ vasQty: newRecord.vasQty, updater: user.id, updatedAt: new Date() }
|
|
254
|
+
{ vasQty: newRecord.vasQty,vasRemark: newRecord?.vasRemark, updater: user.id, updatedAt: new Date() }
|
|
252
255
|
)
|
|
253
256
|
|
|
254
257
|
results.push({ ...result, cuFlag: 'M' })
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
EntityManager,
|
|
3
|
+
Equal,
|
|
4
|
+
getRepository,
|
|
5
|
+
In,
|
|
6
|
+
Not,
|
|
7
|
+
Raw,
|
|
8
|
+
Repository,
|
|
9
|
+
SelectQueryBuilder
|
|
10
|
+
} from 'typeorm'
|
|
2
11
|
|
|
3
12
|
import { User } from '@things-factory/auth-base'
|
|
4
13
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
14
|
+
import {
|
|
15
|
+
Product,
|
|
16
|
+
ProductBundle,
|
|
17
|
+
ProductDetail
|
|
18
|
+
} from '@things-factory/product-base'
|
|
19
|
+
import {
|
|
20
|
+
PartnerSetting,
|
|
21
|
+
Setting
|
|
22
|
+
} from '@things-factory/setting-base'
|
|
23
|
+
import {
|
|
24
|
+
Domain,
|
|
25
|
+
ListParam
|
|
26
|
+
} from '@things-factory/shell'
|
|
8
27
|
import {
|
|
9
28
|
generateInventoryHistory,
|
|
10
29
|
Inventory,
|
|
@@ -238,6 +257,8 @@ export const InventoryUtil = {
|
|
|
238
257
|
items = await trxMgr.query(`select * from temp_inventory_product_group`)
|
|
239
258
|
}
|
|
240
259
|
|
|
260
|
+
await trxMgr.query(`drop table temp_inventory_product_group`)
|
|
261
|
+
|
|
241
262
|
return { items, total }
|
|
242
263
|
} catch (error) {
|
|
243
264
|
throw error
|
|
@@ -745,7 +766,7 @@ export const InventoryUtil = {
|
|
|
745
766
|
}
|
|
746
767
|
})
|
|
747
768
|
|
|
748
|
-
return _composeTargetInventories(productDetail, orderInventory, inventories)
|
|
769
|
+
return _composeTargetInventories(product, productDetail, orderInventory, inventories)
|
|
749
770
|
},
|
|
750
771
|
|
|
751
772
|
/**
|
|
@@ -1059,6 +1080,7 @@ export async function switchLocationStatus(
|
|
|
1059
1080
|
}
|
|
1060
1081
|
|
|
1061
1082
|
export function _composeTargetInventories(
|
|
1083
|
+
product: Product,
|
|
1062
1084
|
productDetail: ProductDetail,
|
|
1063
1085
|
record: any,
|
|
1064
1086
|
inventories: Inventory[]
|
|
@@ -1068,7 +1090,8 @@ export function _composeTargetInventories(
|
|
|
1068
1090
|
let compReleaseQty: number = 0
|
|
1069
1091
|
let compReleaseUomValue: number = 0
|
|
1070
1092
|
let totalInventoryQty: number = inventories.reduce((total, inventory) => total + inventory.remainQty, 0)
|
|
1071
|
-
|
|
1093
|
+
|
|
1094
|
+
if (!product) product = productDetail.product
|
|
1072
1095
|
|
|
1073
1096
|
if (totalInventoryQty < record.releaseQty) {
|
|
1074
1097
|
throw new Error(`invalid release qty for ${product?.sku}`)
|