@things-factory/sales-base 3.8.26 → 3.8.30
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 +2 -4
- 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 +2 -4
- 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
|
@@ -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
|
+
|
|
@@ -115,11 +115,9 @@ export async function confirmReleaseGood(name: string, context: any, tx?: Entity
|
|
|
115
115
|
if (foundMarketplaceProductVariations) {
|
|
116
116
|
await Promise.all(
|
|
117
117
|
foundMarketplaceProductVariations.map(async variation => {
|
|
118
|
-
|
|
119
|
-
variation.reserveQty -= oi.releaseQty
|
|
118
|
+
variation.reserveQty -= oi.releaseQty
|
|
120
119
|
|
|
121
|
-
|
|
122
|
-
}
|
|
120
|
+
await tx.getRepository(MarketplaceProductVariation).save(variation)
|
|
123
121
|
})
|
|
124
122
|
)
|
|
125
123
|
}
|
|
@@ -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,
|
|
@@ -3,12 +3,45 @@ import gql from 'graphql-tag'
|
|
|
3
3
|
export const InvoicePatch = gql`
|
|
4
4
|
input InvoicePatch {
|
|
5
5
|
name: String
|
|
6
|
-
|
|
6
|
+
refNo1: String
|
|
7
|
+
refNo2: String
|
|
8
|
+
refNo3: String
|
|
7
9
|
issuedOn: String
|
|
10
|
+
contactPointRefId: String
|
|
11
|
+
from: String
|
|
12
|
+
fromContactPhone: String
|
|
13
|
+
fromAddress1: String
|
|
14
|
+
fromAddress2: String
|
|
15
|
+
fromAddress3: String
|
|
16
|
+
fromAddress4: String
|
|
17
|
+
fromAddress5: String
|
|
18
|
+
fromPostcode: String
|
|
19
|
+
fromCity: String
|
|
20
|
+
fromState: String
|
|
21
|
+
fromCountry: String
|
|
22
|
+
deliverTo: String
|
|
23
|
+
deliverToPhone: String
|
|
24
|
+
deliveryAddress1: String
|
|
25
|
+
deliveryAddress2: String
|
|
26
|
+
deliveryAddress3: String
|
|
27
|
+
deliveryAddress4: String
|
|
28
|
+
deliveryAddress5: String
|
|
29
|
+
deliveryCity: String
|
|
30
|
+
deliveryState: String
|
|
31
|
+
deliveryCountry: String
|
|
32
|
+
billTo: String
|
|
33
|
+
billToPhone: String
|
|
34
|
+
billingAddress1: String
|
|
35
|
+
billingAddress2: String
|
|
36
|
+
billingAddress3: String
|
|
37
|
+
billingAddress4: String
|
|
38
|
+
billingAddress5: String
|
|
39
|
+
billingPostcode: String
|
|
40
|
+
billingCity: String
|
|
41
|
+
billingState: String
|
|
42
|
+
billingCountry: String
|
|
8
43
|
paymentDue: String
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
state: String
|
|
12
|
-
description: String
|
|
44
|
+
invoiceProducts: [ObjectRef]
|
|
45
|
+
releaseGood: ObjectRef
|
|
13
46
|
}
|
|
14
47
|
`
|
|
@@ -5,12 +5,46 @@ export const Invoice = gql`
|
|
|
5
5
|
id: String
|
|
6
6
|
domain: Domain
|
|
7
7
|
name: String
|
|
8
|
-
|
|
8
|
+
refNo1: String
|
|
9
|
+
refNo2: String
|
|
10
|
+
refNo3: String
|
|
9
11
|
issuedOn: String
|
|
12
|
+
contactPointRefId: String
|
|
13
|
+
from: String
|
|
14
|
+
fromContactPhone: String
|
|
15
|
+
fromAddress1: String
|
|
16
|
+
fromAddress2: String
|
|
17
|
+
fromAddress3: String
|
|
18
|
+
fromAddress4: String
|
|
19
|
+
fromAddress5: String
|
|
20
|
+
fromPostcode: String
|
|
21
|
+
fromCity: String
|
|
22
|
+
fromState: String
|
|
23
|
+
fromCountry: String
|
|
24
|
+
deliverTo: String
|
|
25
|
+
deliverToPhone: String
|
|
26
|
+
deliveryAddress1: String
|
|
27
|
+
deliveryAddress2: String
|
|
28
|
+
deliveryAddress3: String
|
|
29
|
+
deliveryAddress4: String
|
|
30
|
+
deliveryAddress5: String
|
|
31
|
+
deliveryCity: String
|
|
32
|
+
deliveryState: String
|
|
33
|
+
deliveryCountry: String
|
|
34
|
+
billTo: String
|
|
35
|
+
billToPhone: String
|
|
36
|
+
billingAddress1: String
|
|
37
|
+
billingAddress2: String
|
|
38
|
+
billingAddress3: String
|
|
39
|
+
billingAddress4: String
|
|
40
|
+
billingAddress5: String
|
|
41
|
+
billingPostcode: String
|
|
42
|
+
billingCity: String
|
|
43
|
+
billingState: String
|
|
44
|
+
billingCountry: String
|
|
10
45
|
paymentDue: String
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
state: String
|
|
46
|
+
invoiceProducts: [InvoiceProduct]
|
|
47
|
+
releaseGood: ReleaseGood
|
|
14
48
|
description: String
|
|
15
49
|
creator: User
|
|
16
50
|
updater: User
|