@things-factory/sales-base 4.3.534 → 4.3.536
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/service/arrival-notice/arrival-notice-mutation.js +9 -2
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-types.js +12 -0
- package/dist-server/service/arrival-notice/arrival-notice-types.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice.js +5 -0
- package/dist-server/service/arrival-notice/arrival-notice.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-create.js +3 -0
- package/dist-server/service/draft-release-good/draft-release-good-create.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js +8 -1
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js.map +1 -1
- package/dist-server/service/manifest/manifest-mutation.js +19 -19
- package/dist-server/service/manifest/manifest-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +8 -6
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/package.json +16 -16
- package/server/service/arrival-notice/arrival-notice-mutation.ts +78 -67
- package/server/service/arrival-notice/arrival-notice-types.ts +9 -0
- package/server/service/arrival-notice/arrival-notice.ts +4 -0
- package/server/service/draft-release-good/draft-release-good-create.ts +4 -0
- package/server/service/draft-release-good/draft-release-good-mutation.ts +21 -35
- package/server/service/manifest/manifest-mutation.ts +43 -63
- package/server/service/release-good/release-good-mutation.ts +11 -10
|
@@ -35,6 +35,7 @@ import { OrderProduct } from '../order-product/order-product'
|
|
|
35
35
|
import { NewOrderProduct, OrderProductPatch } from '../order-product/order-product-types'
|
|
36
36
|
import { OrderVas } from '../order-vas/order-vas'
|
|
37
37
|
import { ReleaseGood } from '../release-good/release-good'
|
|
38
|
+
import { webhookHandler, WebhookEvents } from '@things-factory/integration-base'
|
|
38
39
|
import { confirmReleaseGood, deleteReleaseGood, rejectReleaseGood } from '../release-good/release-good-mutation'
|
|
39
40
|
import { Vas } from '../vas/vas'
|
|
40
41
|
import { validateBulkArrivalNoticesFunction } from './'
|
|
@@ -70,6 +71,7 @@ export class ArrivalNoticeMutation {
|
|
|
70
71
|
context,
|
|
71
72
|
tx
|
|
72
73
|
)
|
|
74
|
+
webhookHandler(createdArrivalNotice, { id: createdArrivalNotice.bizplace }, WebhookEvents.ArrivalNoticeCreated)
|
|
73
75
|
|
|
74
76
|
return createdArrivalNotice
|
|
75
77
|
}
|
|
@@ -92,6 +94,8 @@ export class ArrivalNoticeMutation {
|
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
webhookHandler(arrivalNotice, arrivalNotice.bizplace, WebhookEvents.ArrivalNoticeConfirmed)
|
|
98
|
+
|
|
95
99
|
return arrivalNotice
|
|
96
100
|
}
|
|
97
101
|
|
|
@@ -154,84 +158,84 @@ export class ArrivalNoticeMutation {
|
|
|
154
158
|
const { user, domain, tx }: { user: User; domain: Domain; tx: EntityManager } = context.state
|
|
155
159
|
|
|
156
160
|
try {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
arrivalNotice.status = approvedAddEditProducts ? ORDER_STATUS.PENDING : ORDER_STATUS.PENDING_APPROVAL
|
|
163
|
-
arrivalNotice.updater = user
|
|
164
|
-
arrivalNotice = await tx.getRepository(ArrivalNotice).save(arrivalNotice)
|
|
165
|
-
|
|
166
|
-
//only for status GAN in 'PENDING'
|
|
167
|
-
//allow to add/edit products without approval from client
|
|
168
|
-
if (approvedAddEditProducts) {
|
|
169
|
-
if (newOrderProducts?.length > 0) {
|
|
170
|
-
let updatedNewOrderProducts = newOrderProducts.map(op => {
|
|
171
|
-
op.status = ORDER_PRODUCT_STATUS.PENDING
|
|
172
|
-
return op
|
|
173
|
-
})
|
|
161
|
+
let arrivalNotice: ArrivalNotice = await tx.getRepository(ArrivalNotice).findOne({
|
|
162
|
+
where: { name: ganNo },
|
|
163
|
+
relations: ['bizplace', 'orderProducts']
|
|
164
|
+
})
|
|
174
165
|
|
|
175
|
-
|
|
176
|
-
|
|
166
|
+
arrivalNotice.status = approvedAddEditProducts ? ORDER_STATUS.PENDING : ORDER_STATUS.PENDING_APPROVAL
|
|
167
|
+
arrivalNotice.updater = user
|
|
168
|
+
arrivalNotice = await tx.getRepository(ArrivalNotice).save(arrivalNotice)
|
|
169
|
+
|
|
170
|
+
//only for status GAN in 'PENDING'
|
|
171
|
+
//allow to add/edit products without approval from client
|
|
172
|
+
if (approvedAddEditProducts) {
|
|
173
|
+
if (newOrderProducts?.length > 0) {
|
|
174
|
+
let updatedNewOrderProducts = newOrderProducts.map(op => {
|
|
175
|
+
op.status = ORDER_PRODUCT_STATUS.PENDING
|
|
176
|
+
return op
|
|
177
|
+
})
|
|
177
178
|
|
|
179
|
+
await addArrivalNoticeProducts(domain, arrivalNotice, updatedNewOrderProducts, user, tx)
|
|
180
|
+
}
|
|
178
181
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
182
|
+
for (const op of existingOrderProducts) {
|
|
183
|
+
await tx
|
|
184
|
+
.createQueryBuilder()
|
|
185
|
+
.update(OrderProduct)
|
|
186
|
+
.set({
|
|
187
|
+
batchId: op.batchId,
|
|
188
|
+
batchIdRef: op.batchIdRef,
|
|
189
|
+
manufactureDate: op.manufactureDate,
|
|
190
|
+
packQty: op.packQty,
|
|
191
|
+
packingType: op.packingType,
|
|
192
|
+
palletQty: op.palletQty,
|
|
193
|
+
remark: op.remark,
|
|
194
|
+
totalUomValue: op.totalUomValue,
|
|
195
|
+
uom: op.uom,
|
|
196
|
+
uomValue: op.uomValue,
|
|
197
|
+
unitPrice: op.unitPrice,
|
|
198
|
+
updater: user
|
|
199
|
+
})
|
|
200
|
+
.where('id = :id', { id: op.id })
|
|
201
|
+
.andWhere('domain_id = :domainId', { domainId: domain.id })
|
|
202
|
+
.execute()
|
|
200
203
|
}
|
|
201
204
|
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
return true
|
|
206
|
+
}
|
|
204
207
|
|
|
205
|
-
|
|
208
|
+
if (newOrderProducts?.length > 0)
|
|
209
|
+
await addArrivalNoticeProducts(domain, arrivalNotice, newOrderProducts, user, tx)
|
|
206
210
|
|
|
207
|
-
|
|
211
|
+
if (existingOrderProducts?.length > 0) await editArrivalNoticeProducts(existingOrderProducts, user, tx)
|
|
208
212
|
|
|
209
|
-
|
|
210
|
-
|
|
213
|
+
// notification logics
|
|
214
|
+
const users: any[] = await getDomainUsers(arrivalNotice?.bizplace, tx)
|
|
211
215
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
if (users?.length && context.header?.referer) {
|
|
217
|
+
const receivers: any[] = users.map(user => user.id)
|
|
218
|
+
const msg = {
|
|
219
|
+
title: `Products are added/edited for ${arrivalNotice.name}`,
|
|
220
|
+
body: `Warehouse need your review for changes to be approved`,
|
|
221
|
+
url: context.header.referer,
|
|
222
|
+
data: { url: context.header.referer }
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @notes Temporary off sendNotification due to suspect of causing wms down
|
|
226
|
+
*/
|
|
227
|
+
|
|
228
|
+
// await sendNotification({
|
|
229
|
+
// receivers,
|
|
230
|
+
// message: { ...msg }
|
|
231
|
+
// })
|
|
219
232
|
}
|
|
220
|
-
/**
|
|
221
|
-
* @notes Temporary off sendNotification due to suspect of causing wms down
|
|
222
|
-
*/
|
|
223
233
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
// })
|
|
234
|
+
return true
|
|
235
|
+
} catch (error) {
|
|
236
|
+
throw new Error(error)
|
|
228
237
|
}
|
|
229
|
-
|
|
230
|
-
return true
|
|
231
|
-
} catch (error) {
|
|
232
|
-
throw new Error(error)
|
|
233
238
|
}
|
|
234
|
-
}
|
|
235
239
|
|
|
236
240
|
@Directive('@privilege(category: "order_customer", privilege: "mutation")')
|
|
237
241
|
@Directive('@transaction')
|
|
@@ -270,7 +274,14 @@ export class ArrivalNoticeMutation {
|
|
|
270
274
|
}
|
|
271
275
|
|
|
272
276
|
await tx.getRepository(ArrivalNotice).update(existingArrivalNotice.id, arrivalNotice)
|
|
273
|
-
|
|
277
|
+
|
|
278
|
+
const updatedArrivalNotice: ArrivalNotice = await tx
|
|
279
|
+
.getRepository(ArrivalNotice)
|
|
280
|
+
.findOne({ where: { id: existingArrivalNotice.id }, relations: ['bizplace', 'domain'] })
|
|
281
|
+
|
|
282
|
+
webhookHandler(updatedArrivalNotice, updatedArrivalNotice.bizplace, WebhookEvents.ArrivalNoticeUpdated)
|
|
283
|
+
|
|
284
|
+
return updatedArrivalNotice
|
|
274
285
|
}
|
|
275
286
|
|
|
276
287
|
@Directive('@privilege(category: "order_customer", privilege: "mutation")')
|
|
@@ -688,7 +699,7 @@ export async function confirmArrivalNoticeFunction(
|
|
|
688
699
|
|
|
689
700
|
let arrivalNotice: ArrivalNotice = await tx
|
|
690
701
|
.getRepository(ArrivalNotice)
|
|
691
|
-
.findOne({ where: { id: foundArrivalNotice.id } })
|
|
702
|
+
.findOne({ where: { id: foundArrivalNotice.id }, relations: ['bizplace', 'domain'] })
|
|
692
703
|
|
|
693
704
|
await tx
|
|
694
705
|
.getRepository(OrderProduct)
|
|
@@ -32,6 +32,9 @@ export class NewArrivalNotice {
|
|
|
32
32
|
@Field()
|
|
33
33
|
ownTransport: boolean
|
|
34
34
|
|
|
35
|
+
@Field({ nullable: true })
|
|
36
|
+
transportVehicle: string
|
|
37
|
+
|
|
35
38
|
@Field({ nullable: true })
|
|
36
39
|
crossDocking: boolean
|
|
37
40
|
|
|
@@ -151,6 +154,9 @@ export class ArrivalNoticePatch {
|
|
|
151
154
|
|
|
152
155
|
@Field({ nullable: true })
|
|
153
156
|
ownTransport: boolean
|
|
157
|
+
|
|
158
|
+
@Field({ nullable: true })
|
|
159
|
+
transportVehicle: string
|
|
154
160
|
|
|
155
161
|
@Field({ nullable: true })
|
|
156
162
|
crossDocking: boolean
|
|
@@ -239,6 +245,9 @@ export class RawArrivalNotice {
|
|
|
239
245
|
@Field()
|
|
240
246
|
ownTransport: boolean
|
|
241
247
|
|
|
248
|
+
@Field({ nullable: true })
|
|
249
|
+
transportVehicle: string
|
|
250
|
+
|
|
242
251
|
@Field({ nullable: true })
|
|
243
252
|
productId?: string
|
|
244
253
|
|
|
@@ -4,6 +4,7 @@ import { EntityManager, getConnection, getRepository, In, Repository } from 'typ
|
|
|
4
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
5
|
import { logger } from '@things-factory/env'
|
|
6
6
|
import { ProductBundle } from '@things-factory/product-base'
|
|
7
|
+
import { webhookHandler, WebhookEvents } from '@things-factory/integration-base'
|
|
7
8
|
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
8
9
|
import { Domain } from '@things-factory/shell'
|
|
9
10
|
import { bulkReleaseGoodsAvailableItemsFunction, DraftReleaseGood, DraftReleaseGoodInfos, OrderProduct } from '../'
|
|
@@ -334,6 +335,9 @@ export async function generateReleaseGoods(_generateReleaseGoodsRecord, context:
|
|
|
334
335
|
if (settingValue > 1) {
|
|
335
336
|
createdReleaseGood = await receiveReleaseGood(createdReleaseGood.name, context, innerTx2)
|
|
336
337
|
}
|
|
338
|
+
|
|
339
|
+
webhookHandler(draftOrder, draftOrder.bizplace, WebhookEvents.DraftOrderConverted)
|
|
340
|
+
webhookHandler(createdReleaseGood, createdReleaseGood.bizplace, WebhookEvents.ReleaseOrderCreated)
|
|
337
341
|
})
|
|
338
342
|
} else {
|
|
339
343
|
if (draftOrder.orderProducts.every(op => op.id === insufficient?.id)) {
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
GraphQLUpload
|
|
4
|
-
} from 'graphql-upload'
|
|
5
|
-
import {
|
|
6
|
-
Arg,
|
|
7
|
-
Ctx,
|
|
8
|
-
Directive,
|
|
9
|
-
Mutation,
|
|
10
|
-
Resolver
|
|
11
|
-
} from 'type-graphql'
|
|
1
|
+
import { FileUpload, GraphQLUpload } from 'graphql-upload'
|
|
2
|
+
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
12
3
|
import {
|
|
13
4
|
Brackets,
|
|
14
5
|
EntityManager,
|
|
@@ -17,37 +8,22 @@ import {
|
|
|
17
8
|
In,
|
|
18
9
|
IsNull,
|
|
19
10
|
Repository,
|
|
20
|
-
SelectQueryBuilder
|
|
11
|
+
SelectQueryBuilder,
|
|
12
|
+
getConnection
|
|
21
13
|
} from 'typeorm'
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
Attachment,
|
|
25
|
-
createAttachments,
|
|
26
|
-
deleteAttachmentsByRef
|
|
27
|
-
} from '@things-factory/attachment-base'
|
|
14
|
+
import { webhookHandler, WebhookEvents } from '@things-factory/integration-base'
|
|
15
|
+
import { Attachment, createAttachments, deleteAttachmentsByRef } from '@things-factory/attachment-base'
|
|
28
16
|
import { User } from '@things-factory/auth-base'
|
|
29
|
-
import {
|
|
30
|
-
Bizplace,
|
|
31
|
-
getPermittedBizplaces
|
|
32
|
-
} from '@things-factory/biz-base'
|
|
17
|
+
import { Bizplace, getPermittedBizplaces } from '@things-factory/biz-base'
|
|
33
18
|
import { GeoCountry } from '@things-factory/geography'
|
|
34
19
|
import { generateId } from '@things-factory/id-rule-base'
|
|
35
20
|
import { LastMileDelivery } from '@things-factory/integration-lmd'
|
|
36
|
-
import {
|
|
37
|
-
Product,
|
|
38
|
-
ProductBundle,
|
|
39
|
-
ProductDetail
|
|
40
|
-
} from '@things-factory/product-base'
|
|
21
|
+
import { Product, ProductBundle, ProductDetail } from '@things-factory/product-base'
|
|
41
22
|
import { Setting } from '@things-factory/setting-base'
|
|
42
23
|
import { Domain } from '@things-factory/shell'
|
|
43
24
|
|
|
44
25
|
// import { Location } from '@things-factory/warehouse-base'
|
|
45
|
-
import {
|
|
46
|
-
DraftReleaseGood,
|
|
47
|
-
DraftReleaseGoodPatch,
|
|
48
|
-
NewDraftReleaseGood,
|
|
49
|
-
OrderProduct
|
|
50
|
-
} from '../'
|
|
26
|
+
import { DraftReleaseGood, DraftReleaseGoodPatch, NewDraftReleaseGood, OrderProduct } from '../'
|
|
51
27
|
import {
|
|
52
28
|
ATTACHMENT_TYPE,
|
|
53
29
|
DRAFT_RELEASE_ORDER_STATUS,
|
|
@@ -81,6 +57,7 @@ export class DraftReleaseGoodMutation {
|
|
|
81
57
|
): Promise<DraftReleaseGood> {
|
|
82
58
|
try {
|
|
83
59
|
const { tx }: { tx: EntityManager } = context.state
|
|
60
|
+
const updateDraft = draftReleaseGood.id ? true : false
|
|
84
61
|
const createdDraftReleaseGood: DraftReleaseGood = await upsertDraftReleaseGoodFunction(
|
|
85
62
|
null,
|
|
86
63
|
draftReleaseGood,
|
|
@@ -91,6 +68,12 @@ export class DraftReleaseGoodMutation {
|
|
|
91
68
|
tx
|
|
92
69
|
)
|
|
93
70
|
|
|
71
|
+
webhookHandler(
|
|
72
|
+
createdDraftReleaseGood,
|
|
73
|
+
createdDraftReleaseGood.bizplace,
|
|
74
|
+
updateDraft ? WebhookEvents.DraftOrderUpdated : WebhookEvents.DraftOrderCreated
|
|
75
|
+
)
|
|
76
|
+
|
|
94
77
|
return createdDraftReleaseGood
|
|
95
78
|
} catch (error) {
|
|
96
79
|
throw error
|
|
@@ -604,7 +587,6 @@ export async function upsertDraftReleaseGoodProducts(
|
|
|
604
587
|
}
|
|
605
588
|
|
|
606
589
|
async function autoAssignLmd(domain, countryId, postalCode, bizplace) {
|
|
607
|
-
|
|
608
590
|
let lmdResult: LastMileDelivery
|
|
609
591
|
const qb: SelectQueryBuilder<LastMileDelivery> = getRepository(LastMileDelivery)
|
|
610
592
|
.createQueryBuilder('lmd')
|
|
@@ -621,7 +603,11 @@ async function autoAssignLmd(domain, countryId, postalCode, bizplace) {
|
|
|
621
603
|
let lmdList = await qb.getMany()
|
|
622
604
|
|
|
623
605
|
if (lmdList.length > 1) {
|
|
624
|
-
qb.andWhere('lmd.id IN (:...lmdIds)', {
|
|
606
|
+
qb.andWhere('lmd.id IN (:...lmdIds)', {
|
|
607
|
+
lmdIds: lmdList.map(lmd => {
|
|
608
|
+
return lmd.id
|
|
609
|
+
})
|
|
610
|
+
})
|
|
625
611
|
}
|
|
626
612
|
|
|
627
613
|
qb.andWhere(
|
|
@@ -1,35 +1,15 @@
|
|
|
1
1
|
import i18next from 'i18next'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from 'type-graphql'
|
|
9
|
-
import {
|
|
10
|
-
In,
|
|
11
|
-
IsNull,
|
|
12
|
-
Not
|
|
13
|
-
} from 'typeorm'
|
|
14
|
-
|
|
15
|
-
import { triggerWebhook } from '@things-factory/integration-base'
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
DISPATCHMENT_STATUS,
|
|
19
|
-
MANIFEST_STATUS
|
|
20
|
-
} from '../../constants'
|
|
2
|
+
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
3
|
+
import { In, IsNull, Not } from 'typeorm'
|
|
4
|
+
|
|
5
|
+
import { webhookHandler, WebhookEvents } from '@things-factory/integration-base'
|
|
6
|
+
|
|
7
|
+
import { DISPATCHMENT_STATUS, MANIFEST_STATUS } from '../../constants'
|
|
21
8
|
import { OrderNoGenerator } from '../../utils'
|
|
22
9
|
import { OrderPackage } from '../order-package/order-package'
|
|
23
10
|
import { ReleaseGood } from '../release-good/release-good'
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
ManifestStatus
|
|
27
|
-
} from './manifest'
|
|
28
|
-
import {
|
|
29
|
-
ManifestItem,
|
|
30
|
-
ManifestPatch,
|
|
31
|
-
NewManifest
|
|
32
|
-
} from './manifest-type'
|
|
11
|
+
import { Manifest, ManifestStatus } from './manifest'
|
|
12
|
+
import { ManifestItem, ManifestPatch, NewManifest } from './manifest-type'
|
|
33
13
|
|
|
34
14
|
@Resolver(Manifest)
|
|
35
15
|
export class ManifestMutation {
|
|
@@ -174,7 +154,8 @@ export class ManifestMutation {
|
|
|
174
154
|
throw new Error(i18next.t('error.tracking_no_already_scanned_before'))
|
|
175
155
|
}
|
|
176
156
|
|
|
177
|
-
let transporter =
|
|
157
|
+
let transporter =
|
|
158
|
+
foundOrderPackage.transporter?.toLowerCase() == 'ems' ? 'efmx' : foundOrderPackage.transporter?.toLowerCase()
|
|
178
159
|
|
|
179
160
|
if (transporter !== shippingProvider?.toLowerCase()) {
|
|
180
161
|
throw new Error(i18next.t('error.tracking_no_belongs_to_x', { x: foundOrderPackage.transporter }))
|
|
@@ -258,49 +239,48 @@ export class ManifestMutation {
|
|
|
258
239
|
@Ctx() context: any
|
|
259
240
|
): Promise<Manifest> {
|
|
260
241
|
const { domain, user, tx } = context.state
|
|
242
|
+
try {
|
|
243
|
+
const manifest: Manifest = await tx.getRepository(Manifest).findOne({
|
|
244
|
+
where: { domain, name, status: Not(MANIFEST_STATUS.CLOSED) }
|
|
245
|
+
})
|
|
246
|
+
if (!manifest) throw new Error(`Unable to find ${name}`)
|
|
247
|
+
|
|
248
|
+
let orderPackages: any[] = await tx.getRepository(OrderPackage).find({ where: { domain, manifest } })
|
|
249
|
+
orderPackages = orderPackages.map((opk: OrderPackage) => {
|
|
250
|
+
return {
|
|
251
|
+
...opk,
|
|
252
|
+
dispatchmentStatus: DISPATCHMENT_STATUS.DISPATCHED,
|
|
253
|
+
updater: user
|
|
254
|
+
}
|
|
255
|
+
})
|
|
256
|
+
await tx.getRepository(OrderPackage).save(orderPackages)
|
|
261
257
|
|
|
262
|
-
|
|
263
|
-
where: { domain, name, status: Not(MANIFEST_STATUS.CLOSED) }
|
|
264
|
-
})
|
|
265
|
-
if (!manifest) throw new Error(`Unable to find ${name}`)
|
|
258
|
+
let releaseGoods: any[] = await tx.getRepository(ReleaseGood).find({ where: { domain, manifest } })
|
|
266
259
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
await tx.getRepository(OrderPackage).save(orderPackages)
|
|
260
|
+
releaseGoods = releaseGoods.map((releaseGood: ReleaseGood) => {
|
|
261
|
+
return {
|
|
262
|
+
...releaseGood,
|
|
263
|
+
dispatchmentStatus: DISPATCHMENT_STATUS.DISPATCHED,
|
|
264
|
+
updater: user
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
await tx.getRepository(ReleaseGood).save(releaseGoods)
|
|
276
268
|
|
|
277
|
-
|
|
269
|
+
const bizplaceIds = [...new Set(orderPackages.map(itm => itm.bizplaceId))]
|
|
278
270
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
...
|
|
282
|
-
|
|
271
|
+
const savedManifest = await tx.getRepository(Manifest).save({
|
|
272
|
+
...manifest,
|
|
273
|
+
...patch,
|
|
274
|
+
status: ManifestStatus.CLOSED,
|
|
275
|
+
dispatchedAt: new Date(),
|
|
283
276
|
updater: user
|
|
284
|
-
}
|
|
285
|
-
})
|
|
286
|
-
await tx.getRepository(ReleaseGood).save(releaseGoods)
|
|
287
|
-
|
|
288
|
-
const bizplaceIds = [...new Set(orderPackages.map(itm => itm.bizplaceId))]
|
|
277
|
+
})
|
|
289
278
|
|
|
290
|
-
|
|
291
|
-
...manifest,
|
|
292
|
-
...patch,
|
|
293
|
-
status: ManifestStatus.CLOSED,
|
|
294
|
-
dispatchedAt: new Date(),
|
|
295
|
-
updater: user
|
|
296
|
-
})
|
|
279
|
+
webhookHandler(manifest.id, bizplaceIds, WebhookEvents.DispatchManifest)
|
|
297
280
|
|
|
298
|
-
|
|
299
|
-
triggerWebhook(manifest.id, bizplaceIds, 'Dispatch Manifest', context)
|
|
281
|
+
return savedManifest
|
|
300
282
|
} catch (e) {
|
|
301
283
|
console.log(e)
|
|
302
284
|
}
|
|
303
|
-
|
|
304
|
-
return savedManifest
|
|
305
285
|
}
|
|
306
286
|
}
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
} from '@things-factory/biz-base'
|
|
25
25
|
import { GeoCountry } from '@things-factory/geography'
|
|
26
26
|
import { generateId } from '@things-factory/id-rule-base'
|
|
27
|
+
import { webhookHandler, WebhookEvents } from '@things-factory/integration-base'
|
|
27
28
|
import { LastMileDelivery } from '@things-factory/integration-lmd'
|
|
28
29
|
import { MarketplaceStore } from '@things-factory/integration-marketplace'
|
|
29
30
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
@@ -235,6 +236,8 @@ export class ReleaseGoodMutation {
|
|
|
235
236
|
awbAttachment
|
|
236
237
|
)
|
|
237
238
|
|
|
239
|
+
webhookHandler(createdReleaseGood, createdReleaseGood.bizplace, WebhookEvents.ReleaseOrderCreated)
|
|
240
|
+
|
|
238
241
|
return createdReleaseGood
|
|
239
242
|
}
|
|
240
243
|
|
|
@@ -251,7 +254,7 @@ export class ReleaseGoodMutation {
|
|
|
251
254
|
const { tx, domain, user } = context.state
|
|
252
255
|
let foundReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
253
256
|
where: { id: releaseGood.id, domain },
|
|
254
|
-
relations: ['shippingOrder']
|
|
257
|
+
relations: ['domain', 'bizplace', 'shippingOrder']
|
|
255
258
|
})
|
|
256
259
|
|
|
257
260
|
if (!foundReleaseGood) {
|
|
@@ -300,6 +303,8 @@ export class ReleaseGoodMutation {
|
|
|
300
303
|
remark: releaseGood?.remark ? releaseGood.remark : null
|
|
301
304
|
})
|
|
302
305
|
|
|
306
|
+
webhookHandler(foundReleaseGood, foundReleaseGood.bizplace, WebhookEvents.ReleaseOrderUpdated)
|
|
307
|
+
|
|
303
308
|
return foundReleaseGood
|
|
304
309
|
}
|
|
305
310
|
|
|
@@ -322,6 +327,8 @@ export class ReleaseGoodMutation {
|
|
|
322
327
|
}
|
|
323
328
|
}
|
|
324
329
|
|
|
330
|
+
webhookHandler(releaseGood, releaseGood.bizplace, WebhookEvents.ReleaseOrderConfirmed)
|
|
331
|
+
|
|
325
332
|
return releaseGood
|
|
326
333
|
}
|
|
327
334
|
|
|
@@ -1197,9 +1204,7 @@ export async function confirmReleaseGood(name: string, context: any, tx?: Entity
|
|
|
1197
1204
|
await tx.getRepository(OrderInventory).save(foundOIs)
|
|
1198
1205
|
|
|
1199
1206
|
// 2. Update status of order vass
|
|
1200
|
-
if (foundOVs && foundOVs.length
|
|
1201
|
-
&& foundOVs.some( vas => vas.status != ORDER_VAS_STATUS.PENDING_APPROVE )
|
|
1202
|
-
) {
|
|
1207
|
+
if (foundOVs && foundOVs.length && foundOVs.some(vas => vas.status != ORDER_VAS_STATUS.PENDING_APPROVE)) {
|
|
1203
1208
|
foundOVs = foundOVs.map((orderVas: OrderVas) => {
|
|
1204
1209
|
return {
|
|
1205
1210
|
...orderVas,
|
|
@@ -1258,7 +1263,7 @@ export async function receiveReleaseGood(name: string, context: any, tx: EntityM
|
|
|
1258
1263
|
|
|
1259
1264
|
const foundReleaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
1260
1265
|
where: { domain, name, status: ORDER_STATUS.PENDING_RECEIVE },
|
|
1261
|
-
relations: ['bizplace', 'orderInventories', 'orderVass', 'lastMileDelivery']
|
|
1266
|
+
relations: ['domain', 'bizplace', 'orderInventories', 'orderVass', 'lastMileDelivery']
|
|
1262
1267
|
})
|
|
1263
1268
|
|
|
1264
1269
|
if (!foundReleaseGood) throw new Error(`Release good order doesn't exists.`)
|
|
@@ -1286,9 +1291,7 @@ export async function receiveReleaseGood(name: string, context: any, tx: EntityM
|
|
|
1286
1291
|
await tx.getRepository(OrderInventory).save(foundOIs)
|
|
1287
1292
|
|
|
1288
1293
|
// 2. Update status of order vass
|
|
1289
|
-
if (foundOVs && foundOVs.length
|
|
1290
|
-
&& foundOVs.some( vas => vas.status != ORDER_VAS_STATUS.PENDING_APPROVE )
|
|
1291
|
-
) {
|
|
1294
|
+
if (foundOVs && foundOVs.length && foundOVs.some(vas => vas.status != ORDER_VAS_STATUS.PENDING_APPROVE)) {
|
|
1292
1295
|
foundOVs = foundOVs.map((orderVas: OrderVas) => {
|
|
1293
1296
|
return {
|
|
1294
1297
|
...orderVas,
|
|
@@ -1664,8 +1667,6 @@ export async function bulkGenerateReleaseGood(
|
|
|
1664
1667
|
updater: newReleaseGood?.updater || user
|
|
1665
1668
|
}
|
|
1666
1669
|
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
1670
|
let newOrderProduct: Partial<OrderProduct>
|
|
1670
1671
|
if (!oi?.orderProduct) {
|
|
1671
1672
|
newOrderProduct = {
|