@things-factory/operato-hub 4.3.576 → 4.3.577
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/controllers/company-initializer/settings.js +2 -1
- package/dist-server/controllers/company-initializer/settings.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/utils/params.js +62 -0
- package/dist-server/routers/api/restful-apis/v1/utils/params.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-sales-invoice.js +59 -0
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-sales-invoice.js.map +1 -0
- package/dist-server/routers/api/restful-apis/v1/warehouse/index.js +1 -0
- package/dist-server/routers/api/restful-apis/v1/warehouse/index.js.map +1 -1
- package/openapi/v1/outbound.yaml +1242 -920
- package/package.json +4 -4
- package/server/controllers/company-initializer/settings.ts +2 -1
- package/server/routers/api/restful-apis/v1/utils/params.ts +62 -0
- package/server/routers/api/restful-apis/v1/warehouse/add-sales-invoice.ts +93 -0
- package/server/routers/api/restful-apis/v1/warehouse/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-hub",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.577",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@things-factory/pdf": "^4.3.534",
|
|
93
93
|
"@things-factory/product-ui": "^4.3.563",
|
|
94
94
|
"@things-factory/resource-ui": "^4.3.563",
|
|
95
|
-
"@things-factory/sales-base": "^4.3.
|
|
95
|
+
"@things-factory/sales-base": "^4.3.577",
|
|
96
96
|
"@things-factory/scene-data-transform": "^4.3.534",
|
|
97
97
|
"@things-factory/scene-excel": "^4.3.534",
|
|
98
98
|
"@things-factory/scene-firebase": "^4.3.534",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"@things-factory/system-ui": "^4.3.535",
|
|
110
110
|
"@things-factory/transport-base": "^4.3.563",
|
|
111
111
|
"@things-factory/warehouse-base": "^4.3.567",
|
|
112
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
112
|
+
"@things-factory/worksheet-base": "^4.3.577",
|
|
113
113
|
"cron-parser": "^4.7.0",
|
|
114
114
|
"koa2-swagger-ui": "^5.0.2",
|
|
115
115
|
"swagger-jsdoc": "^5.0.0",
|
|
@@ -122,5 +122,5 @@
|
|
|
122
122
|
"resolutions": {
|
|
123
123
|
"core-js": "^3.16.0"
|
|
124
124
|
},
|
|
125
|
-
"gitHead": "
|
|
125
|
+
"gitHead": "e98c76f52f07989c011d10335d9c4a99485b61a5"
|
|
126
126
|
}
|
|
@@ -16,7 +16,8 @@ const settings = [
|
|
|
16
16
|
{ name: 'enable-custom-clearance-transportation', description: 'custom clearance transport', category: 'id-rule' },
|
|
17
17
|
{ name: 'enable-transportation-service', description: 'warehouse transport', category: 'id-rule' },
|
|
18
18
|
{ name: 'hide-cross-dock', description: 'hide cross docking button', category: 'id-rule' },
|
|
19
|
-
{ name: 'disable-reusable-pallet', description: 'hide and disable reusable pallet text field', category: 'id-rule' }
|
|
19
|
+
{ name: 'disable-reusable-pallet', description: 'hide and disable reusable pallet text field', category: 'id-rule' },
|
|
20
|
+
{ name: 'enable-lot-id-input', description: 'allow creation of gan with lot id', category: 'id-rule' }
|
|
20
21
|
]
|
|
21
22
|
|
|
22
23
|
import { Setting } from '@things-factory/setting-base'
|
|
@@ -573,6 +573,55 @@ export const params = {
|
|
|
573
573
|
'productDetails.childProductDetail',
|
|
574
574
|
'productDetails.childQty',
|
|
575
575
|
'productDetails.productBarcodes.gtin'
|
|
576
|
+
],
|
|
577
|
+
'add-sales-invoice': [
|
|
578
|
+
'invoiceProducts',
|
|
579
|
+
'invoiceProducts.sku',
|
|
580
|
+
'invoiceProducts.name',
|
|
581
|
+
'invoiceProducts.description',
|
|
582
|
+
'invoiceProducts.qty',
|
|
583
|
+
'invoiceProducts.unitPrice',
|
|
584
|
+
'invoiceProducts.paidPrice',
|
|
585
|
+
'invoiceProducts.discount',
|
|
586
|
+
'invoiceProducts.shippingFeePaidByCustomer',
|
|
587
|
+
'name',
|
|
588
|
+
'refNo1',
|
|
589
|
+
'refNo2',
|
|
590
|
+
'refNo3',
|
|
591
|
+
'issuedOn',
|
|
592
|
+
'from',
|
|
593
|
+
'fromContactPhone',
|
|
594
|
+
'fromAddress1',
|
|
595
|
+
'fromAddress2',
|
|
596
|
+
'fromAddress3',
|
|
597
|
+
'fromAddress4',
|
|
598
|
+
'fromAddress5',
|
|
599
|
+
'fromPostcode',
|
|
600
|
+
'fromCity',
|
|
601
|
+
'fromState',
|
|
602
|
+
'fromCountry',
|
|
603
|
+
'deliverTo',
|
|
604
|
+
'deliverToPhone',
|
|
605
|
+
'deliveryAddress1',
|
|
606
|
+
'deliveryAddress2',
|
|
607
|
+
'deliveryAddress3',
|
|
608
|
+
'deliveryAddress4',
|
|
609
|
+
'deliveryAddress5',
|
|
610
|
+
'deliveryPostcode',
|
|
611
|
+
'deliveryCity',
|
|
612
|
+
'deliveryState',
|
|
613
|
+
'deliveryCountry',
|
|
614
|
+
'billTo',
|
|
615
|
+
'billToPhone',
|
|
616
|
+
'billingAddress1',
|
|
617
|
+
'billingAddress2',
|
|
618
|
+
'billingAddress3',
|
|
619
|
+
'billingAddress4',
|
|
620
|
+
'billingAddress5',
|
|
621
|
+
'billingPostcode',
|
|
622
|
+
'billingCity',
|
|
623
|
+
'billingState',
|
|
624
|
+
'billingCountry'
|
|
576
625
|
]
|
|
577
626
|
}
|
|
578
627
|
|
|
@@ -1035,6 +1084,19 @@ export const reqParams = {
|
|
|
1035
1084
|
required: true,
|
|
1036
1085
|
type: 'field'
|
|
1037
1086
|
}
|
|
1087
|
+
],
|
|
1088
|
+
'add-sales-invoice': [
|
|
1089
|
+
{ name: 'refNo1', required: true, type: 'field' },
|
|
1090
|
+
{
|
|
1091
|
+
name: 'invoiceProducts',
|
|
1092
|
+
required: true,
|
|
1093
|
+
type: 'array',
|
|
1094
|
+
data: [
|
|
1095
|
+
{ name: 'sku', required: true, type: 'field' },
|
|
1096
|
+
{ name: 'qty', required: true, type: 'field' },
|
|
1097
|
+
{ name: 'paidPrice', required: true, type: 'field' }
|
|
1098
|
+
]
|
|
1099
|
+
}
|
|
1038
1100
|
]
|
|
1039
1101
|
}
|
|
1040
1102
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { EntityManager, getConnection, SelectQueryBuilder } from 'typeorm'
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
3
|
+
|
|
4
|
+
import { restfulApiRouter as router } from '@things-factory/api'
|
|
5
|
+
import { User } from '@things-factory/auth-base'
|
|
6
|
+
import { OrderNoGenerator, Invoice, InvoiceProduct } from '@things-factory/sales-base'
|
|
7
|
+
import { Domain } from '@things-factory/shell'
|
|
8
|
+
|
|
9
|
+
import { businessMiddleware, loggingMiddleware, validationMiddleware } from '../middlewares'
|
|
10
|
+
import { ApiError, ApiErrorHandler, throwInternalServerError } from '../utils/error-util'
|
|
11
|
+
|
|
12
|
+
router.post(
|
|
13
|
+
'/v1/warehouse/add-sales-invoice',
|
|
14
|
+
businessMiddleware,
|
|
15
|
+
validationMiddleware,
|
|
16
|
+
loggingMiddleware,
|
|
17
|
+
async (context, next) => {
|
|
18
|
+
try {
|
|
19
|
+
const { client, domain, user, application } = context.state
|
|
20
|
+
const bodyReq = context.request.body.data
|
|
21
|
+
|
|
22
|
+
await getConnection().transaction(async (tx: EntityManager) => {
|
|
23
|
+
//save invoice
|
|
24
|
+
let createdInvoice: Invoice = await tx.getRepository(Invoice).save({
|
|
25
|
+
...bodyReq,
|
|
26
|
+
domain,
|
|
27
|
+
name: OrderNoGenerator.invoice(),
|
|
28
|
+
creator: user
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const savedInvoice = await tx.getRepository(Invoice).findOne({
|
|
32
|
+
where: { id: createdInvoice.id }
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const data: any = {
|
|
36
|
+
invoice: savedInvoice
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//save invoice products
|
|
40
|
+
const invoiceProducts: any = await addInvoiceProducts(domain, createdInvoice, bodyReq.invoiceProducts, user, tx)
|
|
41
|
+
|
|
42
|
+
data.invoice.invoiceProducts = invoiceProducts
|
|
43
|
+
|
|
44
|
+
context.body = {
|
|
45
|
+
responseCode: '200',
|
|
46
|
+
message: 'success',
|
|
47
|
+
data
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
} catch (e) {
|
|
51
|
+
if (e instanceof ApiError) ApiErrorHandler(context, e)
|
|
52
|
+
else throwInternalServerError(context, e)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
async function addInvoiceProducts(
|
|
58
|
+
domain: Domain,
|
|
59
|
+
invoice: Invoice,
|
|
60
|
+
invoiceProducts: any[],
|
|
61
|
+
user: User,
|
|
62
|
+
tx?: EntityManager
|
|
63
|
+
): Promise<InvoiceProduct[]> {
|
|
64
|
+
const createdInvoiceProducts: InvoiceProduct[] = await Promise.all(
|
|
65
|
+
invoiceProducts.map(async (invoiceProduct: InvoiceProduct) => {
|
|
66
|
+
return {
|
|
67
|
+
name: OrderNoGenerator.invoiceProduct(),
|
|
68
|
+
...invoiceProduct,
|
|
69
|
+
domain,
|
|
70
|
+
invoice,
|
|
71
|
+
creator: user
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
let result: any = await tx.getRepository(InvoiceProduct).save(createdInvoiceProducts)
|
|
77
|
+
|
|
78
|
+
result = result.map((r: any) => {
|
|
79
|
+
return {
|
|
80
|
+
id: r.id,
|
|
81
|
+
sku: r.sku,
|
|
82
|
+
name: r.name,
|
|
83
|
+
description: r.description,
|
|
84
|
+
qty: r.qty,
|
|
85
|
+
unitPrice: r.unitPrice,
|
|
86
|
+
paidPrice: r.paidPrice,
|
|
87
|
+
discount: r.discount,
|
|
88
|
+
shippingFeePaidByCustomer: r.shippingFeePaidByCustomer
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
return result
|
|
93
|
+
}
|