@things-factory/sales-base 8.0.0-beta.9 → 8.0.0
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/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/server/constants/attachment-type.ts +9 -0
- package/server/constants/index.ts +7 -0
- package/server/constants/load-type.ts +4 -0
- package/server/constants/order.ts +203 -0
- package/server/constants/product-group-type.ts +4 -0
- package/server/constants/release-good.ts +9 -0
- package/server/constants/transfer-order-type.ts +6 -0
- package/server/constants/validation-error-code.ts +3 -0
- package/server/constants/vas-target-type.ts +25 -0
- package/server/controllers/ecommerce/ecommerce-controller.ts +122 -0
- package/server/controllers/ecommerce/index.ts +2 -0
- package/server/controllers/ecommerce/sellercraft-controller.ts +182 -0
- package/server/controllers/index.ts +2 -0
- package/server/controllers/order-controller.ts +296 -0
- package/server/errors/index.ts +1 -0
- package/server/errors/validation-error.ts +25 -0
- package/server/index.ts +5 -0
- package/server/migrations/index.ts +9 -0
- package/server/service/arrival-notice/arrival-notice-mutation.ts +1152 -0
- package/server/service/arrival-notice/arrival-notice-query.ts +549 -0
- package/server/service/arrival-notice/arrival-notice-types.ts +310 -0
- package/server/service/arrival-notice/arrival-notice.ts +202 -0
- package/server/service/arrival-notice/index.ts +9 -0
- package/server/service/claim/claim-mutation.ts +308 -0
- package/server/service/claim/claim-query.ts +122 -0
- package/server/service/claim/claim-types.ts +130 -0
- package/server/service/claim/claim.ts +140 -0
- package/server/service/claim/index.ts +9 -0
- package/server/service/claim-detail/claim-detail-mutation.ts +102 -0
- package/server/service/claim-detail/claim-detail-query.ts +55 -0
- package/server/service/claim-detail/claim-detail-types.ts +47 -0
- package/server/service/claim-detail/claim-detail.ts +69 -0
- package/server/service/claim-detail/index.ts +9 -0
- package/server/service/claim-order/claim-order-mutation.ts +101 -0
- package/server/service/claim-order/claim-order-query.ts +47 -0
- package/server/service/claim-order/claim-order-types.ts +35 -0
- package/server/service/claim-order/claim-order.ts +81 -0
- package/server/service/claim-order/index.ts +9 -0
- package/server/service/collection-order/collection-order-mutation.ts +245 -0
- package/server/service/collection-order/collection-order-query.ts +97 -0
- package/server/service/collection-order/collection-order-types.ts +165 -0
- package/server/service/collection-order/collection-order.ts +135 -0
- package/server/service/collection-order/index.ts +9 -0
- package/server/service/delivery-order/delivery-order-mutation.ts +967 -0
- package/server/service/delivery-order/delivery-order-query.ts +631 -0
- package/server/service/delivery-order/delivery-order-types.ts +268 -0
- package/server/service/delivery-order/delivery-order.ts +258 -0
- package/server/service/delivery-order/index.ts +9 -0
- package/server/service/draft-release-good/draft-release-good-mutation.ts +765 -0
- package/server/service/draft-release-good/draft-release-good-query.ts +354 -0
- package/server/service/draft-release-good/draft-release-good-type.ts +261 -0
- package/server/service/draft-release-good/draft-release-good.ts +284 -0
- package/server/service/draft-release-good/index.ts +9 -0
- package/server/service/goods-receival-note/goods-receival-note-mutation.ts +129 -0
- package/server/service/goods-receival-note/goods-receival-note-query.ts +280 -0
- package/server/service/goods-receival-note/goods-receival-note-types.ts +105 -0
- package/server/service/goods-receival-note/goods-receival-note.ts +127 -0
- package/server/service/goods-receival-note/index.ts +9 -0
- package/server/service/index.ts +238 -0
- package/server/service/inventory-check/index.ts +9 -0
- package/server/service/inventory-check/inventory-check-mutation.ts +149 -0
- package/server/service/inventory-check/inventory-check-query.ts +48 -0
- package/server/service/inventory-check/inventory-check-types.ts +48 -0
- package/server/service/inventory-check/inventory-check.ts +90 -0
- package/server/service/invoice/index.ts +9 -0
- package/server/service/invoice/invoice-mutation.ts +95 -0
- package/server/service/invoice/invoice-query.ts +53 -0
- package/server/service/invoice/invoice-types.ts +279 -0
- package/server/service/invoice/invoice.ts +230 -0
- package/server/service/invoice-product/index.ts +9 -0
- package/server/service/invoice-product/invoice-product-mutation.ts +54 -0
- package/server/service/invoice-product/invoice-product-query.ts +54 -0
- package/server/service/invoice-product/invoice-product-types.ts +84 -0
- package/server/service/invoice-product/invoice-product.ts +92 -0
- package/server/service/job-sheet/index.ts +9 -0
- package/server/service/job-sheet/job-sheet-mutation.ts +92 -0
- package/server/service/job-sheet/job-sheet-query.ts +112 -0
- package/server/service/job-sheet/job-sheet-types.ts +78 -0
- package/server/service/job-sheet/job-sheet.ts +102 -0
- package/server/service/manifest/index.ts +6 -0
- package/server/service/manifest/manifest-mutation.ts +190 -0
- package/server/service/manifest/manifest-query.ts +149 -0
- package/server/service/manifest/manifest-type.ts +84 -0
- package/server/service/manifest/manifest.ts +114 -0
- package/server/service/order-inventory/index.ts +9 -0
- package/server/service/order-inventory/order-inventory-mutation.ts +54 -0
- package/server/service/order-inventory/order-inventory-query.ts +722 -0
- package/server/service/order-inventory/order-inventory-types.ts +238 -0
- package/server/service/order-inventory/order-inventory.ts +401 -0
- package/server/service/order-product/index.ts +9 -0
- package/server/service/order-product/order-product-mutation.ts +48 -0
- package/server/service/order-product/order-product-query.ts +89 -0
- package/server/service/order-product/order-product-types.ts +335 -0
- package/server/service/order-product/order-product.ts +362 -0
- package/server/service/order-tote/index.ts +9 -0
- package/server/service/order-tote/order-tote-mutation.ts +31 -0
- package/server/service/order-tote/order-tote-query.ts +112 -0
- package/server/service/order-tote/order-tote-types.ts +47 -0
- package/server/service/order-tote/order-tote.ts +73 -0
- package/server/service/order-tote-item/index.ts +9 -0
- package/server/service/order-tote-item/order-tote-item-mutation.ts +31 -0
- package/server/service/order-tote-item/order-tote-item-query.ts +82 -0
- package/server/service/order-tote-item/order-tote-item-types.ts +56 -0
- package/server/service/order-tote-item/order-tote-item.ts +72 -0
- package/server/service/order-tote-seal/index.ts +9 -0
- package/server/service/order-tote-seal/order-tote-seal-mutation.ts +31 -0
- package/server/service/order-tote-seal/order-tote-seal-query.ts +59 -0
- package/server/service/order-tote-seal/order-tote-seal-types.ts +41 -0
- package/server/service/order-tote-seal/order-tote-seal.ts +46 -0
- package/server/service/order-vas/index.ts +9 -0
- package/server/service/order-vas/order-vas-mutation.ts +20 -0
- package/server/service/order-vas/order-vas-query.ts +72 -0
- package/server/service/order-vas/order-vas-types.ts +159 -0
- package/server/service/order-vas/order-vas.ts +207 -0
- package/server/service/others/index.ts +5 -0
- package/server/service/others/other-query.ts +563 -0
- package/server/service/others/other-types.ts +115 -0
- package/server/service/purchase-order/index.ts +9 -0
- package/server/service/purchase-order/purchase-order-mutation.ts +458 -0
- package/server/service/purchase-order/purchase-order-query.ts +90 -0
- package/server/service/purchase-order/purchase-order-types.ts +154 -0
- package/server/service/purchase-order/purchase-order.ts +172 -0
- package/server/service/purchase-order-other-charge/index.ts +9 -0
- package/server/service/purchase-order-other-charge/purchase-order-other-charge-mutation.ts +31 -0
- package/server/service/purchase-order-other-charge/purchase-order-other-charge-query.ts +52 -0
- package/server/service/purchase-order-other-charge/purchase-order-other-charge-types.ts +44 -0
- package/server/service/purchase-order-other-charge/purchase-order-other-charge.ts +68 -0
- package/server/service/release-good/index.ts +9 -0
- package/server/service/release-good/release-good-mutation.ts +1686 -0
- package/server/service/release-good/release-good-query.ts +980 -0
- package/server/service/release-good/release-good-types.ts +662 -0
- package/server/service/release-good/release-good.ts +490 -0
- package/server/service/retail-replenishment-order/index.ts +9 -0
- package/server/service/retail-replenishment-order/retail-replenishment-order-mutation.ts +382 -0
- package/server/service/retail-replenishment-order/retail-replenishment-order-query.ts +54 -0
- package/server/service/retail-replenishment-order/retail-replenishment-order-types.ts +101 -0
- package/server/service/retail-replenishment-order/retail-replenishment-order.ts +115 -0
- package/server/service/return-order/index.ts +9 -0
- package/server/service/return-order/return-order-mutation.ts +516 -0
- package/server/service/return-order/return-order-query.ts +226 -0
- package/server/service/return-order/return-order-types.ts +196 -0
- package/server/service/return-order/return-order.ts +127 -0
- package/server/service/reverse-kitting-order/index.ts +9 -0
- package/server/service/reverse-kitting-order/reverse-kitting-order-mutation.ts +500 -0
- package/server/service/reverse-kitting-order/reverse-kitting-order-query.ts +197 -0
- package/server/service/reverse-kitting-order/reverse-kitting-order-type.ts +173 -0
- package/server/service/reverse-kitting-order/reverse-kitting-order.ts +121 -0
- package/server/service/reverse-kitting-order-inventory/index.ts +9 -0
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.ts +129 -0
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-query.ts +52 -0
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-type.ts +95 -0
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +143 -0
- package/server/service/shipping-order/index.ts +9 -0
- package/server/service/shipping-order/shipping-order-mutation.ts +61 -0
- package/server/service/shipping-order/shipping-order-query.ts +61 -0
- package/server/service/shipping-order/shipping-order-types.ts +89 -0
- package/server/service/shipping-order/shipping-order.ts +129 -0
- package/server/service/transfer-order/index.ts +9 -0
- package/server/service/transfer-order/transfer-order-mutation.ts +309 -0
- package/server/service/transfer-order/transfer-order-query.ts +66 -0
- package/server/service/transfer-order/transfer-order-types.ts +97 -0
- package/server/service/transfer-order/transfer-order.ts +117 -0
- package/server/service/vas/index.ts +9 -0
- package/server/service/vas/vas-mutation.ts +106 -0
- package/server/service/vas/vas-query.ts +60 -0
- package/server/service/vas/vas-types.ts +71 -0
- package/server/service/vas/vas.ts +77 -0
- package/server/service/vas-order/index.ts +9 -0
- package/server/service/vas-order/vas-order-mutation.ts +259 -0
- package/server/service/vas-order/vas-order-query.ts +119 -0
- package/server/service/vas-order/vas-order-types.ts +49 -0
- package/server/service/vas-order/vas-order.ts +81 -0
- package/server/utils/datetime-util.ts +54 -0
- package/server/utils/index.ts +3 -0
- package/server/utils/inventory-util.ts +1155 -0
- package/server/utils/order-no-generator.ts +146 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Field, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
|
+
import { NewOrderInventory } from '../order-inventory/order-inventory-types'
|
|
3
|
+
import { InventoryCheck } from './inventory-check'
|
|
4
|
+
|
|
5
|
+
@ObjectType()
|
|
6
|
+
export class InventoryCheckList {
|
|
7
|
+
@Field(type => [InventoryCheck], { nullable: true })
|
|
8
|
+
items: InventoryCheck[]
|
|
9
|
+
|
|
10
|
+
@Field(type => Int, { nullable: true })
|
|
11
|
+
total: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@InputType()
|
|
15
|
+
export class NewInventoryCheck {
|
|
16
|
+
@Field()
|
|
17
|
+
name: string
|
|
18
|
+
|
|
19
|
+
@Field({ nullable: true })
|
|
20
|
+
description: string
|
|
21
|
+
|
|
22
|
+
@Field({ nullable: true })
|
|
23
|
+
status: string
|
|
24
|
+
|
|
25
|
+
@Field({ nullable: true })
|
|
26
|
+
executionDate: string
|
|
27
|
+
|
|
28
|
+
@Field(type => NewOrderInventory, { nullable: true })
|
|
29
|
+
orderInventories: NewOrderInventory[]
|
|
30
|
+
|
|
31
|
+
@Field({ nullable: true })
|
|
32
|
+
type: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@InputType()
|
|
36
|
+
export class InventoryCheckPatch {
|
|
37
|
+
@Field({ nullable: true })
|
|
38
|
+
id: string
|
|
39
|
+
|
|
40
|
+
@Field({ nullable: true })
|
|
41
|
+
name: string
|
|
42
|
+
|
|
43
|
+
@Field({ nullable: true })
|
|
44
|
+
description: string
|
|
45
|
+
|
|
46
|
+
@Field({ nullable: true })
|
|
47
|
+
cuFlag: string
|
|
48
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { User } from '@things-factory/auth-base'
|
|
2
|
+
import { Bizplace } from '@things-factory/biz-base'
|
|
3
|
+
import { Domain } from '@things-factory/shell'
|
|
4
|
+
import { Field, ID, ObjectType } from 'type-graphql'
|
|
5
|
+
import {
|
|
6
|
+
Column,
|
|
7
|
+
CreateDateColumn,
|
|
8
|
+
Entity,
|
|
9
|
+
Index,
|
|
10
|
+
ManyToOne,
|
|
11
|
+
OneToMany,
|
|
12
|
+
PrimaryGeneratedColumn,
|
|
13
|
+
RelationId,
|
|
14
|
+
UpdateDateColumn
|
|
15
|
+
} from 'typeorm'
|
|
16
|
+
import { OrderInventory } from '../'
|
|
17
|
+
|
|
18
|
+
@Entity()
|
|
19
|
+
@Index('ix_inventory-check_0', (inventoryCheck: InventoryCheck) => [inventoryCheck.domain, inventoryCheck.name], {
|
|
20
|
+
unique: true
|
|
21
|
+
})
|
|
22
|
+
@ObjectType()
|
|
23
|
+
export class InventoryCheck {
|
|
24
|
+
@PrimaryGeneratedColumn('uuid')
|
|
25
|
+
@Field(type => ID)
|
|
26
|
+
readonly id: string
|
|
27
|
+
|
|
28
|
+
@ManyToOne(type => Domain)
|
|
29
|
+
@Field(type => Domain, { nullable: true })
|
|
30
|
+
domain: Domain
|
|
31
|
+
|
|
32
|
+
@RelationId((inventoryCheck: InventoryCheck) => inventoryCheck.domain)
|
|
33
|
+
domainId: string
|
|
34
|
+
|
|
35
|
+
@ManyToOne(type => Bizplace)
|
|
36
|
+
@Field(type => Bizplace, { nullable: true })
|
|
37
|
+
bizplace: Bizplace
|
|
38
|
+
|
|
39
|
+
@RelationId((inventoryCheck: InventoryCheck) => inventoryCheck.bizplace)
|
|
40
|
+
bizplaceId: string
|
|
41
|
+
|
|
42
|
+
@Column()
|
|
43
|
+
@Field()
|
|
44
|
+
name: string
|
|
45
|
+
|
|
46
|
+
@Column({ nullable: true })
|
|
47
|
+
@Field({ nullable: true })
|
|
48
|
+
description: string
|
|
49
|
+
|
|
50
|
+
@Column({ nullable: true })
|
|
51
|
+
@Field({ nullable: true })
|
|
52
|
+
executionDate: string
|
|
53
|
+
|
|
54
|
+
@Column()
|
|
55
|
+
@Field()
|
|
56
|
+
type: string
|
|
57
|
+
|
|
58
|
+
@Column()
|
|
59
|
+
@Field()
|
|
60
|
+
status: string
|
|
61
|
+
|
|
62
|
+
@OneToMany(type => OrderInventory, orderInventory => orderInventory.inventoryCheck)
|
|
63
|
+
@Field(type => OrderInventory, { nullable: true })
|
|
64
|
+
orderInventories: OrderInventory[]
|
|
65
|
+
|
|
66
|
+
@CreateDateColumn()
|
|
67
|
+
@Field()
|
|
68
|
+
createdAt: Date
|
|
69
|
+
|
|
70
|
+
@UpdateDateColumn()
|
|
71
|
+
@Field()
|
|
72
|
+
updatedAt: Date
|
|
73
|
+
|
|
74
|
+
@ManyToOne(type => User)
|
|
75
|
+
@Field(type => User, { nullable: true })
|
|
76
|
+
creator: User
|
|
77
|
+
|
|
78
|
+
@RelationId((inventoryCheck: InventoryCheck) => inventoryCheck.creator)
|
|
79
|
+
creatorId: string
|
|
80
|
+
|
|
81
|
+
@ManyToOne(type => User)
|
|
82
|
+
@Field(type => User, { nullable: true })
|
|
83
|
+
updater: User
|
|
84
|
+
|
|
85
|
+
@RelationId((inventoryCheck: InventoryCheck) => inventoryCheck.updater)
|
|
86
|
+
updaterId: string
|
|
87
|
+
|
|
88
|
+
@Field({ nullable: true })
|
|
89
|
+
cuFlag: string
|
|
90
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Invoice } from './invoice'
|
|
2
|
+
import { InvoiceMutation } from './invoice-mutation'
|
|
3
|
+
import { InvoiceQuery } from './invoice-query'
|
|
4
|
+
|
|
5
|
+
export const entities = [Invoice]
|
|
6
|
+
export const resolvers = [InvoiceQuery, InvoiceMutation]
|
|
7
|
+
|
|
8
|
+
export * from './invoice-mutation'
|
|
9
|
+
export * from './invoice-query'
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
+
import { EntityManager, Repository } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { Domain, getRepository } from '@things-factory/shell'
|
|
6
|
+
|
|
7
|
+
import { InvoicePatch, NewInvoice } from '../'
|
|
8
|
+
import { OrderNoGenerator } from '../../utils'
|
|
9
|
+
import { InvoiceProduct } from '../invoice-product/invoice-product'
|
|
10
|
+
import { Invoice } from './invoice'
|
|
11
|
+
|
|
12
|
+
@Resolver(Invoice)
|
|
13
|
+
export class InvoiceMutation {
|
|
14
|
+
@Mutation(returns => Invoice)
|
|
15
|
+
@Directive('@transaction')
|
|
16
|
+
async createInvoice(
|
|
17
|
+
@Arg('invoice', type => NewInvoice) invoice: NewInvoice,
|
|
18
|
+
@Ctx() context: ResolverContext
|
|
19
|
+
): Promise<Invoice> {
|
|
20
|
+
const { tx, domain, user } = context.state
|
|
21
|
+
let invoiceProducts: any[] = invoice.invoiceProducts
|
|
22
|
+
|
|
23
|
+
let createdInvoice: Invoice = await tx.getRepository(Invoice).save({
|
|
24
|
+
...invoice,
|
|
25
|
+
domain,
|
|
26
|
+
name: OrderNoGenerator.invoice(),
|
|
27
|
+
// releaseGood: await tx.getRepository(ReleaseGood).findOneBy({ id: invoice?.releaseGood.id }),
|
|
28
|
+
creator: user
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
await addInvoiceProducts(domain, createdInvoice, invoiceProducts, user, tx)
|
|
32
|
+
|
|
33
|
+
createdInvoice = await tx.getRepository(Invoice).findOne({
|
|
34
|
+
where: { domain: { id: domain.id }, id: createdInvoice.id },
|
|
35
|
+
relations: ['invoiceProducts']
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return createdInvoice
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Mutation(returns => Invoice)
|
|
42
|
+
@Directive('@transaction')
|
|
43
|
+
async updateInvoice(
|
|
44
|
+
@Arg('name') name: string,
|
|
45
|
+
@Arg('patch', type => InvoicePatch) patch: InvoicePatch,
|
|
46
|
+
@Ctx() context: ResolverContext
|
|
47
|
+
): Promise<Invoice> {
|
|
48
|
+
const { tx, domain, user } = context.state
|
|
49
|
+
|
|
50
|
+
const repository = tx.getRepository(Invoice)
|
|
51
|
+
const invoice = await repository.findOne({
|
|
52
|
+
where: { domain: { id: domain.id }, name }
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
return await repository.save({
|
|
56
|
+
...invoice,
|
|
57
|
+
...patch,
|
|
58
|
+
updater: user
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Mutation(returns => Boolean)
|
|
63
|
+
@Directive('@transaction')
|
|
64
|
+
async deleteInvoice(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
65
|
+
const { tx, domain } = context.state
|
|
66
|
+
|
|
67
|
+
await tx.getRepository(Invoice).delete({ domain: { id: domain.id }, name })
|
|
68
|
+
return true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function addInvoiceProducts(
|
|
73
|
+
domain: Domain,
|
|
74
|
+
invoice: Invoice,
|
|
75
|
+
invoiceProducts: any[],
|
|
76
|
+
user: User,
|
|
77
|
+
tx?: EntityManager
|
|
78
|
+
): Promise<void> {
|
|
79
|
+
const invoiceProductRepo: Repository<InvoiceProduct> =
|
|
80
|
+
tx?.getRepository(InvoiceProduct) || getRepository(InvoiceProduct)
|
|
81
|
+
|
|
82
|
+
const createdInvoiceProducts: InvoiceProduct[] = await Promise.all(
|
|
83
|
+
invoiceProducts.map(async (invoiceProduct: InvoiceProduct) => {
|
|
84
|
+
return {
|
|
85
|
+
name: OrderNoGenerator.invoiceProduct(),
|
|
86
|
+
...invoiceProduct,
|
|
87
|
+
domain,
|
|
88
|
+
invoice,
|
|
89
|
+
creator: user
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
await invoiceProductRepo.save(createdInvoiceProducts)
|
|
95
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Arg, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
+
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { buildQuery, Domain, Filter, getRepository, Pagination, Sorting } from '@things-factory/shell'
|
|
5
|
+
|
|
6
|
+
import { Invoice } from './invoice'
|
|
7
|
+
import { InvoiceList } from './invoice-types'
|
|
8
|
+
|
|
9
|
+
@Resolver(Invoice)
|
|
10
|
+
export class InvoiceQuery {
|
|
11
|
+
@Query(returns => InvoiceList)
|
|
12
|
+
async invoices(
|
|
13
|
+
@Ctx() context: ResolverContext,
|
|
14
|
+
@Arg('filters', type => [Filter], { nullable: true }) filters?: Filter[],
|
|
15
|
+
@Arg('pagination', type => Pagination, { nullable: true }) pagination?: Pagination,
|
|
16
|
+
@Arg('sortings', type => [Sorting], { nullable: true }) sortings?: Sorting[]
|
|
17
|
+
): Promise<InvoiceList> {
|
|
18
|
+
const queryBuilder = getRepository(Invoice).createQueryBuilder()
|
|
19
|
+
buildQuery(queryBuilder, { filters, pagination, sortings }, context)
|
|
20
|
+
const [items, total] = await queryBuilder
|
|
21
|
+
.leftJoinAndSelect('Invoice.domain', 'Domain')
|
|
22
|
+
.leftJoinAndSelect('Invoice.creator', 'Creator')
|
|
23
|
+
.leftJoinAndSelect('Invoice.updater', 'Updater')
|
|
24
|
+
.getManyAndCount()
|
|
25
|
+
|
|
26
|
+
return { items, total }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Query(returns => Invoice)
|
|
30
|
+
async invoice(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Invoice> {
|
|
31
|
+
const { domain } = context.state
|
|
32
|
+
|
|
33
|
+
return await getRepository(Invoice).findOne({
|
|
34
|
+
where: { domain: { id: domain.id }, name },
|
|
35
|
+
relations: ['domain', 'creator', 'updater']
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@FieldResolver(type => Domain)
|
|
40
|
+
async domain(@Root() invoice: Invoice): Promise<Domain> {
|
|
41
|
+
return await getRepository(Domain).findOneBy({ id: invoice.domainId })
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@FieldResolver(type => User)
|
|
45
|
+
async creator(@Root() invoice: Invoice): Promise<User> {
|
|
46
|
+
return await getRepository(User).findOneBy({ id: invoice.creatorId })
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@FieldResolver(type => User)
|
|
50
|
+
async updater(@Root() invoice: Invoice): Promise<User> {
|
|
51
|
+
return await getRepository(User).findOneBy({ id: invoice.updaterId })
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { Field, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
|
+
|
|
3
|
+
import { ObjectRef } from '@things-factory/shell'
|
|
4
|
+
|
|
5
|
+
import { InvoiceProductPatch, NewInvoiceProduct } from '../invoice-product/invoice-product-types'
|
|
6
|
+
import { Invoice } from './invoice'
|
|
7
|
+
|
|
8
|
+
@ObjectType()
|
|
9
|
+
export class InvoiceList {
|
|
10
|
+
@Field(type => [Invoice], { nullable: true })
|
|
11
|
+
items: Invoice[]
|
|
12
|
+
|
|
13
|
+
@Field(type => Int, { nullable: true })
|
|
14
|
+
total: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@InputType()
|
|
18
|
+
export class NewInvoice {
|
|
19
|
+
@Field()
|
|
20
|
+
name: string
|
|
21
|
+
|
|
22
|
+
@Field({ nullable: true })
|
|
23
|
+
refNo1: string
|
|
24
|
+
|
|
25
|
+
@Field({ nullable: true })
|
|
26
|
+
refNo2: string
|
|
27
|
+
|
|
28
|
+
@Field({ nullable: true })
|
|
29
|
+
refNo3: string
|
|
30
|
+
|
|
31
|
+
@Field({ nullable: true })
|
|
32
|
+
issuedOn: string
|
|
33
|
+
|
|
34
|
+
@Field({ nullable: true })
|
|
35
|
+
contactPointRefId: string
|
|
36
|
+
|
|
37
|
+
@Field()
|
|
38
|
+
from: string
|
|
39
|
+
|
|
40
|
+
@Field()
|
|
41
|
+
fromContactPhone: string
|
|
42
|
+
|
|
43
|
+
@Field({ nullable: true })
|
|
44
|
+
fromAddress1: string
|
|
45
|
+
|
|
46
|
+
@Field({ nullable: true })
|
|
47
|
+
fromAddress2: string
|
|
48
|
+
|
|
49
|
+
@Field({ nullable: true })
|
|
50
|
+
fromAddress3: string
|
|
51
|
+
|
|
52
|
+
@Field({ nullable: true })
|
|
53
|
+
fromAddress4: string
|
|
54
|
+
|
|
55
|
+
@Field({ nullable: true })
|
|
56
|
+
fromAddress5: string
|
|
57
|
+
|
|
58
|
+
@Field({ nullable: true })
|
|
59
|
+
fromPostcode: string
|
|
60
|
+
|
|
61
|
+
@Field({ nullable: true })
|
|
62
|
+
fromCity: string
|
|
63
|
+
|
|
64
|
+
@Field({ nullable: true })
|
|
65
|
+
fromState: string
|
|
66
|
+
|
|
67
|
+
@Field({ nullable: true })
|
|
68
|
+
fromCountry: string
|
|
69
|
+
|
|
70
|
+
@Field()
|
|
71
|
+
deliverTo: string
|
|
72
|
+
|
|
73
|
+
@Field()
|
|
74
|
+
deliverToPhone: string
|
|
75
|
+
|
|
76
|
+
@Field()
|
|
77
|
+
deliveryAddress1: string
|
|
78
|
+
|
|
79
|
+
@Field({ nullable: true })
|
|
80
|
+
deliveryAddress2: string
|
|
81
|
+
|
|
82
|
+
@Field({ nullable: true })
|
|
83
|
+
deliveryAddress3: string
|
|
84
|
+
|
|
85
|
+
@Field({ nullable: true })
|
|
86
|
+
deliveryAddress4: string
|
|
87
|
+
|
|
88
|
+
@Field({ nullable: true })
|
|
89
|
+
deliveryAddress5: string
|
|
90
|
+
|
|
91
|
+
@Field()
|
|
92
|
+
deliveryCity: string
|
|
93
|
+
|
|
94
|
+
@Field()
|
|
95
|
+
deliveryState: string
|
|
96
|
+
|
|
97
|
+
@Field()
|
|
98
|
+
deliveryCountry: string
|
|
99
|
+
|
|
100
|
+
@Field()
|
|
101
|
+
deliveryPostcode: string
|
|
102
|
+
|
|
103
|
+
@Field()
|
|
104
|
+
billTo: string
|
|
105
|
+
|
|
106
|
+
@Field()
|
|
107
|
+
billToPhone: string
|
|
108
|
+
|
|
109
|
+
@Field()
|
|
110
|
+
billingAddress1: string
|
|
111
|
+
|
|
112
|
+
@Field({ nullable: true })
|
|
113
|
+
billingAddress2: string
|
|
114
|
+
|
|
115
|
+
@Field({ nullable: true })
|
|
116
|
+
billingAddress3: string
|
|
117
|
+
|
|
118
|
+
@Field({ nullable: true })
|
|
119
|
+
billingAddress4: string
|
|
120
|
+
|
|
121
|
+
@Field({ nullable: true })
|
|
122
|
+
billingAddress5: string
|
|
123
|
+
|
|
124
|
+
@Field()
|
|
125
|
+
billingPostcode: string
|
|
126
|
+
|
|
127
|
+
@Field()
|
|
128
|
+
billingCity: string
|
|
129
|
+
|
|
130
|
+
@Field()
|
|
131
|
+
billingState: string
|
|
132
|
+
|
|
133
|
+
@Field()
|
|
134
|
+
billingCountry: string
|
|
135
|
+
|
|
136
|
+
@Field({ nullable: true })
|
|
137
|
+
paymentDue: string
|
|
138
|
+
|
|
139
|
+
@Field({ nullable: true })
|
|
140
|
+
description: string
|
|
141
|
+
|
|
142
|
+
@Field(type => [NewInvoiceProduct], { nullable: true })
|
|
143
|
+
invoiceProducts: NewInvoiceProduct[]
|
|
144
|
+
|
|
145
|
+
@Field(type => ObjectRef, { nullable: true })
|
|
146
|
+
releaseGood: ObjectRef
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@InputType()
|
|
150
|
+
export class InvoicePatch {
|
|
151
|
+
@Field({ nullable: true })
|
|
152
|
+
name: string
|
|
153
|
+
|
|
154
|
+
@Field({ nullable: true })
|
|
155
|
+
refNo1: string
|
|
156
|
+
|
|
157
|
+
@Field({ nullable: true })
|
|
158
|
+
refNo2: string
|
|
159
|
+
|
|
160
|
+
@Field({ nullable: true })
|
|
161
|
+
refNo3: string
|
|
162
|
+
|
|
163
|
+
@Field({ nullable: true })
|
|
164
|
+
issuedOn: string
|
|
165
|
+
|
|
166
|
+
@Field({ nullable: true })
|
|
167
|
+
contactPointRefId: string
|
|
168
|
+
|
|
169
|
+
@Field()
|
|
170
|
+
from: string
|
|
171
|
+
|
|
172
|
+
@Field()
|
|
173
|
+
fromContactPhone: string
|
|
174
|
+
|
|
175
|
+
@Field({ nullable: true })
|
|
176
|
+
fromAddress1: string
|
|
177
|
+
|
|
178
|
+
@Field({ nullable: true })
|
|
179
|
+
fromAddress2: string
|
|
180
|
+
|
|
181
|
+
@Field({ nullable: true })
|
|
182
|
+
fromAddress3: string
|
|
183
|
+
|
|
184
|
+
@Field({ nullable: true })
|
|
185
|
+
fromAddress4: string
|
|
186
|
+
|
|
187
|
+
@Field({ nullable: true })
|
|
188
|
+
fromAddress5: string
|
|
189
|
+
|
|
190
|
+
@Field({ nullable: true })
|
|
191
|
+
fromPostcode: string
|
|
192
|
+
|
|
193
|
+
@Field({ nullable: true })
|
|
194
|
+
fromCity: string
|
|
195
|
+
|
|
196
|
+
@Field({ nullable: true })
|
|
197
|
+
fromState: string
|
|
198
|
+
|
|
199
|
+
@Field({ nullable: true })
|
|
200
|
+
fromCountry: string
|
|
201
|
+
|
|
202
|
+
@Field()
|
|
203
|
+
deliverTo: string
|
|
204
|
+
|
|
205
|
+
@Field()
|
|
206
|
+
deliverToPhone: string
|
|
207
|
+
|
|
208
|
+
@Field()
|
|
209
|
+
deliveryAddress1: string
|
|
210
|
+
|
|
211
|
+
@Field({ nullable: true })
|
|
212
|
+
deliveryAddress2: string
|
|
213
|
+
|
|
214
|
+
@Field({ nullable: true })
|
|
215
|
+
deliveryAddress3: string
|
|
216
|
+
|
|
217
|
+
@Field({ nullable: true })
|
|
218
|
+
deliveryAddress4: string
|
|
219
|
+
|
|
220
|
+
@Field({ nullable: true })
|
|
221
|
+
deliveryAddress5: string
|
|
222
|
+
|
|
223
|
+
@Field()
|
|
224
|
+
deliveryCity: string
|
|
225
|
+
|
|
226
|
+
@Field()
|
|
227
|
+
deliveryState: string
|
|
228
|
+
|
|
229
|
+
@Field()
|
|
230
|
+
deliveryCountry: string
|
|
231
|
+
|
|
232
|
+
@Field()
|
|
233
|
+
deliveryPostcode: string
|
|
234
|
+
|
|
235
|
+
@Field()
|
|
236
|
+
billTo: string
|
|
237
|
+
|
|
238
|
+
@Field()
|
|
239
|
+
billToPhone: string
|
|
240
|
+
|
|
241
|
+
@Field()
|
|
242
|
+
billingAddress1: string
|
|
243
|
+
|
|
244
|
+
@Field({ nullable: true })
|
|
245
|
+
billingAddress2: string
|
|
246
|
+
|
|
247
|
+
@Field({ nullable: true })
|
|
248
|
+
billingAddress3: string
|
|
249
|
+
|
|
250
|
+
@Field({ nullable: true })
|
|
251
|
+
billingAddress4: string
|
|
252
|
+
|
|
253
|
+
@Field({ nullable: true })
|
|
254
|
+
billingAddress5: string
|
|
255
|
+
|
|
256
|
+
@Field()
|
|
257
|
+
billingPostcode: string
|
|
258
|
+
|
|
259
|
+
@Field()
|
|
260
|
+
billingCity: string
|
|
261
|
+
|
|
262
|
+
@Field()
|
|
263
|
+
billingState: string
|
|
264
|
+
|
|
265
|
+
@Field()
|
|
266
|
+
billingCountry: string
|
|
267
|
+
|
|
268
|
+
@Field({ nullable: true })
|
|
269
|
+
paymentDue: string
|
|
270
|
+
|
|
271
|
+
@Field({ nullable: true })
|
|
272
|
+
description: string
|
|
273
|
+
|
|
274
|
+
@Field(type => [InvoiceProductPatch], { nullable: true })
|
|
275
|
+
invoiceProducts: InvoiceProductPatch[]
|
|
276
|
+
|
|
277
|
+
@Field(type => ObjectRef, { nullable: true })
|
|
278
|
+
releaseGood: ObjectRef
|
|
279
|
+
}
|