@things-factory/warehouse-base 4.3.246 → 4.3.249
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/location.js +2 -1
- package/dist-server/constants/location.js.map +1 -1
- package/dist-server/service/index.js +7 -2
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/inventory/inventory-query.js +47 -21
- package/dist-server/service/inventory/inventory-query.js.map +1 -1
- package/dist-server/service/inventory/inventory.js +4 -0
- package/dist-server/service/inventory/inventory.js.map +1 -1
- package/dist-server/service/inventory-change/inventory-change-mutation.js +6 -7
- package/dist-server/service/inventory-change/inventory-change-mutation.js.map +1 -1
- package/dist-server/service/inventory-history/inventory-history-query.js +3 -1
- package/dist-server/service/inventory-history/inventory-history-query.js.map +1 -1
- package/dist-server/service/product-detail-stock/index.js +9 -0
- package/dist-server/service/product-detail-stock/index.js.map +1 -0
- package/dist-server/service/product-detail-stock/product-detail-stock-mutation.js +120 -0
- package/dist-server/service/product-detail-stock/product-detail-stock-mutation.js.map +1 -0
- package/dist-server/service/product-detail-stock/product-detail-stock-query.js +66 -0
- package/dist-server/service/product-detail-stock/product-detail-stock-query.js.map +1 -0
- package/dist-server/service/product-detail-stock/product-detail-stock-types.js +57 -0
- package/dist-server/service/product-detail-stock/product-detail-stock-types.js.map +1 -0
- package/dist-server/service/product-detail-stock/product-detail-stock.js +90 -0
- package/dist-server/service/product-detail-stock/product-detail-stock.js.map +1 -0
- package/package.json +9 -9
- package/server/constants/location.ts +2 -1
- package/server/service/index.ts +10 -2
- package/server/service/inventory/inventory-query.ts +52 -24
- package/server/service/inventory/inventory.ts +3 -0
- package/server/service/inventory-change/inventory-change-mutation.ts +6 -7
- package/server/service/inventory-history/inventory-history-query.ts +3 -1
- package/server/service/product-detail-stock/index.ts +6 -0
- package/server/service/product-detail-stock/product-detail-stock-mutation.ts +112 -0
- package/server/service/product-detail-stock/product-detail-stock-query.ts +33 -0
- package/server/service/product-detail-stock/product-detail-stock-types.ts +30 -0
- package/server/service/product-detail-stock/product-detail-stock.ts +79 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
import { getRepository, In } from 'typeorm'
|
|
3
|
+
import { ProductDetailStock } from './product-detail-stock'
|
|
4
|
+
import { NewProductDetailStock, ProductDetailStockPatch } from './product-detail-stock-types'
|
|
5
|
+
|
|
6
|
+
@Resolver(ProductDetailStock)
|
|
7
|
+
export class ProductDetailStockMutation {
|
|
8
|
+
@Directive('@transaction')
|
|
9
|
+
@Mutation(returns => ProductDetailStock, { description: 'To create new ProductDetailStock' })
|
|
10
|
+
async createProductDetailStock(
|
|
11
|
+
@Arg('productDetailStock') productDetailStock: NewProductDetailStock,
|
|
12
|
+
@Ctx() context: any
|
|
13
|
+
): Promise<ProductDetailStock> {
|
|
14
|
+
const { domain, user, tx } = context.state
|
|
15
|
+
|
|
16
|
+
return await tx.getRepository(ProductDetailStock).save({
|
|
17
|
+
...productDetailStock,
|
|
18
|
+
domain,
|
|
19
|
+
creator: user,
|
|
20
|
+
updater: user
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Directive('@transaction')
|
|
25
|
+
@Mutation(returns => ProductDetailStock, { description: 'To modify ProductDetailStock information' })
|
|
26
|
+
async updateProductDetailStock(
|
|
27
|
+
@Arg('id') id: string,
|
|
28
|
+
@Arg('patch') patch: ProductDetailStockPatch,
|
|
29
|
+
@Ctx() context: any
|
|
30
|
+
): Promise<ProductDetailStock> {
|
|
31
|
+
const { domain, user, tx } = context.state
|
|
32
|
+
|
|
33
|
+
const repository = tx.getRepository(ProductDetailStock)
|
|
34
|
+
const productDetailStock = await repository.findOne({
|
|
35
|
+
where: { domain, id }
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return await repository.save({
|
|
39
|
+
...productDetailStock,
|
|
40
|
+
...patch,
|
|
41
|
+
updater: user
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Directive('@transaction')
|
|
46
|
+
@Mutation(returns => [ProductDetailStock], { description: "To modify multiple ProductDetailStocks' information" })
|
|
47
|
+
async updateMultipleProductDetailStock(
|
|
48
|
+
@Arg('patches', type => [ProductDetailStockPatch]) patches: ProductDetailStockPatch[],
|
|
49
|
+
@Ctx() context: any
|
|
50
|
+
): Promise<ProductDetailStock[]> {
|
|
51
|
+
const { domain, user, tx } = context.state
|
|
52
|
+
|
|
53
|
+
let results = []
|
|
54
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
55
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
56
|
+
const productDetailStockRepo = tx.getRepository(ProductDetailStock)
|
|
57
|
+
|
|
58
|
+
if (_createRecords.length > 0) {
|
|
59
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
60
|
+
const newRecord = _createRecords[i]
|
|
61
|
+
|
|
62
|
+
const result = await productDetailStockRepo.save({
|
|
63
|
+
...newRecord,
|
|
64
|
+
domain,
|
|
65
|
+
creator: user,
|
|
66
|
+
updater: user
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
results.push({ ...result, cuFlag: '+' })
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (_updateRecords.length > 0) {
|
|
74
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
75
|
+
const newRecord = _updateRecords[i]
|
|
76
|
+
const productDetailStock = await productDetailStockRepo.findOne(newRecord.id)
|
|
77
|
+
|
|
78
|
+
const result = await productDetailStockRepo.save({
|
|
79
|
+
...productDetailStock,
|
|
80
|
+
...newRecord,
|
|
81
|
+
updater: user
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
results.push({ ...result, cuFlag: 'M' })
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return results
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@Directive('@transaction')
|
|
92
|
+
@Mutation(returns => Boolean, { description: 'To delete ProductDetailStock' })
|
|
93
|
+
async deleteProductDetailStock(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {
|
|
94
|
+
const { domain, tx } = context.state
|
|
95
|
+
|
|
96
|
+
await tx.getRepository(ProductDetailStock).delete({ domain, id })
|
|
97
|
+
return true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@Directive('@transaction')
|
|
101
|
+
@Mutation(returns => Boolean, { description: 'To delete multiple productDetailStocks' })
|
|
102
|
+
async deleteProductDetailStocks(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {
|
|
103
|
+
const { domain, tx } = context.state
|
|
104
|
+
|
|
105
|
+
await tx.getRepository(ProductDetailStock).delete({
|
|
106
|
+
domain,
|
|
107
|
+
id: In(ids)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
return true
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
import { getRepository } from 'typeorm'
|
|
3
|
+
import { Domain, ListParam, convertListParams } from '@things-factory/shell'
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { ProductDetailStock } from './product-detail-stock'
|
|
6
|
+
import { ProductDetailStockList } from './product-detail-stock-types'
|
|
7
|
+
|
|
8
|
+
@Resolver(ProductDetailStock)
|
|
9
|
+
export class ProductDetailStockQuery {
|
|
10
|
+
@Query(returns => ProductDetailStock, { description: 'To fetch a ProductDetailStock' })
|
|
11
|
+
async productDetailStock(@Arg('id') id: string, @Ctx() context: any): Promise<ProductDetailStock> {
|
|
12
|
+
const { domain } = context.state
|
|
13
|
+
|
|
14
|
+
return await getRepository(ProductDetailStock).findOne({
|
|
15
|
+
where: { domain, id }
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Query(returns => ProductDetailStockList, { description: 'To fetch multiple ProductDetailStocks' })
|
|
20
|
+
async productDetailStocks(@Args() params: ListParam, @Ctx() context: any): Promise<ProductDetailStockList> {
|
|
21
|
+
const { domain } = context.state
|
|
22
|
+
|
|
23
|
+
const convertedParams = convertListParams(params, domain.id)
|
|
24
|
+
const [items, total] = await getRepository(ProductDetailStock).findAndCount(convertedParams)
|
|
25
|
+
|
|
26
|
+
return { items, total }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@FieldResolver(type => Domain)
|
|
30
|
+
async domain(@Root() productDetailStock: ProductDetailStock): Promise<Domain> {
|
|
31
|
+
return await getRepository(Domain).findOne(productDetailStock.domainId)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
|
|
2
|
+
|
|
3
|
+
import { ProductDetailStock, ProductDetailStockStatus } from './product-detail-stock'
|
|
4
|
+
|
|
5
|
+
@InputType()
|
|
6
|
+
export class NewProductDetailStock {
|
|
7
|
+
@Field()
|
|
8
|
+
name: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@InputType()
|
|
12
|
+
export class ProductDetailStockPatch {
|
|
13
|
+
@Field(type => ID, { nullable: true })
|
|
14
|
+
id?: string
|
|
15
|
+
|
|
16
|
+
@Field({ nullable: true })
|
|
17
|
+
name?: string
|
|
18
|
+
|
|
19
|
+
@Field()
|
|
20
|
+
cuFlag: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@ObjectType()
|
|
24
|
+
export class ProductDetailStockList {
|
|
25
|
+
@Field(type => [ProductDetailStock])
|
|
26
|
+
items: ProductDetailStock[]
|
|
27
|
+
|
|
28
|
+
@Field(type => Int)
|
|
29
|
+
total: number
|
|
30
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CreateDateColumn,
|
|
3
|
+
UpdateDateColumn,
|
|
4
|
+
Entity,
|
|
5
|
+
Index,
|
|
6
|
+
Column,
|
|
7
|
+
RelationId,
|
|
8
|
+
ManyToOne,
|
|
9
|
+
OneToOne,
|
|
10
|
+
JoinColumn,
|
|
11
|
+
PrimaryGeneratedColumn
|
|
12
|
+
} from 'typeorm'
|
|
13
|
+
import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
|
|
14
|
+
|
|
15
|
+
import { ProductDetail } from '@things-factory/product-base'
|
|
16
|
+
import { Domain } from '@things-factory/shell'
|
|
17
|
+
|
|
18
|
+
export enum ProductDetailStockStatus {
|
|
19
|
+
STATUS_A = 'STATUS_A',
|
|
20
|
+
STATUS_B = 'STATUS_B'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
registerEnumType(ProductDetailStockStatus, {
|
|
24
|
+
name: 'ProductDetailStockStatus',
|
|
25
|
+
description: 'state enumeration of a productDetailStock'
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
@Entity()
|
|
29
|
+
@Index(
|
|
30
|
+
'ix_product_detail_stock_0',
|
|
31
|
+
(productDetailStock: ProductDetailStock) => [productDetailStock.domain, productDetailStock.id],
|
|
32
|
+
{ unique: true }
|
|
33
|
+
)
|
|
34
|
+
@ObjectType({ description: 'Entity for ProductDetailStock' })
|
|
35
|
+
export class ProductDetailStock {
|
|
36
|
+
@PrimaryGeneratedColumn('uuid')
|
|
37
|
+
@Field(type => ID)
|
|
38
|
+
readonly id: string
|
|
39
|
+
|
|
40
|
+
@OneToOne(type => ProductDetail, { nullable: true })
|
|
41
|
+
@JoinColumn()
|
|
42
|
+
@Field(type => ProductDetail, { nullable: true })
|
|
43
|
+
productDetail: ProductDetail
|
|
44
|
+
|
|
45
|
+
@Column('float')
|
|
46
|
+
@Field({ nullable: true })
|
|
47
|
+
qty: number
|
|
48
|
+
|
|
49
|
+
@Column('float', { nullable: true })
|
|
50
|
+
@Field({ nullable: true })
|
|
51
|
+
lockedQty: number
|
|
52
|
+
|
|
53
|
+
@Column('float', { nullable: true })
|
|
54
|
+
@Field({ nullable: true })
|
|
55
|
+
unassignedQty: number
|
|
56
|
+
|
|
57
|
+
@Column('float', { nullable: true })
|
|
58
|
+
@Field({ nullable: true })
|
|
59
|
+
uomValue: number
|
|
60
|
+
|
|
61
|
+
@Column('float', { nullable: true })
|
|
62
|
+
@Field({ nullable: true })
|
|
63
|
+
lockedUomValue: number
|
|
64
|
+
|
|
65
|
+
@Column('float', { nullable: true })
|
|
66
|
+
@Field({ nullable: true })
|
|
67
|
+
unassignedUomValue: number
|
|
68
|
+
|
|
69
|
+
@ManyToOne(type => Domain)
|
|
70
|
+
@Field({ nullable: true })
|
|
71
|
+
domain?: Domain
|
|
72
|
+
|
|
73
|
+
@RelationId((productDetailStock: ProductDetailStock) => productDetailStock.domain)
|
|
74
|
+
domainId?: string
|
|
75
|
+
|
|
76
|
+
@UpdateDateColumn()
|
|
77
|
+
@Field({ nullable: true })
|
|
78
|
+
updatedAt?: Date
|
|
79
|
+
}
|