@things-factory/sales-base 4.3.94-alpha.1 → 4.3.96
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 +5 -6
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-types.js +4 -0
- package/dist-server/service/arrival-notice/arrival-notice-types.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js +4 -3
- 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 +15 -11
- package/dist-server/service/draft-release-good/draft-release-good-query.js.map +1 -1
- package/dist-server/service/invoice-product/invoice-product.js +3 -8
- package/dist-server/service/invoice-product/invoice-product.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-query.js +1 -2
- package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-types.js +10 -18
- package/dist-server/service/order-inventory/order-inventory-types.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory.js +3 -12
- package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
- package/dist-server/service/order-product/order-product-query.js +0 -1
- package/dist-server/service/order-product/order-product-query.js.map +1 -1
- package/dist-server/service/order-product/order-product-types.js +10 -18
- package/dist-server/service/order-product/order-product-types.js.map +1 -1
- package/dist-server/service/order-vas/order-vas.js +3 -8
- package/dist-server/service/order-vas/order-vas.js.map +1 -1
- package/dist-server/service/others/other-query.js +21 -17
- package/dist-server/service/others/other-query.js.map +1 -1
- package/dist-server/service/others/other-types.js +0 -4
- package/dist-server/service/others/other-types.js.map +1 -1
- package/dist-server/service/purchase-order/purchase-order-mutation.js +2 -10
- package/dist-server/service/purchase-order/purchase-order-mutation.js.map +1 -1
- package/dist-server/service/purchase-order/purchase-order-query.js +0 -1
- package/dist-server/service/purchase-order/purchase-order-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +8 -18
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-query.js +6 -4
- package/dist-server/service/release-good/release-good-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-types.js +4 -8
- package/dist-server/service/release-good/release-good-types.js.map +1 -1
- package/dist-server/service/return-order/return-order-mutation.js +0 -2
- package/dist-server/service/return-order/return-order-mutation.js.map +1 -1
- package/dist-server/service/return-order/return-order-types.js.map +1 -1
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js +3 -8
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js.map +1 -1
- package/dist-server/utils/inventory-util.js +102 -33
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +13 -13
- package/server/service/arrival-notice/arrival-notice-mutation.ts +3 -6
- package/server/service/arrival-notice/arrival-notice-types.ts +4 -1
- package/server/service/draft-release-good/draft-release-good-mutation.ts +4 -3
- package/server/service/draft-release-good/draft-release-good-query.ts +21 -17
- package/server/service/invoice-product/invoice-product.ts +1 -5
- package/server/service/order-inventory/order-inventory-query.ts +0 -2
- package/server/service/order-inventory/order-inventory-types.ts +0 -6
- package/server/service/order-inventory/order-inventory.ts +1 -8
- package/server/service/order-product/order-product-query.ts +0 -1
- package/server/service/order-product/order-product-types.ts +0 -6
- package/server/service/order-vas/order-vas.ts +1 -6
- package/server/service/others/other-query.ts +31 -30
- package/server/service/others/other-types.ts +0 -3
- package/server/service/purchase-order/purchase-order-mutation.ts +1 -10
- package/server/service/purchase-order/purchase-order-query.ts +0 -1
- package/server/service/release-good/release-good-mutation.ts +8 -21
- package/server/service/release-good/release-good-query.ts +7 -4
- package/server/service/release-good/release-good-types.ts +3 -4
- package/server/service/return-order/return-order-mutation.ts +1 -3
- package/server/service/return-order/return-order-types.ts +0 -1
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +1 -5
- package/server/utils/inventory-util.ts +147 -67
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from '@things-factory/biz-base'
|
|
14
14
|
import { generateId } from '@things-factory/id-rule-base'
|
|
15
15
|
import { sendNotification } from '@things-factory/notification'
|
|
16
|
-
import { Product
|
|
16
|
+
import { Product } from '@things-factory/product-base'
|
|
17
17
|
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
18
18
|
import { Domain } from '@things-factory/shell'
|
|
19
19
|
|
|
@@ -339,6 +339,7 @@ export class ArrivalNoticeMutation {
|
|
|
339
339
|
domain,
|
|
340
340
|
bizplace: foundBizplace,
|
|
341
341
|
name: OrderNoGenerator.orderProduct(),
|
|
342
|
+
// product: await childTx.getRepository(Product).findOne(op.product.id),
|
|
342
343
|
status: ORDER_PRODUCT_STATUS.PENDING,
|
|
343
344
|
arrivalNotice: createdArrivalNotice,
|
|
344
345
|
creator: user
|
|
@@ -973,7 +974,6 @@ export async function addArrivalNoticeProducts(
|
|
|
973
974
|
tx?: EntityManager
|
|
974
975
|
): Promise<void> {
|
|
975
976
|
const productRepo: Repository<Product> = tx?.getRepository(Product) || getRepository(Product)
|
|
976
|
-
const productDetailRepo: Repository<ProductDetail> = tx?.getRepository(ProductDetail) || getRepository(ProductDetail)
|
|
977
977
|
const orderProductRepo: Repository<OrderProduct> = tx?.getRepository(OrderProduct) || getRepository(OrderProduct)
|
|
978
978
|
|
|
979
979
|
if (!arrivalNotice?.bizplace || !arrivalNotice?.orderProducts?.length) {
|
|
@@ -991,7 +991,6 @@ export async function addArrivalNoticeProducts(
|
|
|
991
991
|
bizplace: arrivalNotice.bizplace,
|
|
992
992
|
name: OrderNoGenerator.orderProduct(),
|
|
993
993
|
product: await productRepo.findOne(op.product.id),
|
|
994
|
-
productDetail: await productDetailRepo.findOne(op.productDetail.id),
|
|
995
994
|
arrivalNotice,
|
|
996
995
|
creator: user
|
|
997
996
|
}
|
|
@@ -1059,10 +1058,8 @@ function extractArrivalNotices(rawArrivalNotices): Partial<ArrivalNotice[]> {
|
|
|
1059
1058
|
})
|
|
1060
1059
|
|
|
1061
1060
|
const product: Product = Object.assign(new Product(), { id: raw.productId, sku: raw.sku })
|
|
1062
|
-
const productDetail: ProductDetail = Object.assign(new ProductDetail(), { id: raw.productDetailId })
|
|
1063
1061
|
const orderProduct: Partial<OrderProduct> = {
|
|
1064
1062
|
product,
|
|
1065
|
-
productDetail,
|
|
1066
1063
|
batchId: raw.batchId,
|
|
1067
1064
|
batchIdRef: raw.batchIdRef,
|
|
1068
1065
|
packingType: raw.packingType,
|
|
@@ -1073,7 +1070,7 @@ function extractArrivalNotices(rawArrivalNotices): Partial<ArrivalNotice[]> {
|
|
|
1073
1070
|
totalUomValue: raw.totalUomValue,
|
|
1074
1071
|
palletQty: raw.palletQty,
|
|
1075
1072
|
unitPrice: raw.unitPrice,
|
|
1076
|
-
manufactureDate: raw.manufactureDate
|
|
1073
|
+
manufactureDate: raw.manufactureDate
|
|
1077
1074
|
}
|
|
1078
1075
|
|
|
1079
1076
|
if (idx >= 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
2
|
|
|
3
|
-
import { ObjectRef
|
|
3
|
+
import { ObjectRef } from '@things-factory/shell'
|
|
4
4
|
|
|
5
5
|
import { NewOrderProduct } from '../order-product/order-product-types'
|
|
6
6
|
import { NewOrderVas } from '../order-vas/order-vas-types'
|
|
@@ -125,6 +125,9 @@ export class NewArrivalNotice {
|
|
|
125
125
|
@Field({ nullable: true })
|
|
126
126
|
manufactureDate?: string
|
|
127
127
|
|
|
128
|
+
@Field({ nullable: true })
|
|
129
|
+
source?: string
|
|
130
|
+
|
|
128
131
|
@Field({ nullable: true })
|
|
129
132
|
errorMsg: string
|
|
130
133
|
}
|
|
@@ -195,7 +195,6 @@ export class DraftReleaseGoodMutation {
|
|
|
195
195
|
relations: [
|
|
196
196
|
'orderProducts',
|
|
197
197
|
'orderProducts.product',
|
|
198
|
-
'orderProducts.productDetail',
|
|
199
198
|
'orderProducts.productBundle',
|
|
200
199
|
'shippingOrder',
|
|
201
200
|
'bizplace',
|
|
@@ -263,7 +262,10 @@ export class DraftReleaseGoodMutation {
|
|
|
263
262
|
draftOrder.orderProducts = draftOrder.orderProducts.map(itm => {
|
|
264
263
|
let foundProductInv = productInventory.items.find(
|
|
265
264
|
i =>
|
|
266
|
-
(i.
|
|
265
|
+
(i.productId == itm?.product?.id || i.productId == itm?.productBundle?.id) &&
|
|
266
|
+
i.packingType == itm.packingType &&
|
|
267
|
+
i.packingSize == itm.packingSize &&
|
|
268
|
+
i.uom == itm.uom &&
|
|
267
269
|
itm.releaseQty <= i.remainQty
|
|
268
270
|
)
|
|
269
271
|
return {
|
|
@@ -633,7 +635,6 @@ export async function upsertDraftReleaseGoodProducts(
|
|
|
633
635
|
relations: [
|
|
634
636
|
'orderProducts',
|
|
635
637
|
'orderProducts.product',
|
|
636
|
-
'orderProducts.productDetail',
|
|
637
638
|
'orderProducts.productBundle',
|
|
638
639
|
'orderProducts.creator',
|
|
639
640
|
'orderProducts.updater'
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { Arg, Args, Ctx,
|
|
2
|
-
import {
|
|
1
|
+
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root, Directive } from 'type-graphql'
|
|
2
|
+
import { getRepository, SelectQueryBuilder, EntityManager, In, getManager } from 'typeorm'
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { buildQuery, Domain, ListParam } from '@things-factory/shell'
|
|
4
|
+
import { checkUserBelongsDomain, User } from '@things-factory/auth-base'
|
|
5
|
+
import { Bizplace, getPermittedBizplaces, getPermittedBizplaceIds } from '@things-factory/biz-base'
|
|
6
|
+
import { buildQuery, Domain, ListParam, Filter, Pagination, Sorting } from '@things-factory/shell'
|
|
8
7
|
|
|
9
|
-
import {
|
|
10
|
-
import { InventoryUtil } from '../../utils'
|
|
8
|
+
import { DRAFT_RELEASE_ORDER_STATUS, ORDER_STATUS } from '../../constants'
|
|
11
9
|
import { DraftReleaseGood } from './draft-release-good'
|
|
12
10
|
import { DraftReleaseGoodList } from './draft-release-good-type'
|
|
13
11
|
|
|
12
|
+
import { Attachment } from '@things-factory/attachment-base'
|
|
13
|
+
import { ATTACHMENT_TYPE } from '../../constants'
|
|
14
|
+
|
|
15
|
+
import { InventoryUtil } from '../../utils'
|
|
16
|
+
import { OrderProduct } from '../order-product/order-product'
|
|
17
|
+
|
|
14
18
|
@Resolver(DraftReleaseGood)
|
|
15
19
|
export class DraftReleaseGoodQuery {
|
|
16
20
|
@Query(returns => DraftReleaseGood, { description: 'To fetch a DraftReleaseGood' })
|
|
@@ -110,10 +114,10 @@ export class DraftReleaseGoodQuery {
|
|
|
110
114
|
where drg1.status ='DRAFT' AND drg1.domain_id = $1
|
|
111
115
|
AND NOT EXISTS (
|
|
112
116
|
SELECT * FROM warehouse_bizplace_onhand_inventories wboi
|
|
113
|
-
where (wboi."
|
|
114
|
-
and wboi."
|
|
115
|
-
and wboi."
|
|
116
|
-
AND wboi."
|
|
117
|
+
where (wboi."productId" = op.product_id or wboi."productBundleId" = op.product_id)
|
|
118
|
+
and wboi."domainId" = op.domain_id
|
|
119
|
+
and wboi."bizplaceId" = op.bizplace_id
|
|
120
|
+
AND wboi."remainQty" >= op.release_qty
|
|
117
121
|
) GROUP BY drg1.id
|
|
118
122
|
)
|
|
119
123
|
`,
|
|
@@ -251,7 +255,6 @@ export async function getDraftReleaseGoodFunction(_: any, name: any, context: an
|
|
|
251
255
|
'releaseGood',
|
|
252
256
|
'orderProducts',
|
|
253
257
|
'orderProducts.product',
|
|
254
|
-
'orderProducts.productDetail',
|
|
255
258
|
'orderProducts.productBundle',
|
|
256
259
|
'shippingOrder',
|
|
257
260
|
'bizplace',
|
|
@@ -313,7 +316,11 @@ export async function getDraftReleaseGoodFunction(_: any, name: any, context: an
|
|
|
313
316
|
|
|
314
317
|
result.orderProducts = result.orderProducts.map(itm => {
|
|
315
318
|
let foundProductInv = productInventory?.items.find(
|
|
316
|
-
i =>
|
|
319
|
+
i =>
|
|
320
|
+
(i.productId == itm?.product?.id || i.productId == itm?.productBundle?.id) &&
|
|
321
|
+
i.packingType == itm.packingType &&
|
|
322
|
+
i.packingSize == itm.packingSize &&
|
|
323
|
+
i.uom == itm.uom
|
|
317
324
|
)
|
|
318
325
|
return {
|
|
319
326
|
...itm,
|
|
@@ -323,9 +330,6 @@ export async function getDraftReleaseGoodFunction(_: any, name: any, context: an
|
|
|
323
330
|
brand: foundProductInv.productBrand,
|
|
324
331
|
sku: foundProductInv.productSKU
|
|
325
332
|
},
|
|
326
|
-
productDetail: itm.productDetail || {
|
|
327
|
-
id: foundProductInv.productDetailId
|
|
328
|
-
},
|
|
329
333
|
groupType: foundProductInv ? foundProductInv.groupType : 'SINGLE',
|
|
330
334
|
remainQty: foundProductInv ? foundProductInv.remainQty : 0,
|
|
331
335
|
remainUomValue: foundProductInv ? foundProductInv.remainUomValue : 0,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from 'typeorm'
|
|
12
12
|
|
|
13
13
|
import { User } from '@things-factory/auth-base'
|
|
14
|
-
import { Product
|
|
14
|
+
import { Product } from '@things-factory/product-base'
|
|
15
15
|
import { Domain } from '@things-factory/shell'
|
|
16
16
|
|
|
17
17
|
import { Invoice } from '../invoice/invoice'
|
|
@@ -77,10 +77,6 @@ export class InvoiceProduct {
|
|
|
77
77
|
@Field({ nullable: true })
|
|
78
78
|
shippingFeePaidByCustomer: number
|
|
79
79
|
|
|
80
|
-
@ManyToOne(type => ProductDetail, { nullable: true })
|
|
81
|
-
@Field({ nullable: true })
|
|
82
|
-
productDetail: ProductDetail
|
|
83
|
-
|
|
84
80
|
@CreateDateColumn()
|
|
85
81
|
@Field()
|
|
86
82
|
createdAt: Date
|
|
@@ -286,7 +286,6 @@ export class OrderInventoryQuery {
|
|
|
286
286
|
.leftJoinAndSelect('oi.bizplace', 'bizplace')
|
|
287
287
|
.leftJoinAndSelect('oi.inventory', 'inventory')
|
|
288
288
|
.leftJoinAndSelect('inventory.product', 'product')
|
|
289
|
-
.leftJoinAndSelect('inventory.productDetail', 'productDetail')
|
|
290
289
|
.leftJoinAndSelect('oi.creator', 'creator')
|
|
291
290
|
.leftJoinAndSelect('oi.updater', 'updater')
|
|
292
291
|
|
|
@@ -300,7 +299,6 @@ export class OrderInventoryQuery {
|
|
|
300
299
|
releaseGoodName: item.releaseGood.name,
|
|
301
300
|
palletId: item.inventory.palletId,
|
|
302
301
|
productId: item.inventory.product.id,
|
|
303
|
-
productDetailId: item.inventory.productDetail.id,
|
|
304
302
|
productName: item.inventory.product.name,
|
|
305
303
|
productSKU: item.inventory.product.sku,
|
|
306
304
|
productBrand: item.inventory.product.brand,
|
|
@@ -41,9 +41,6 @@ export class NewOrderInventory {
|
|
|
41
41
|
@Field(type => NewProduct, { nullable: true })
|
|
42
42
|
product: NewProduct
|
|
43
43
|
|
|
44
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
45
|
-
productDetail: ObjectRef
|
|
46
|
-
|
|
47
44
|
@Field({ nullable: true })
|
|
48
45
|
productSKU: string
|
|
49
46
|
|
|
@@ -203,9 +200,6 @@ export class OrderInventoryPatch {
|
|
|
203
200
|
@Field({ nullable: true })
|
|
204
201
|
productId: string
|
|
205
202
|
|
|
206
|
-
@Field({ nullable: true })
|
|
207
|
-
productDetailId: string
|
|
208
|
-
|
|
209
203
|
@Field({ nullable: true })
|
|
210
204
|
orderProductId: string
|
|
211
205
|
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
import { User } from '@things-factory/auth-base'
|
|
15
15
|
import { Bizplace } from '@things-factory/biz-base'
|
|
16
|
-
import { Product
|
|
16
|
+
import { Product } from '@things-factory/product-base'
|
|
17
17
|
import { Domain } from '@things-factory/shell'
|
|
18
18
|
import { Inventory, Location } from '@things-factory/warehouse-base'
|
|
19
19
|
|
|
@@ -341,13 +341,6 @@ export class OrderInventory {
|
|
|
341
341
|
@Field({ nullable: true })
|
|
342
342
|
loadedAt: Date
|
|
343
343
|
|
|
344
|
-
@ManyToOne(type => ProductDetail, { nullable: true })
|
|
345
|
-
@Field({ nullable: true })
|
|
346
|
-
productDetail: ProductDetail
|
|
347
|
-
|
|
348
|
-
@Field({ nullable: true })
|
|
349
|
-
productDetailId: String
|
|
350
|
-
|
|
351
344
|
@Field({ nullable: true })
|
|
352
345
|
dispatchedAt: Date
|
|
353
346
|
|
|
@@ -26,7 +26,6 @@ export class OrderProductQuery {
|
|
|
26
26
|
|
|
27
27
|
let qb: SelectQueryBuilder<OrderProduct> = await getRepository(OrderProduct).createQueryBuilder('op')
|
|
28
28
|
qb.leftJoinAndSelect('op.product', 'product')
|
|
29
|
-
.leftJoinAndSelect('op.productDetail', 'productDetail')
|
|
30
29
|
.leftJoinAndSelect('op.domain', 'domain')
|
|
31
30
|
.leftJoinAndSelect('op.bizplace', 'bizplace')
|
|
32
31
|
.leftJoinAndSelect('bizplace.company', 'company')
|
|
@@ -84,9 +84,6 @@ export class OrderProductPatch {
|
|
|
84
84
|
@Field(type => ObjectRef, { nullable: true })
|
|
85
85
|
toInventory: ObjectRef
|
|
86
86
|
|
|
87
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
88
|
-
productDetail: ObjectRef
|
|
89
|
-
|
|
90
87
|
@Field(type => InboundProduct, { nullable: true })
|
|
91
88
|
product: InboundProduct
|
|
92
89
|
|
|
@@ -228,9 +225,6 @@ export class NewOrderProduct {
|
|
|
228
225
|
@Field(type => ObjectRef, { nullable: true })
|
|
229
226
|
toInventory: ObjectRef
|
|
230
227
|
|
|
231
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
232
|
-
productDetail: ObjectRef
|
|
233
|
-
|
|
234
228
|
@Field(type => InboundProduct, { nullable: true })
|
|
235
229
|
product: InboundProduct
|
|
236
230
|
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
|
|
13
13
|
import { User } from '@things-factory/auth-base'
|
|
14
14
|
import { Bizplace } from '@things-factory/biz-base'
|
|
15
|
-
import { Product
|
|
15
|
+
import { Product } from '@things-factory/product-base'
|
|
16
16
|
import { Domain } from '@things-factory/shell'
|
|
17
17
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
18
18
|
|
|
@@ -200,10 +200,6 @@ export class OrderVas {
|
|
|
200
200
|
@Field()
|
|
201
201
|
updatedAt: Date
|
|
202
202
|
|
|
203
|
-
@ManyToOne(type => ProductDetail, { nullable: true })
|
|
204
|
-
@Field({ nullable: true })
|
|
205
|
-
productDetail: ProductDetail
|
|
206
|
-
|
|
207
203
|
@ManyToOne(type => User)
|
|
208
204
|
@Field(type => User, { nullable: true })
|
|
209
205
|
creator: User
|
|
@@ -217,5 +213,4 @@ export class OrderVas {
|
|
|
217
213
|
|
|
218
214
|
@RelationId((orderVas: OrderVas) => orderVas.updater)
|
|
219
215
|
updaterId: string
|
|
220
|
-
|
|
221
216
|
}
|
|
@@ -205,30 +205,32 @@ export class OtherQuery {
|
|
|
205
205
|
|
|
206
206
|
let packageUomValue = availableItem ? availableItem.remainUomValue / availableItem.remainQty : null
|
|
207
207
|
const newOrderInventory: any = {
|
|
208
|
-
product:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
? {
|
|
214
|
-
...items[0],
|
|
215
|
-
remainQty: total > 0 ? items[0].remainQty : null,
|
|
216
|
-
remainUomValue: total > 0 ? items[0].remainUomValue : null,
|
|
217
|
-
remainUomValueWithUom: total > 0 ? items[0].remainUomValueWithUom : ''
|
|
208
|
+
product: availableItem
|
|
209
|
+
? {
|
|
210
|
+
id: availableItem.productId,
|
|
211
|
+
sku: availableItem.productSKU,
|
|
212
|
+
name: availableItem.productName
|
|
218
213
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
214
|
+
: { id: null },
|
|
215
|
+
inventory: availableItem
|
|
216
|
+
? {
|
|
217
|
+
...availableItem,
|
|
218
|
+
remainQty: availableItem ? availableItem.remainQty : null,
|
|
219
|
+
remainUomValue: availableItem ? availableItem.remainUomValue : null,
|
|
220
|
+
remainUomValueWithUom: availableItem ? availableItem.remainUomValueWithUom : ''
|
|
221
|
+
}
|
|
222
|
+
: null,
|
|
223
|
+
productId: availableItem ? availableItem.productId : null,
|
|
224
|
+
productSKU: availableItem ? availableItem.productSKU : orderInventory.productSKU,
|
|
225
|
+
productName: availableItem ? availableItem.productName : null,
|
|
226
|
+
uom: availableItem ? availableItem.uom : null,
|
|
227
|
+
remainQty: availableItem ? availableItem.remainQty : null,
|
|
228
|
+
remainUomValue: availableItem ? availableItem.remainUomValue : null,
|
|
229
|
+
remainUomValueWithUom: availableItem ? availableItem.remainUomValueWithUom : '',
|
|
230
|
+
batchId: availableItem ? availableItem.batchId : null,
|
|
231
|
+
batchIdRef: availableItem ? availableItem.batchIdRef : null,
|
|
232
|
+
packingType: availableItem ? availableItem.packingType : orderInventory.packingType,
|
|
233
|
+
packingSize: availableItem ? availableItem.packingSize : 1,
|
|
232
234
|
releaseQty: orderInventory.releaseQty
|
|
233
235
|
? Number.isInteger(orderInventory.releaseQty)
|
|
234
236
|
? orderInventory.releaseQty
|
|
@@ -352,7 +354,7 @@ export class OtherQuery {
|
|
|
352
354
|
let productDetail: ProductDetail
|
|
353
355
|
const hasConditions: boolean = Boolean(
|
|
354
356
|
(orderProduct?.packingType && orderProduct?.packingType.trim() != '') ||
|
|
355
|
-
|
|
357
|
+
(orderProduct?.uom && orderProduct?.uom.trim() != '')
|
|
356
358
|
)
|
|
357
359
|
let productDetailCondition: any = { product: foundProduct }
|
|
358
360
|
|
|
@@ -375,8 +377,8 @@ export class OtherQuery {
|
|
|
375
377
|
? productDetail.uomValue
|
|
376
378
|
: null
|
|
377
379
|
: orderProduct?.uomValue
|
|
378
|
-
|
|
379
|
-
|
|
380
|
+
? orderProduct.uomValue
|
|
381
|
+
: productDetail.uomValue
|
|
380
382
|
|
|
381
383
|
newOrderProduct = {
|
|
382
384
|
...orderProduct,
|
|
@@ -482,7 +484,7 @@ export class OtherQuery {
|
|
|
482
484
|
let productDetail: ProductDetail
|
|
483
485
|
const hasConditions: boolean = Boolean(
|
|
484
486
|
(orderProduct?.packingType && orderProduct?.packingType.trim() != '') ||
|
|
485
|
-
|
|
487
|
+
(orderProduct?.uom && orderProduct?.uom.trim() != '')
|
|
486
488
|
)
|
|
487
489
|
let productDetailCondition: any = { product: foundProduct }
|
|
488
490
|
|
|
@@ -505,8 +507,8 @@ export class OtherQuery {
|
|
|
505
507
|
? productDetail.uomValue
|
|
506
508
|
: null
|
|
507
509
|
: orderProduct?.uomValue
|
|
508
|
-
|
|
509
|
-
|
|
510
|
+
? orderProduct.uomValue
|
|
511
|
+
: productDetail.uomValue
|
|
510
512
|
|
|
511
513
|
newOrderProduct = {
|
|
512
514
|
...orderProduct,
|
|
@@ -526,7 +528,6 @@ export class OtherQuery {
|
|
|
526
528
|
primaryUnit: productDetail?.uom ? productDetail.uom : null,
|
|
527
529
|
primaryValue: productDetail?.uomValue ? productDetail.uomValue : null
|
|
528
530
|
},
|
|
529
|
-
productDetail,
|
|
530
531
|
totalUomValue:
|
|
531
532
|
orderProduct.packQty > 0
|
|
532
533
|
? uomValue
|
|
@@ -69,14 +69,7 @@ export class PurchaseOrderMutation {
|
|
|
69
69
|
|
|
70
70
|
const findPurchaseOrder: PurchaseOrder = await getRepository(PurchaseOrder).findOne({
|
|
71
71
|
where: { domain, id },
|
|
72
|
-
relations: [
|
|
73
|
-
'orderProducts',
|
|
74
|
-
'orderProducts.product',
|
|
75
|
-
'orderProducts.productDetail',
|
|
76
|
-
'bufferLocation',
|
|
77
|
-
'bizplace',
|
|
78
|
-
'domain'
|
|
79
|
-
]
|
|
72
|
+
relations: ['orderProducts', 'orderProducts.product', 'bufferLocation', 'bizplace', 'domain']
|
|
80
73
|
})
|
|
81
74
|
|
|
82
75
|
// const findPurchaseOrder: PurchaseOrder = await tx.getRepository(PurchaseOrder).findOne({id}, { relations:['bizplace']})
|
|
@@ -425,7 +418,6 @@ export async function upsertPurchaseOrderProducts(
|
|
|
425
418
|
const bizplaceRepo: Repository<Product> = tx?.getRepository(Bizplace) || getRepository(Bizplace)
|
|
426
419
|
const orderProductRepo: Repository<OrderProduct> = tx?.getRepository(OrderProduct) || getRepository(OrderProduct)
|
|
427
420
|
const productRepo: Repository<Product> = tx?.getRepository(Product) || getRepository(Product)
|
|
428
|
-
const productDetailRepo: Repository<Product> = tx?.getRepository(ProductDetail) || getRepository(ProductDetail)
|
|
429
421
|
|
|
430
422
|
// // Remove all existing order products that do not exist in current input
|
|
431
423
|
let removeOP = purchaseOrder.orderProducts.filter(
|
|
@@ -451,7 +443,6 @@ export async function upsertPurchaseOrderProducts(
|
|
|
451
443
|
bizplace: bizplace,
|
|
452
444
|
name: op?.id ? op.name : OrderNoGenerator.orderProduct(),
|
|
453
445
|
product: await productRepo.findOne(op.product.id),
|
|
454
|
-
productDetail: await productDetailRepo.findOne(op.productDetail.id),
|
|
455
446
|
packingSize: foundProductDetail?.packingSize || 1,
|
|
456
447
|
purchaseOrder: purchaseOrder,
|
|
457
448
|
status: purchaseOrder.status,
|
|
@@ -16,7 +16,7 @@ import { MarketplaceStore } from '@things-factory/integration-marketplace'
|
|
|
16
16
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
17
17
|
import { MarketplaceOrder, MarketplaceProductVariation } from '@things-factory/marketplace-base'
|
|
18
18
|
// import { sendNotification } from '@things-factory/notification'
|
|
19
|
-
import { Product, ProductBundleSetting
|
|
19
|
+
import { Product, ProductBundleSetting } from '@things-factory/product-base'
|
|
20
20
|
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
21
21
|
import { Domain } from '@things-factory/shell'
|
|
22
22
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
@@ -675,7 +675,7 @@ export async function generateReleaseGoodFunction(
|
|
|
675
675
|
|
|
676
676
|
const pbSettings: ProductBundleSetting[] = await tx.getRepository(ProductBundleSetting).find({
|
|
677
677
|
where: { productBundle: oi.product.id },
|
|
678
|
-
relations: ['product', 'productBundle'
|
|
678
|
+
relations: ['product', 'productBundle']
|
|
679
679
|
})
|
|
680
680
|
|
|
681
681
|
pbSettings.forEach(pbs => {
|
|
@@ -689,9 +689,6 @@ export async function generateReleaseGoodFunction(
|
|
|
689
689
|
id: pbs.product.id,
|
|
690
690
|
name: pbs.product.name,
|
|
691
691
|
groupType: PRODUCT_GROUP_TYPE.SINGLE
|
|
692
|
-
},
|
|
693
|
-
productDetail: {
|
|
694
|
-
id: pbs.productDetail.id
|
|
695
692
|
}
|
|
696
693
|
}
|
|
697
694
|
splitBundleOIs.push(splitOI)
|
|
@@ -706,10 +703,6 @@ export async function generateReleaseGoodFunction(
|
|
|
706
703
|
newReleaseGood = await tx.getRepository(ReleaseGood).save(newReleaseGood)
|
|
707
704
|
|
|
708
705
|
for (let oi of orderInventories) {
|
|
709
|
-
let productDetail: any = await tx
|
|
710
|
-
.getRepository(ProductDetail)
|
|
711
|
-
.findOne(oi.productDetail.id, { relations: ['product'] })
|
|
712
|
-
|
|
713
706
|
let newOrderInv: OrderInventory = Object.assign({}, oi)
|
|
714
707
|
newOrderInv = {
|
|
715
708
|
...newOrderInv,
|
|
@@ -718,8 +711,7 @@ export async function generateReleaseGoodFunction(
|
|
|
718
711
|
status: ORDER_INVENTORY_STATUS.PENDING,
|
|
719
712
|
name: OrderNoGenerator.orderInventory(),
|
|
720
713
|
releaseGood: newReleaseGood,
|
|
721
|
-
product:
|
|
722
|
-
productDetail,
|
|
714
|
+
product: await tx.getRepository(Product).findOne(oi.product.id),
|
|
723
715
|
creator: user,
|
|
724
716
|
updater: user
|
|
725
717
|
}
|
|
@@ -757,9 +749,9 @@ export async function generateReleaseGoodFunction(
|
|
|
757
749
|
}
|
|
758
750
|
|
|
759
751
|
let assignedOrderInventories: OrderInventory[] = await InventoryUtil.autoAssignInventoryForRelease(
|
|
752
|
+
newOrderInv.product,
|
|
760
753
|
oi,
|
|
761
|
-
|
|
762
|
-
productDetail,
|
|
754
|
+
oi.packingType,
|
|
763
755
|
locationSortingRules,
|
|
764
756
|
bizplace,
|
|
765
757
|
warehouseDomain,
|
|
@@ -1374,17 +1366,12 @@ export async function bulkGenerateReleaseGood(
|
|
|
1374
1366
|
}
|
|
1375
1367
|
}
|
|
1376
1368
|
|
|
1377
|
-
|
|
1378
|
-
let product = oi.orderProduct?.product
|
|
1379
|
-
if (!productDetail) {
|
|
1380
|
-
productDetail = await tx.getRepository(ProductDetail).findOne(oi.productDetailId, { relations: ['product'] })
|
|
1381
|
-
product = productDetail.product
|
|
1382
|
-
}
|
|
1369
|
+
const product: Product = await tx.getRepository(Product).findOne(oi.productId)
|
|
1383
1370
|
|
|
1384
1371
|
let assignedResult = await InventoryUtil.autoAssignInventoryForRelease(
|
|
1385
|
-
oi,
|
|
1386
1372
|
product,
|
|
1387
|
-
|
|
1373
|
+
oi,
|
|
1374
|
+
oi.packingType,
|
|
1388
1375
|
locationSortingRules,
|
|
1389
1376
|
bizplace,
|
|
1390
1377
|
warehouseDomain,
|
|
@@ -196,7 +196,6 @@ export class ReleaseGoodQuery {
|
|
|
196
196
|
.createQueryBuilder('oi')
|
|
197
197
|
.leftJoinAndSelect('oi.inventory', 'inventory')
|
|
198
198
|
.leftJoinAndSelect('oi.product', 'product')
|
|
199
|
-
.leftJoinAndSelect('oi.productDetail', 'productDetail')
|
|
200
199
|
.leftJoinAndSelect('inventory.location', 'location')
|
|
201
200
|
.where('oi.domain_id = :domainId', { domainId: domain.id })
|
|
202
201
|
.andWhere('oi.release_good_id = :releaseGoodId', { releaseGoodId: releaseGood.id })
|
|
@@ -227,7 +226,6 @@ export class ReleaseGoodQuery {
|
|
|
227
226
|
batchIdRef: inventory.batchIdRef,
|
|
228
227
|
palletId: inventory.palletId,
|
|
229
228
|
product: orderInv.product,
|
|
230
|
-
productDetail: orderInv.productDetail,
|
|
231
229
|
productIdRef: orderInv.product.id,
|
|
232
230
|
productName: `${orderInv.product.name} (${orderInv.product.description})`,
|
|
233
231
|
packingType: orderInv.packingType,
|
|
@@ -377,7 +375,10 @@ export class ReleaseGoodQuery {
|
|
|
377
375
|
params.filters.push({
|
|
378
376
|
name: typeFilter == 'b2c' ? 'releaseDate' : 'createdAt',
|
|
379
377
|
operator: 'gte',
|
|
380
|
-
value:
|
|
378
|
+
value:
|
|
379
|
+
typeFilter == 'b2c'
|
|
380
|
+
? releaseDateFrom
|
|
381
|
+
: fromDateVal.toISOString(),
|
|
381
382
|
relation: false
|
|
382
383
|
})
|
|
383
384
|
}
|
|
@@ -392,7 +393,9 @@ export class ReleaseGoodQuery {
|
|
|
392
393
|
name: typeFilter == 'b2c' ? 'releaseDate' : 'createdAt',
|
|
393
394
|
operator: typeFilter == 'b2c' ? 'lte' : 'lt',
|
|
394
395
|
value:
|
|
395
|
-
typeFilter == 'b2c'
|
|
396
|
+
typeFilter == 'b2c'
|
|
397
|
+
? releaseDateTo
|
|
398
|
+
: new Date(toDateVal.setDate(toDateVal.getDate() + 1)).toISOString(),
|
|
396
399
|
relation: false
|
|
397
400
|
})
|
|
398
401
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
2
|
|
|
3
|
-
import { Product
|
|
3
|
+
import { Product } from '@things-factory/product-base'
|
|
4
4
|
import { ObjectRef } from '@things-factory/shell'
|
|
5
5
|
import { Location } from '@things-factory/warehouse-base'
|
|
6
6
|
|
|
@@ -77,9 +77,6 @@ export class InventoryInfos {
|
|
|
77
77
|
@Field(type => Product, { nullable: true })
|
|
78
78
|
product?: Product
|
|
79
79
|
|
|
80
|
-
@Field(type => ProductDetail, { nullable: true })
|
|
81
|
-
productDetail?: ProductDetail
|
|
82
|
-
|
|
83
80
|
@Field({ nullable: true })
|
|
84
81
|
packingType?: string
|
|
85
82
|
|
|
@@ -188,6 +185,8 @@ export class NewReleaseGood {
|
|
|
188
185
|
@Field({ nullable: true })
|
|
189
186
|
orderMethod: string
|
|
190
187
|
|
|
188
|
+
|
|
189
|
+
|
|
191
190
|
@Field({ nullable: true })
|
|
192
191
|
collectionOrderNo: string
|
|
193
192
|
|
|
@@ -6,7 +6,7 @@ import { Attachment, createAttachments } from '@things-factory/attachment-base'
|
|
|
6
6
|
import { Role, User } from '@things-factory/auth-base'
|
|
7
7
|
import { Bizplace, getDomainUsers } from '@things-factory/biz-base'
|
|
8
8
|
import { sendNotification } from '@things-factory/notification'
|
|
9
|
-
import { Product
|
|
9
|
+
import { Product } from '@things-factory/product-base'
|
|
10
10
|
import { Domain } from '@things-factory/shell'
|
|
11
11
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
12
12
|
|
|
@@ -59,7 +59,6 @@ export class ReturnOrderMutation {
|
|
|
59
59
|
itm =>
|
|
60
60
|
itm.product.id === curr.product.id &&
|
|
61
61
|
itm.packingType === curr.packingType &&
|
|
62
|
-
itm.productDetailId === curr.product.productDetailId &&
|
|
63
62
|
itm.batchId === curr.batchId &&
|
|
64
63
|
itm.packingSize === curr.packingSize
|
|
65
64
|
)
|
|
@@ -100,7 +99,6 @@ export class ReturnOrderMutation {
|
|
|
100
99
|
newOrderInv.name = OrderNoGenerator.orderInventory()
|
|
101
100
|
newOrderInv.returnOrder = createdReturnOrder
|
|
102
101
|
newOrderInv.product = await tx.getRepository(Product).findOne(moi.product.id)
|
|
103
|
-
newOrderInv.productDetail = await tx.getRepository(ProductDetail).findOne(moi.productDetail.id)
|
|
104
102
|
newOrderInv.creator = user
|
|
105
103
|
newOrderInv.updater = user
|
|
106
104
|
|