@things-factory/sales-base 3.8.27 → 3.8.31
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/entities/index.js +6 -3
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/invoice-product.js +94 -0
- package/dist-server/entities/invoice-product.js.map +1 -0
- package/dist-server/entities/invoice.js +163 -24
- package/dist-server/entities/invoice.js.map +1 -1
- package/dist-server/entities/release-good.js +3 -1
- package/dist-server/entities/release-good.js.map +1 -1
- package/dist-server/graphql/resolvers/index.js +3 -0
- package/dist-server/graphql/resolvers/index.js.map +1 -1
- package/dist-server/graphql/resolvers/invoice/create-invoice.js +17 -2
- package/dist-server/graphql/resolvers/invoice/create-invoice.js.map +1 -1
- package/dist-server/graphql/resolvers/invoice-product/create-invoice-product.js +12 -0
- package/dist-server/graphql/resolvers/invoice-product/create-invoice-product.js.map +1 -0
- package/dist-server/graphql/resolvers/invoice-product/delete-invoice-product.js +13 -0
- package/dist-server/graphql/resolvers/invoice-product/delete-invoice-product.js.map +1 -0
- package/dist-server/graphql/resolvers/invoice-product/delete-invoice-products.js +16 -0
- package/dist-server/graphql/resolvers/invoice-product/delete-invoice-products.js.map +1 -0
- package/dist-server/graphql/resolvers/invoice-product/index.js +12 -0
- package/dist-server/graphql/resolvers/invoice-product/index.js.map +1 -0
- package/dist-server/graphql/resolvers/invoice-product/invoice-product-query.js +33 -0
- package/dist-server/graphql/resolvers/invoice-product/invoice-product-query.js.map +1 -0
- package/dist-server/graphql/resolvers/invoice-product/update-invoice-product.js +16 -0
- package/dist-server/graphql/resolvers/invoice-product/update-invoice-product.js.map +1 -0
- package/dist-server/graphql/resolvers/invoice-product/update-multiple-invoice-product.js +31 -0
- package/dist-server/graphql/resolvers/invoice-product/update-multiple-invoice-product.js.map +1 -0
- package/dist-server/graphql/resolvers/release-good/confirm-release-good.js +14 -20
- package/dist-server/graphql/resolvers/release-good/confirm-release-good.js.map +1 -1
- package/dist-server/graphql/types/index.js +4 -0
- package/dist-server/graphql/types/index.js.map +1 -1
- package/dist-server/graphql/types/invoice/invoice-patch.js +38 -5
- package/dist-server/graphql/types/invoice/invoice-patch.js.map +1 -1
- package/dist-server/graphql/types/invoice/invoice.js +38 -4
- package/dist-server/graphql/types/invoice/invoice.js.map +1 -1
- package/dist-server/graphql/types/invoice/new-invoice.js +42 -8
- package/dist-server/graphql/types/invoice/new-invoice.js.map +1 -1
- package/dist-server/graphql/types/invoice-product/index.js +21 -0
- package/dist-server/graphql/types/invoice-product/index.js.map +1 -0
- package/dist-server/graphql/types/invoice-product/invoice-product-list.js +14 -0
- package/dist-server/graphql/types/invoice-product/invoice-product-list.js.map +1 -0
- package/dist-server/graphql/types/invoice-product/invoice-product-patch.js +21 -0
- package/dist-server/graphql/types/invoice-product/invoice-product-patch.js.map +1 -0
- package/dist-server/graphql/types/invoice-product/invoice-product.js +27 -0
- package/dist-server/graphql/types/invoice-product/invoice-product.js.map +1 -0
- package/dist-server/graphql/types/invoice-product/new-invoice-product.js +21 -0
- package/dist-server/graphql/types/invoice-product/new-invoice-product.js.map +1 -0
- package/dist-server/graphql/types/invoice-product/product-input.js +13 -0
- package/dist-server/graphql/types/invoice-product/product-input.js.map +1 -0
- package/dist-server/utils/order-no-generator.js +7 -0
- package/dist-server/utils/order-no-generator.js.map +1 -1
- package/package.json +6 -6
- package/server/entities/index.ts +6 -3
- package/server/entities/invoice-product.ts +64 -0
- package/server/entities/invoice.ts +127 -19
- package/server/entities/release-good.ts +2 -0
- package/server/graphql/resolvers/index.ts +3 -0
- package/server/graphql/resolvers/invoice/create-invoice.ts +43 -6
- package/server/graphql/resolvers/invoice-product/create-invoice-product.ts +16 -0
- package/server/graphql/resolvers/invoice-product/delete-invoice-product.ts +13 -0
- package/server/graphql/resolvers/invoice-product/delete-invoice-products.ts +16 -0
- package/server/graphql/resolvers/invoice-product/index.ts +18 -0
- package/server/graphql/resolvers/invoice-product/invoice-product-query.ts +38 -0
- package/server/graphql/resolvers/invoice-product/update-invoice-product.ts +19 -0
- package/server/graphql/resolvers/invoice-product/update-multiple-invoice-product.ts +46 -0
- package/server/graphql/resolvers/release-good/confirm-release-good.ts +17 -20
- package/server/graphql/types/index.ts +4 -0
- package/server/graphql/types/invoice/invoice-patch.ts +38 -5
- package/server/graphql/types/invoice/invoice.ts +38 -4
- package/server/graphql/types/invoice/new-invoice.ts +42 -8
- package/server/graphql/types/invoice-product/index.ts +20 -0
- package/server/graphql/types/invoice-product/invoice-product-list.ts +8 -0
- package/server/graphql/types/invoice-product/invoice-product-patch.ts +15 -0
- package/server/graphql/types/invoice-product/invoice-product.ts +21 -0
- package/server/graphql/types/invoice-product/new-invoice-product.ts +15 -0
- package/server/graphql/types/invoice-product/product-input.ts +7 -0
- package/server/utils/order-no-generator.ts +11 -0
package/server/entities/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Manifest } from './manifest'
|
|
2
1
|
import { ArrivalNotice } from './arrival-notice'
|
|
3
2
|
import { Claim } from './claim'
|
|
4
3
|
import { ClaimDetail } from './claim-detail'
|
|
@@ -8,7 +7,9 @@ import { DeliveryOrder } from './delivery-order'
|
|
|
8
7
|
import { GoodsReceivalNote } from './goods-receival-note'
|
|
9
8
|
import { InventoryCheck } from './inventory-check'
|
|
10
9
|
import { Invoice } from './invoice'
|
|
10
|
+
import { InvoiceProduct } from './invoice-product'
|
|
11
11
|
import { JobSheet } from './job-sheet'
|
|
12
|
+
import { Manifest } from './manifest'
|
|
12
13
|
import { OrderInventory } from './order-inventory'
|
|
13
14
|
import { OrderProduct } from './order-product'
|
|
14
15
|
import { OrderReverseKitting } from './order-reverse-kitting'
|
|
@@ -25,7 +26,8 @@ import { Vas } from './vas'
|
|
|
25
26
|
import { VasOrder } from './vas-order'
|
|
26
27
|
|
|
27
28
|
export const entities = [
|
|
28
|
-
|
|
29
|
+
InvoiceProduct,
|
|
30
|
+
Manifest,
|
|
29
31
|
PurchaseOrderOtherCharge,
|
|
30
32
|
ArrivalNotice,
|
|
31
33
|
OrderProduct,
|
|
@@ -53,7 +55,6 @@ export const entities = [
|
|
|
53
55
|
]
|
|
54
56
|
|
|
55
57
|
export {
|
|
56
|
-
Manifest,
|
|
57
58
|
ArrivalNotice,
|
|
58
59
|
Claim,
|
|
59
60
|
ClaimDetail,
|
|
@@ -63,7 +64,9 @@ export {
|
|
|
63
64
|
GoodsReceivalNote,
|
|
64
65
|
InventoryCheck,
|
|
65
66
|
Invoice,
|
|
67
|
+
InvoiceProduct,
|
|
66
68
|
JobSheet,
|
|
69
|
+
Manifest,
|
|
67
70
|
OrderInventory,
|
|
68
71
|
OrderProduct,
|
|
69
72
|
OrderReverseKitting,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { Product } from '@things-factory/product-base'
|
|
5
|
+
import { Domain } from '@things-factory/shell'
|
|
6
|
+
|
|
7
|
+
import { Invoice } from './invoice'
|
|
8
|
+
|
|
9
|
+
@Entity()
|
|
10
|
+
@Index('ix_invoice_product_0', (invoiceProduct: InvoiceProduct) => [invoiceProduct.id], {
|
|
11
|
+
unique: true
|
|
12
|
+
})
|
|
13
|
+
export class InvoiceProduct {
|
|
14
|
+
@PrimaryGeneratedColumn('uuid')
|
|
15
|
+
id: string
|
|
16
|
+
|
|
17
|
+
@ManyToOne(type => Domain)
|
|
18
|
+
domain: Domain
|
|
19
|
+
|
|
20
|
+
@Column({ nullable: true })
|
|
21
|
+
sku: string
|
|
22
|
+
|
|
23
|
+
@Column()
|
|
24
|
+
name: string
|
|
25
|
+
|
|
26
|
+
@Column({
|
|
27
|
+
nullable: true
|
|
28
|
+
})
|
|
29
|
+
description: string
|
|
30
|
+
|
|
31
|
+
@ManyToOne(type => Invoice)
|
|
32
|
+
invoice: Invoice
|
|
33
|
+
|
|
34
|
+
@ManyToOne(type => Product, { nullable: true })
|
|
35
|
+
product: Product
|
|
36
|
+
|
|
37
|
+
@Column('int', { default: 0 })
|
|
38
|
+
qty: number
|
|
39
|
+
|
|
40
|
+
@Column('float', { default: 0 })
|
|
41
|
+
otherCharges: number
|
|
42
|
+
|
|
43
|
+
@Column('float', { default: 0 })
|
|
44
|
+
unitPrice: number
|
|
45
|
+
|
|
46
|
+
@Column('float', { default: 0 })
|
|
47
|
+
paidPrice: number
|
|
48
|
+
|
|
49
|
+
@CreateDateColumn()
|
|
50
|
+
createdAt: Date
|
|
51
|
+
|
|
52
|
+
@UpdateDateColumn()
|
|
53
|
+
updatedAt: Date
|
|
54
|
+
|
|
55
|
+
@ManyToOne(type => User, {
|
|
56
|
+
nullable: true
|
|
57
|
+
})
|
|
58
|
+
creator: User
|
|
59
|
+
|
|
60
|
+
@ManyToOne(type => User, {
|
|
61
|
+
nullable: true
|
|
62
|
+
})
|
|
63
|
+
updater: User
|
|
64
|
+
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { User } from '@things-factory/auth-base'
|
|
2
|
-
import { Bizplace } from '@things-factory/biz-base'
|
|
3
|
-
import { Domain } from '@things-factory/shell'
|
|
4
1
|
import {
|
|
5
2
|
Column,
|
|
6
3
|
CreateDateColumn,
|
|
@@ -8,14 +5,20 @@ import {
|
|
|
8
5
|
Index,
|
|
9
6
|
JoinColumn,
|
|
10
7
|
ManyToOne,
|
|
8
|
+
OneToMany,
|
|
11
9
|
OneToOne,
|
|
12
10
|
PrimaryGeneratedColumn,
|
|
13
11
|
UpdateDateColumn
|
|
14
12
|
} from 'typeorm'
|
|
15
|
-
|
|
13
|
+
|
|
14
|
+
import { User } from '@things-factory/auth-base'
|
|
15
|
+
import { Domain } from '@things-factory/shell'
|
|
16
|
+
|
|
17
|
+
import { ReleaseGood } from '../entities'
|
|
18
|
+
import { InvoiceProduct } from './invoice-product'
|
|
16
19
|
|
|
17
20
|
@Entity()
|
|
18
|
-
@Index('ix_invoice_0', (invoice: Invoice) => [invoice.
|
|
21
|
+
@Index('ix_invoice_0', (invoice: Invoice) => [invoice.id], { unique: true })
|
|
19
22
|
export class Invoice {
|
|
20
23
|
@PrimaryGeneratedColumn('uuid')
|
|
21
24
|
id: string
|
|
@@ -26,29 +29,134 @@ export class Invoice {
|
|
|
26
29
|
@Column()
|
|
27
30
|
name: string
|
|
28
31
|
|
|
29
|
-
@
|
|
30
|
-
|
|
32
|
+
@Column({
|
|
33
|
+
nullable: true
|
|
34
|
+
})
|
|
35
|
+
description: string
|
|
31
36
|
|
|
32
|
-
@
|
|
33
|
-
|
|
37
|
+
@OneToMany(type => InvoiceProduct, invoiceProduct => invoiceProduct.invoice)
|
|
38
|
+
invoiceProducts: InvoiceProduct[]
|
|
34
39
|
|
|
35
|
-
@
|
|
36
|
-
|
|
40
|
+
@OneToOne(type => ReleaseGood, { nullable: true })
|
|
41
|
+
@JoinColumn()
|
|
42
|
+
releaseGood: ReleaseGood
|
|
37
43
|
|
|
38
|
-
@Column()
|
|
39
|
-
|
|
44
|
+
@Column({ default: '' })
|
|
45
|
+
refNo1: string
|
|
40
46
|
|
|
41
|
-
@
|
|
42
|
-
|
|
43
|
-
purchaseOrder: PurchaseOrder
|
|
47
|
+
@Column({ default: '' })
|
|
48
|
+
refNo2: string
|
|
44
49
|
|
|
45
|
-
@Column()
|
|
46
|
-
|
|
50
|
+
@Column({ default: '' })
|
|
51
|
+
refNo3: string
|
|
52
|
+
|
|
53
|
+
@Column({ nullable: true })
|
|
54
|
+
issuedOn: Date
|
|
47
55
|
|
|
48
56
|
@Column({
|
|
57
|
+
type: 'uuid',
|
|
49
58
|
nullable: true
|
|
50
59
|
})
|
|
51
|
-
|
|
60
|
+
contactPointRefId: string
|
|
61
|
+
|
|
62
|
+
@Column()
|
|
63
|
+
from: string
|
|
64
|
+
|
|
65
|
+
@Column()
|
|
66
|
+
fromContactPhone: string
|
|
67
|
+
|
|
68
|
+
@Column({ nullable: true })
|
|
69
|
+
fromAddress1: string
|
|
70
|
+
|
|
71
|
+
@Column({ nullable: true })
|
|
72
|
+
fromAddress2: string
|
|
73
|
+
|
|
74
|
+
@Column({ nullable: true })
|
|
75
|
+
fromAddress3: string
|
|
76
|
+
|
|
77
|
+
@Column({ nullable: true })
|
|
78
|
+
fromAddress4: string
|
|
79
|
+
|
|
80
|
+
@Column({ nullable: true })
|
|
81
|
+
fromAddress5: string
|
|
82
|
+
|
|
83
|
+
@Column({ nullable: true })
|
|
84
|
+
fromPostcode: string
|
|
85
|
+
|
|
86
|
+
@Column({ nullable: true })
|
|
87
|
+
fromCity: string
|
|
88
|
+
|
|
89
|
+
@Column({ nullable: true })
|
|
90
|
+
fromState: string
|
|
91
|
+
|
|
92
|
+
@Column({ nullable: true })
|
|
93
|
+
fromCountry: string
|
|
94
|
+
|
|
95
|
+
@Column()
|
|
96
|
+
deliverTo: string
|
|
97
|
+
|
|
98
|
+
@Column()
|
|
99
|
+
deliverToPhone: string
|
|
100
|
+
|
|
101
|
+
@Column()
|
|
102
|
+
deliveryAddress1: string
|
|
103
|
+
|
|
104
|
+
@Column({ nullable: true })
|
|
105
|
+
deliveryAddress2: string
|
|
106
|
+
|
|
107
|
+
@Column({ nullable: true })
|
|
108
|
+
deliveryAddress3: string
|
|
109
|
+
|
|
110
|
+
@Column({ nullable: true })
|
|
111
|
+
deliveryAddress4: string
|
|
112
|
+
|
|
113
|
+
@Column({ nullable: true })
|
|
114
|
+
deliveryAddress5: string
|
|
115
|
+
|
|
116
|
+
@Column()
|
|
117
|
+
deliveryPostcode: string
|
|
118
|
+
|
|
119
|
+
@Column()
|
|
120
|
+
deliveryCity: string
|
|
121
|
+
|
|
122
|
+
@Column()
|
|
123
|
+
deliveryState: string
|
|
124
|
+
|
|
125
|
+
@Column()
|
|
126
|
+
deliveryCountry: string
|
|
127
|
+
|
|
128
|
+
@Column()
|
|
129
|
+
billTo: string
|
|
130
|
+
|
|
131
|
+
@Column()
|
|
132
|
+
billToPhone: string
|
|
133
|
+
|
|
134
|
+
@Column()
|
|
135
|
+
billingAddress1: string
|
|
136
|
+
|
|
137
|
+
@Column({ nullable: true })
|
|
138
|
+
billingAddress2: string
|
|
139
|
+
|
|
140
|
+
@Column({ nullable: true })
|
|
141
|
+
billingAddress3: string
|
|
142
|
+
|
|
143
|
+
@Column({ nullable: true })
|
|
144
|
+
billingAddress4: string
|
|
145
|
+
|
|
146
|
+
@Column({ nullable: true })
|
|
147
|
+
billingAddress5: string
|
|
148
|
+
|
|
149
|
+
@Column()
|
|
150
|
+
billingPostcode: string
|
|
151
|
+
|
|
152
|
+
@Column()
|
|
153
|
+
billingCity: string
|
|
154
|
+
|
|
155
|
+
@Column()
|
|
156
|
+
billingState: string
|
|
157
|
+
|
|
158
|
+
@Column()
|
|
159
|
+
billingCountry: string
|
|
52
160
|
|
|
53
161
|
@ManyToOne(type => User, {
|
|
54
162
|
nullable: true
|
|
@@ -40,6 +40,8 @@ export enum DispatchmentStatus {
|
|
|
40
40
|
}
|
|
41
41
|
@Entity()
|
|
42
42
|
@Index('ix_release-good_0', (releaseGood: ReleaseGood) => [releaseGood.domain, releaseGood.name], { unique: true })
|
|
43
|
+
@Index('ix_release-good_1', (releaseGood: ReleaseGood) => [releaseGood.domain, releaseGood.refNo])
|
|
44
|
+
@Index('ix_release-good_2', (releaseGood: ReleaseGood) => [releaseGood.domain, releaseGood.refNo2])
|
|
43
45
|
export class ReleaseGood {
|
|
44
46
|
@PrimaryGeneratedColumn('uuid')
|
|
45
47
|
id: string
|
|
@@ -7,6 +7,7 @@ import * as DeliveryOrder from './delivery-order'
|
|
|
7
7
|
import * as GoodsReceivalNote from './goods-receival-note'
|
|
8
8
|
import * as InventoryCheck from './inventory-check'
|
|
9
9
|
import * as Invoice from './invoice'
|
|
10
|
+
import * as InvoiceProduct from './invoice-product'
|
|
10
11
|
import * as JobSheet from './job-sheet'
|
|
11
12
|
import * as Manifest from './manifest'
|
|
12
13
|
import * as OrderInventory from './order-inventory'
|
|
@@ -27,6 +28,7 @@ import * as VasOrder from './vas-order'
|
|
|
27
28
|
|
|
28
29
|
export const queries = [
|
|
29
30
|
Invoice.Query,
|
|
31
|
+
InvoiceProduct.Query,
|
|
30
32
|
InventoryCheck.Query,
|
|
31
33
|
JobSheet.Query,
|
|
32
34
|
PurchaseOrder.Query,
|
|
@@ -55,6 +57,7 @@ export const queries = [
|
|
|
55
57
|
|
|
56
58
|
export const mutations = [
|
|
57
59
|
Invoice.Mutation,
|
|
60
|
+
InvoiceProduct.Mutation,
|
|
58
61
|
JobSheet.Mutation,
|
|
59
62
|
InventoryCheck.Mutation,
|
|
60
63
|
PurchaseOrder.Mutation,
|
|
@@ -1,17 +1,54 @@
|
|
|
1
|
+
import { EntityManager, getRepository, Repository } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { Product } from '@things-factory/product-base'
|
|
2
5
|
import { Domain } from '@things-factory/shell'
|
|
3
|
-
|
|
4
|
-
import { Invoice } from '../../../entities'
|
|
6
|
+
|
|
7
|
+
import { Invoice, InvoiceProduct, ReleaseGood } from '../../../entities'
|
|
8
|
+
import { OrderNoGenerator } from '../../../utils'
|
|
5
9
|
|
|
6
10
|
export const createInvoice = {
|
|
7
11
|
async createInvoice(_: any, { invoice }, context: any) {
|
|
8
12
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
13
|
+
let invoiceProducts: InvoiceProduct[] = invoice.invoiceProducts
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
domain,
|
|
15
|
+
let createdInvoice: Invoice = await tx.getRepository(Invoice).save({
|
|
12
16
|
...invoice,
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
domain,
|
|
18
|
+
name: OrderNoGenerator.invoice(),
|
|
19
|
+
releaseGood: await tx.getRepository(ReleaseGood).findOne(invoice?.releaseGood.id),
|
|
20
|
+
creator: user
|
|
15
21
|
})
|
|
22
|
+
|
|
23
|
+
await addInvoiceProducts(domain, createdInvoice, invoiceProducts, user, tx)
|
|
24
|
+
|
|
25
|
+
return createdInvoice
|
|
16
26
|
}
|
|
17
27
|
}
|
|
28
|
+
|
|
29
|
+
export async function addInvoiceProducts(
|
|
30
|
+
domain: Domain,
|
|
31
|
+
invoice: Invoice,
|
|
32
|
+
invoiceProducts: any[],
|
|
33
|
+
user: User,
|
|
34
|
+
tx?: EntityManager
|
|
35
|
+
): Promise<void> {
|
|
36
|
+
const productRepo: Repository<Product> = tx?.getRepository(Product) || getRepository(Product)
|
|
37
|
+
const invoiceProductRepo: Repository<InvoiceProduct> =
|
|
38
|
+
tx?.getRepository(InvoiceProduct) || getRepository(InvoiceProduct)
|
|
39
|
+
|
|
40
|
+
const createdInvoiceProducts: InvoiceProduct[] = await Promise.all(
|
|
41
|
+
invoiceProducts.map(async (invoiceProduct: InvoiceProduct) => {
|
|
42
|
+
return {
|
|
43
|
+
name: OrderNoGenerator.invoiceProduct(),
|
|
44
|
+
...invoiceProduct,
|
|
45
|
+
domain,
|
|
46
|
+
product: await productRepo.findOne(invoiceProduct?.product.id),
|
|
47
|
+
invoice,
|
|
48
|
+
creator: user
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
await invoiceProductRepo.save(createdInvoiceProducts)
|
|
54
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getRepository } from 'typeorm'
|
|
2
|
+
import { InvoiceProduct } from '../../../entities'
|
|
3
|
+
|
|
4
|
+
export const createInvoiceProduct = {
|
|
5
|
+
async createInvoiceProduct(_: any, { invoiceProduct }, context: any) {
|
|
6
|
+
const { domain, user } = context.state
|
|
7
|
+
|
|
8
|
+
return await getRepository(InvoiceProduct).save({
|
|
9
|
+
...invoiceProduct,
|
|
10
|
+
domain,
|
|
11
|
+
creator: user,
|
|
12
|
+
updater: user
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getRepository } from 'typeorm'
|
|
2
|
+
import { InvoiceProduct } from '../../../entities'
|
|
3
|
+
|
|
4
|
+
export const deleteInvoiceProduct = {
|
|
5
|
+
async deleteInvoiceProduct(_: any, { name }, context: any) {
|
|
6
|
+
const { domain, user } = context.state
|
|
7
|
+
|
|
8
|
+
await getRepository(InvoiceProduct).delete({ domain, name })
|
|
9
|
+
|
|
10
|
+
return true
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getRepository, In } from 'typeorm'
|
|
2
|
+
import { InvoiceProduct } from '../../../entities'
|
|
3
|
+
|
|
4
|
+
export const deleteInvoiceProducts = {
|
|
5
|
+
async deleteInvoiceProducts(_: any, { names }, context: any) {
|
|
6
|
+
const { domain, user } = context.state
|
|
7
|
+
|
|
8
|
+
await getRepository(InvoiceProduct).delete({
|
|
9
|
+
domain,
|
|
10
|
+
name: In(names)
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
return true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createInvoiceProduct } from './create-invoice-product'
|
|
2
|
+
import { deleteInvoiceProduct } from './delete-invoice-product'
|
|
3
|
+
import { deleteInvoiceProducts } from './delete-invoice-products'
|
|
4
|
+
import { Query as InvoiceProductQuery } from './invoice-product-query'
|
|
5
|
+
import { updateInvoiceProduct } from './update-invoice-product'
|
|
6
|
+
import { updateMultipleInvoiceProduct } from './update-multiple-invoice-product'
|
|
7
|
+
|
|
8
|
+
export const Query = {
|
|
9
|
+
...InvoiceProductQuery
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Mutation = {
|
|
13
|
+
...updateInvoiceProduct,
|
|
14
|
+
...updateMultipleInvoiceProduct,
|
|
15
|
+
...createInvoiceProduct,
|
|
16
|
+
...deleteInvoiceProduct,
|
|
17
|
+
...deleteInvoiceProducts
|
|
18
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getRepository } from 'typeorm'
|
|
2
|
+
import { Domain, ListParam, convertListParams } from '@things-factory/shell'
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { InvoiceProduct as InvoiceProductEntity } from '../../../entities'
|
|
5
|
+
|
|
6
|
+
export const Query = {
|
|
7
|
+
async invoiceProduct(_: any, { name }, context: any) {
|
|
8
|
+
const { domain, user } = context.state
|
|
9
|
+
const repository = getRepository(InvoiceProductEntity)
|
|
10
|
+
|
|
11
|
+
return await repository.findOne({
|
|
12
|
+
where: { domain, name }
|
|
13
|
+
})
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
async invoiceProducts(_: any, params: ListParam, context: any) {
|
|
17
|
+
const convertedParams = convertListParams(params)
|
|
18
|
+
const [items, total] = await getRepository(InvoiceProductEntity).findAndCount({
|
|
19
|
+
...convertedParams
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
return { items, total }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const InvoiceProduct = {
|
|
27
|
+
async domain(invoiceProduct) {
|
|
28
|
+
return await getRepository(Domain).findOne(invoiceProduct.domainId)
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
async creator(invoiceProduct) {
|
|
32
|
+
return await getRepository(User).findOne(invoiceProduct.creatorId)
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
async updater(invoiceProduct) {
|
|
36
|
+
return await getRepository(User).findOne(invoiceProduct.updaterId)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getRepository } from 'typeorm'
|
|
2
|
+
import { InvoiceProduct } from '../../../entities'
|
|
3
|
+
|
|
4
|
+
export const updateInvoiceProduct = {
|
|
5
|
+
async updateInvoiceProduct(_: any, { name, patch }, context: any) {
|
|
6
|
+
const { domain, user } = context.state
|
|
7
|
+
|
|
8
|
+
const repository = getRepository(InvoiceProduct)
|
|
9
|
+
const invoiceProduct = await repository.findOne({
|
|
10
|
+
where: { domain, name }
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
return await repository.save({
|
|
14
|
+
...invoiceProduct,
|
|
15
|
+
...patch,
|
|
16
|
+
updater: user
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getRepository } from 'typeorm'
|
|
2
|
+
import { InvoiceProduct } from '../../../entities'
|
|
3
|
+
|
|
4
|
+
export const updateMultipleInvoiceProduct = {
|
|
5
|
+
async updateMultipleInvoiceProduct(_: any, { patches }, context: any) {
|
|
6
|
+
const { domain, user } = context.state
|
|
7
|
+
|
|
8
|
+
let results = []
|
|
9
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
10
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
11
|
+
const invoiceProductRepo = getRepository(InvoiceProduct)
|
|
12
|
+
|
|
13
|
+
if (_createRecords.length > 0) {
|
|
14
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
15
|
+
const newRecord = _createRecords[i]
|
|
16
|
+
|
|
17
|
+
const result = await invoiceProductRepo.save({
|
|
18
|
+
...newRecord,
|
|
19
|
+
domain: domain,
|
|
20
|
+
creator: user,
|
|
21
|
+
updater: user,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
results.push({ ...result, cuFlag: '+' })
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (_updateRecords.length > 0) {
|
|
29
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
30
|
+
const newRecord = _updateRecords[i]
|
|
31
|
+
const invoiceProduct = await invoiceProductRepo.findOne({ domain, id: newRecord.id})
|
|
32
|
+
|
|
33
|
+
const result = await invoiceProductRepo.save({
|
|
34
|
+
...invoiceProduct,
|
|
35
|
+
...newRecord,
|
|
36
|
+
updater: user
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
results.push({ ...result, cuFlag: 'M' })
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return results
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
@@ -39,26 +39,25 @@ export async function confirmReleaseGood(name: string, context: any, tx?: Entity
|
|
|
39
39
|
|
|
40
40
|
let foundReleaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
41
41
|
where: { name, status: ORDER_STATUS.PENDING },
|
|
42
|
-
relations: [
|
|
43
|
-
'domain',
|
|
44
|
-
'bizplace',
|
|
45
|
-
'bizplace.domain',
|
|
46
|
-
'bizplace.company',
|
|
47
|
-
'bizplace.company.domain',
|
|
48
|
-
'orderProducts',
|
|
49
|
-
'orderProducts.product',
|
|
50
|
-
'orderProducts.product.productDetails',
|
|
51
|
-
'orderInventories',
|
|
52
|
-
'orderInventories.product',
|
|
53
|
-
'orderVass'
|
|
54
|
-
]
|
|
42
|
+
relations: ['domain', 'bizplace', 'bizplace.domain', 'bizplace.company', 'bizplace.company.domain', 'orderVass']
|
|
55
43
|
})
|
|
56
44
|
|
|
57
45
|
if (!foundReleaseGood) throw new Error(`Release good order doesn't exists.`)
|
|
58
|
-
|
|
46
|
+
|
|
47
|
+
// query orderInventories separately from releaseGood to reduce resource usage
|
|
48
|
+
let foundOIs: OrderInventory[] = await tx.getRepository(OrderInventory).find({
|
|
49
|
+
where: { domain, releaseGood: foundReleaseGood },
|
|
50
|
+
relations: ['product']
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// query orderProducts separately from releaseGood to reduce resource usage
|
|
54
|
+
let foundOPs: OrderProduct[] = await tx.getRepository(OrderProduct).find({
|
|
55
|
+
where: { domain, releaseGood: foundReleaseGood },
|
|
56
|
+
relations: ['product', 'product.productDetails']
|
|
57
|
+
})
|
|
58
|
+
|
|
59
59
|
let foundBundleInfo: any[] = JSON.parse(foundReleaseGood.bundleInfo)
|
|
60
60
|
let foundOVs: OrderVas[] = foundReleaseGood.orderVass
|
|
61
|
-
let foundOPs: OrderProduct[] = foundReleaseGood.orderProducts
|
|
62
61
|
let customerBizplace: Bizplace = foundReleaseGood.bizplace
|
|
63
62
|
const companyDomain: Domain = customerBizplace?.company.domain
|
|
64
63
|
const sellercraft: Sellercraft = await tx
|
|
@@ -68,7 +67,7 @@ export async function confirmReleaseGood(name: string, context: any, tx?: Entity
|
|
|
68
67
|
if (foundReleaseGood.type == 'b2c') {
|
|
69
68
|
if (sellercraft) {
|
|
70
69
|
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
71
|
-
foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, foundReleaseGood)
|
|
70
|
+
foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, { ...foundReleaseGood, orderProducts: foundOPs })
|
|
72
71
|
} else {
|
|
73
72
|
// find for any existing marketplace store connections
|
|
74
73
|
let marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
|
|
@@ -115,11 +114,9 @@ export async function confirmReleaseGood(name: string, context: any, tx?: Entity
|
|
|
115
114
|
if (foundMarketplaceProductVariations) {
|
|
116
115
|
await Promise.all(
|
|
117
116
|
foundMarketplaceProductVariations.map(async variation => {
|
|
118
|
-
|
|
119
|
-
variation.reserveQty -= oi.releaseQty
|
|
117
|
+
variation.reserveQty -= oi.releaseQty
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
}
|
|
119
|
+
await tx.getRepository(MarketplaceProductVariation).save(variation)
|
|
123
120
|
})
|
|
124
121
|
)
|
|
125
122
|
}
|
|
@@ -7,6 +7,7 @@ import * as DeliveryOrder from './delivery-order'
|
|
|
7
7
|
import * as GoodsReceivalNote from './goods-receival-note'
|
|
8
8
|
import * as InventoryCheck from './inventory-check'
|
|
9
9
|
import * as Invoice from './invoice'
|
|
10
|
+
import * as InvoiceProduct from './invoice-product'
|
|
10
11
|
import * as JobSheet from './job-sheet'
|
|
11
12
|
import * as Manifest from './manifest'
|
|
12
13
|
import * as OrderInventory from './order-inventory'
|
|
@@ -29,6 +30,7 @@ export const queries = [
|
|
|
29
30
|
RetailReplenishmentOrder.Query,
|
|
30
31
|
TransferOrder.Query,
|
|
31
32
|
Invoice.Query,
|
|
33
|
+
InvoiceProduct.Query,
|
|
32
34
|
InventoryCheck.Query,
|
|
33
35
|
JobSheet.Query,
|
|
34
36
|
PurchaseOrder.Query,
|
|
@@ -58,6 +60,7 @@ export const mutations = [
|
|
|
58
60
|
RetailReplenishmentOrder.Mutation,
|
|
59
61
|
TransferOrder.Mutation,
|
|
60
62
|
Invoice.Mutation,
|
|
63
|
+
InvoiceProduct.Mutation,
|
|
61
64
|
InventoryCheck.Mutation,
|
|
62
65
|
JobSheet.Mutation,
|
|
63
66
|
PurchaseOrder.Mutation,
|
|
@@ -86,6 +89,7 @@ export const types = [
|
|
|
86
89
|
...RetailReplenishmentOrder.Types,
|
|
87
90
|
...TransferOrder.Types,
|
|
88
91
|
...Invoice.Types,
|
|
92
|
+
...InvoiceProduct.Types,
|
|
89
93
|
...InventoryCheck.Types,
|
|
90
94
|
...JobSheet.Types,
|
|
91
95
|
...PurchaseOrder.Types,
|