@things-factory/operato-hub 4.3.588 → 4.3.591
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/routers/api/restful-apis/unstable/add-sales-invoice.js +82 -78
- package/dist-server/routers/api/restful-apis/unstable/add-sales-invoice.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-sales-invoice.js +19 -2
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-sales-invoice.js.map +1 -1
- package/package.json +58 -58
- package/server/routers/api/restful-apis/unstable/add-sales-invoice.ts +89 -85
- package/server/routers/api/restful-apis/v1/warehouse/add-sales-invoice.ts +25 -3
|
@@ -25,88 +25,92 @@ api_1.restfulApiRouter.post('/unstable/warehouse/:warehouseId/add-sales-invoice'
|
|
|
25
25
|
}
|
|
26
26
|
await checkMandatoryKey(context, bodyReq);
|
|
27
27
|
debug('post:/add-sales-invoice request.body', bodyReq);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const response = await client.mutate({
|
|
29
|
+
mutation: (0, graphql_tag_1.default) `
|
|
30
|
+
mutation createInvoice($invoice: NewInvoice!) {
|
|
31
|
+
createInvoice(invoice: $invoice) {
|
|
32
|
+
id
|
|
33
|
+
name
|
|
34
|
+
refNo1
|
|
35
|
+
refNo2
|
|
36
|
+
refNo3
|
|
37
|
+
issuedOn
|
|
38
|
+
contactPointRefId
|
|
39
|
+
from
|
|
40
|
+
fromContactPhone
|
|
41
|
+
fromAddress1
|
|
42
|
+
fromAddress2
|
|
43
|
+
fromAddress3
|
|
44
|
+
fromAddress4
|
|
45
|
+
fromAddress5
|
|
46
|
+
fromPostcode
|
|
47
|
+
fromCity
|
|
48
|
+
fromState
|
|
49
|
+
fromCountry
|
|
50
|
+
deliverTo
|
|
51
|
+
deliverToPhone
|
|
52
|
+
deliveryAddress1
|
|
53
|
+
deliveryAddress2
|
|
54
|
+
deliveryAddress3
|
|
55
|
+
deliveryAddress4
|
|
56
|
+
deliveryAddress5
|
|
57
|
+
deliveryCity
|
|
58
|
+
deliveryState
|
|
59
|
+
deliveryCountry
|
|
60
|
+
billTo
|
|
61
|
+
billToPhone
|
|
62
|
+
billingAddress1
|
|
63
|
+
billingAddress2
|
|
64
|
+
billingAddress3
|
|
65
|
+
billingAddress4
|
|
66
|
+
billingAddress5
|
|
67
|
+
billingPostcode
|
|
68
|
+
billingCity
|
|
69
|
+
billingState
|
|
70
|
+
billingCountry
|
|
71
|
+
paymentDue
|
|
72
|
+
invoiceProducts {
|
|
73
|
+
id
|
|
74
|
+
name
|
|
75
|
+
product {
|
|
33
76
|
id
|
|
77
|
+
sku
|
|
34
78
|
name
|
|
35
|
-
refNo1
|
|
36
|
-
refNo2
|
|
37
|
-
refNo3
|
|
38
|
-
issuedOn
|
|
39
|
-
contactPointRefId
|
|
40
|
-
from
|
|
41
|
-
fromContactPhone
|
|
42
|
-
fromAddress1
|
|
43
|
-
fromAddress2
|
|
44
|
-
fromAddress3
|
|
45
|
-
fromAddress4
|
|
46
|
-
fromAddress5
|
|
47
|
-
fromPostcode
|
|
48
|
-
fromCity
|
|
49
|
-
fromState
|
|
50
|
-
fromCountry
|
|
51
|
-
deliverTo
|
|
52
|
-
deliverToPhone
|
|
53
|
-
deliveryAddress1
|
|
54
|
-
deliveryAddress2
|
|
55
|
-
deliveryAddress3
|
|
56
|
-
deliveryAddress4
|
|
57
|
-
deliveryAddress5
|
|
58
|
-
deliveryCity
|
|
59
|
-
deliveryState
|
|
60
|
-
deliveryCountry
|
|
61
|
-
billTo
|
|
62
|
-
billToPhone
|
|
63
|
-
billingAddress1
|
|
64
|
-
billingAddress2
|
|
65
|
-
billingAddress3
|
|
66
|
-
billingAddress4
|
|
67
|
-
billingAddress5
|
|
68
|
-
billingPostcode
|
|
69
|
-
billingCity
|
|
70
|
-
billingState
|
|
71
|
-
billingCountry
|
|
72
|
-
paymentDue
|
|
73
|
-
invoiceProducts {
|
|
74
|
-
id
|
|
75
|
-
name
|
|
76
|
-
product {
|
|
77
|
-
id
|
|
78
|
-
sku
|
|
79
|
-
name
|
|
80
|
-
}
|
|
81
|
-
qty
|
|
82
|
-
otherCharges
|
|
83
|
-
unitPrice
|
|
84
|
-
discount
|
|
85
|
-
shippingFeePaidByCustomer
|
|
86
|
-
}
|
|
87
|
-
releaseGood {
|
|
88
|
-
id
|
|
89
|
-
name
|
|
90
|
-
refNo
|
|
91
|
-
refNo2
|
|
92
|
-
refNo3
|
|
93
|
-
}
|
|
94
|
-
creator {
|
|
95
|
-
id
|
|
96
|
-
name
|
|
97
|
-
}
|
|
98
|
-
updater {
|
|
99
|
-
id
|
|
100
|
-
name
|
|
101
|
-
}
|
|
102
|
-
createdAt
|
|
103
|
-
updatedAt
|
|
104
79
|
}
|
|
80
|
+
qty
|
|
81
|
+
otherCharges
|
|
82
|
+
unitPrice
|
|
83
|
+
discount
|
|
84
|
+
shippingFeePaidByCustomer
|
|
85
|
+
}
|
|
86
|
+
releaseGood {
|
|
87
|
+
id
|
|
88
|
+
name
|
|
89
|
+
refNo
|
|
90
|
+
refNo2
|
|
91
|
+
refNo3
|
|
92
|
+
}
|
|
93
|
+
creator {
|
|
94
|
+
id
|
|
95
|
+
name
|
|
105
96
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
updater {
|
|
98
|
+
id
|
|
99
|
+
name
|
|
100
|
+
}
|
|
101
|
+
createdAt
|
|
102
|
+
updatedAt
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
`,
|
|
106
|
+
variables: { invoice: Object.assign({}, bodyReq) },
|
|
107
|
+
context: Object.assign(Object.assign({}, context), { state: Object.assign(Object.assign({}, context.state), { domain, type: 'api' }) })
|
|
108
|
+
});
|
|
109
|
+
if (response.errors) {
|
|
110
|
+
context.throw(404, t(`${response.errors[0].message}`));
|
|
111
|
+
}
|
|
112
|
+
context.body = {
|
|
113
|
+
result: response.data
|
|
110
114
|
};
|
|
111
115
|
(0, integration_base_1.createPayloadLog)(name, `/unstable/warehouse/:warehouseId/add-sales-invoice`, request, context.body, context, integration_base_1.PayloadType.INGESTION);
|
|
112
116
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-sales-invoice.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/add-sales-invoice.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAE7B,6CAAgE;AAEhE,qFAAgF;AAChF,uFAAkF;AAClF,uEAAgF;AAEhF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mEAAmE,CAAC,CAAA;AAEnG,sBAAM,CAAC,IAAI,CACT,oDAAoD,EACpD,wCAAkB,EAClB,0CAAmB,EACnB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IACxC,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IACrB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAA;IACtC,MAAM,OAAO,GAAG;QACd,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;KAClC,CAAA;IACD,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IAElC,IAAI,OAAO,OAAO,KAAK,SAAS,IAAI,CAAC,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,0CAAE,MAAM,CAAA,EAAE;QACjE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAA;KAC3D;IAED,MAAM,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACzC,KAAK,CAAC,sCAAsC,EAAE,OAAO,CAAC,CAAA;IAEtD,
|
|
1
|
+
{"version":3,"file":"add-sales-invoice.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/add-sales-invoice.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAE7B,6CAAgE;AAEhE,qFAAgF;AAChF,uFAAkF;AAClF,uEAAgF;AAEhF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mEAAmE,CAAC,CAAA;AAEnG,sBAAM,CAAC,IAAI,CACT,oDAAoD,EACpD,wCAAkB,EAClB,0CAAmB,EACnB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IACxC,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IACrB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAA;IACtC,MAAM,OAAO,GAAG;QACd,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;KAClC,CAAA;IACD,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IAElC,IAAI,OAAO,OAAO,KAAK,SAAS,IAAI,CAAC,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,0CAAE,MAAM,CAAA,EAAE;QACjE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAA;KAC3D;IAED,MAAM,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACzC,KAAK,CAAC,sCAAsC,EAAE,OAAO,CAAC,CAAA;IAEtD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QACnC,QAAQ,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EAAE,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QACzG,CAAC,CAAC,CAAA;KACH;SAAM;QACL,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;KACjC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;KACnG;AACH,CAAC;AAvBD,8CAuBC"}
|
|
@@ -9,9 +9,10 @@ const middlewares_1 = require("../middlewares");
|
|
|
9
9
|
const error_util_1 = require("../utils/error-util");
|
|
10
10
|
api_1.restfulApiRouter.post('/v1/warehouse/add-sales-invoice', middlewares_1.businessMiddleware, middlewares_1.validationMiddleware, middlewares_1.loggingMiddleware, async (context, next) => {
|
|
11
11
|
try {
|
|
12
|
-
const { domain, user } = context.state;
|
|
13
|
-
const bodyReq = context.request.body.data;
|
|
14
12
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
13
|
+
const { domain, user } = context.state;
|
|
14
|
+
const bodyReq = context.request.body.data;
|
|
15
|
+
await checkExistingInvoice(bodyReq, domain, tx);
|
|
15
16
|
//save invoice
|
|
16
17
|
let createdInvoice = await tx.getRepository(sales_base_1.Invoice).save(Object.assign(Object.assign({}, bodyReq), { domain, name: sales_base_1.OrderNoGenerator.invoice(), creator: user }));
|
|
17
18
|
const savedInvoice = await tx.getRepository(sales_base_1.Invoice).findOne({
|
|
@@ -77,4 +78,20 @@ async function getCustomerCompanyDomain(id, tx) {
|
|
|
77
78
|
});
|
|
78
79
|
return customerBizplace.company.domain;
|
|
79
80
|
}
|
|
81
|
+
async function checkExistingInvoice(payload, domain, tx) {
|
|
82
|
+
let conditions = {
|
|
83
|
+
domain,
|
|
84
|
+
refNo1: payload === null || payload === void 0 ? void 0 : payload.refNo1,
|
|
85
|
+
refNo2: payload.refNo2
|
|
86
|
+
};
|
|
87
|
+
if (payload === null || payload === void 0 ? void 0 : payload.refNo3) {
|
|
88
|
+
conditions.refNo3 = payload === null || payload === void 0 ? void 0 : payload.refNo3;
|
|
89
|
+
}
|
|
90
|
+
const existingInvoice = await tx.getRepository(sales_base_1.Invoice).findOne({
|
|
91
|
+
where: conditions
|
|
92
|
+
});
|
|
93
|
+
if (existingInvoice) {
|
|
94
|
+
throw new error_util_1.ApiError('E06', `Invoice already exists`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
80
97
|
//# sourceMappingURL=add-sales-invoice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-sales-invoice.js","sourceRoot":"","sources":["../../../../../../server/routers/api/restful-apis/v1/warehouse/add-sales-invoice.ts"],"names":[],"mappings":";;AAAA,qCAA0E;AAG1E,6CAAgE;AAEhE,2DAAsF;AACtF,+DAA4D;AAE5D,uDAA4D;AAE5D,gDAA4F;AAC5F,oDAAyF;AAEzF,sBAAM,CAAC,IAAI,CACT,iCAAiC,EACjC,gCAAkB,EAClB,kCAAoB,EACpB,+BAAiB,EACjB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACtB,IAAI;QACF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"add-sales-invoice.js","sourceRoot":"","sources":["../../../../../../server/routers/api/restful-apis/v1/warehouse/add-sales-invoice.ts"],"names":[],"mappings":";;AAAA,qCAA0E;AAG1E,6CAAgE;AAEhE,2DAAsF;AACtF,+DAA4D;AAE5D,uDAA4D;AAE5D,gDAA4F;AAC5F,oDAAyF;AAEzF,sBAAM,CAAC,IAAI,CACT,iCAAiC,EACjC,gCAAkB,EAClB,kCAAoB,EACpB,+BAAiB,EACjB,KAAK,EA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,EAAE;QACnB,MAAM,IAAI,qBAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC,CAAA;KACpD;AACH,CAAC"}
|
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.591",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -55,61 +55,61 @@
|
|
|
55
55
|
"@operato/scene-tab": "^0.1.8",
|
|
56
56
|
"@operato/scene-table": "^0.1.8",
|
|
57
57
|
"@operato/scene-wheel-sorter": "^0.1.8",
|
|
58
|
-
"@things-factory/api": "^4.3.
|
|
59
|
-
"@things-factory/apptool-ui": "^4.3.
|
|
60
|
-
"@things-factory/attachment-base": "^4.3.
|
|
61
|
-
"@things-factory/auth-base": "^4.3.
|
|
62
|
-
"@things-factory/auth-ui": "^4.3.
|
|
63
|
-
"@things-factory/biz-base": "^4.3.
|
|
64
|
-
"@things-factory/biz-ui": "^4.3.
|
|
65
|
-
"@things-factory/board-service": "^4.3.
|
|
66
|
-
"@things-factory/board-ui": "^4.3.
|
|
67
|
-
"@things-factory/code-ui": "^4.3.
|
|
68
|
-
"@things-factory/component-ui": "^4.3.
|
|
69
|
-
"@things-factory/context-ui": "^4.3.
|
|
70
|
-
"@things-factory/document-template-ui": "^4.3.
|
|
71
|
-
"@things-factory/export-ui": "^4.3.
|
|
72
|
-
"@things-factory/export-ui-csv": "^4.3.
|
|
73
|
-
"@things-factory/export-ui-excel": "^4.3.
|
|
74
|
-
"@things-factory/geography": "^4.3.
|
|
75
|
-
"@things-factory/grist-ui": "^4.3.
|
|
76
|
-
"@things-factory/help": "^4.3.
|
|
77
|
-
"@things-factory/i18n-base": "^4.3.
|
|
78
|
-
"@things-factory/import-ui": "^4.3.
|
|
79
|
-
"@things-factory/import-ui-excel": "^4.3.
|
|
80
|
-
"@things-factory/integration-accounting": "^4.3.
|
|
81
|
-
"@things-factory/integration-fulfillment": "^4.3.
|
|
82
|
-
"@things-factory/integration-lmd": "^4.3.
|
|
83
|
-
"@things-factory/integration-marketplace": "^4.3.
|
|
84
|
-
"@things-factory/integration-pos": "^4.3.
|
|
85
|
-
"@things-factory/integration-powrup": "^4.3.
|
|
86
|
-
"@things-factory/integration-sellercraft": "^4.3.
|
|
87
|
-
"@things-factory/integration-sftp": "^4.3.
|
|
88
|
-
"@things-factory/lite-menu": "^4.3.
|
|
89
|
-
"@things-factory/marketplace-base": "^4.3.
|
|
90
|
-
"@things-factory/more-ui": "^4.3.
|
|
91
|
-
"@things-factory/notification": "^4.3.
|
|
92
|
-
"@things-factory/pdf": "^4.3.
|
|
93
|
-
"@things-factory/product-ui": "^4.3.
|
|
94
|
-
"@things-factory/resource-ui": "^4.3.
|
|
95
|
-
"@things-factory/sales-base": "^4.3.
|
|
96
|
-
"@things-factory/scene-data-transform": "^4.3.
|
|
97
|
-
"@things-factory/scene-excel": "^4.3.
|
|
98
|
-
"@things-factory/scene-firebase": "^4.3.
|
|
99
|
-
"@things-factory/scene-form": "^4.3.
|
|
100
|
-
"@things-factory/scene-google-map": "^4.3.
|
|
101
|
-
"@things-factory/scene-graphql": "^4.3.
|
|
102
|
-
"@things-factory/scene-label": "^4.3.
|
|
103
|
-
"@things-factory/scene-marker": "^4.3.
|
|
104
|
-
"@things-factory/scene-mqtt": "^4.3.
|
|
105
|
-
"@things-factory/scene-restful": "^4.3.
|
|
106
|
-
"@things-factory/scene-visualizer": "^4.3.
|
|
107
|
-
"@things-factory/setting-ui": "^4.3.
|
|
108
|
-
"@things-factory/shell": "^4.3.
|
|
109
|
-
"@things-factory/system-ui": "^4.3.
|
|
110
|
-
"@things-factory/transport-base": "^4.3.
|
|
111
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
112
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
58
|
+
"@things-factory/api": "^4.3.591",
|
|
59
|
+
"@things-factory/apptool-ui": "^4.3.591",
|
|
60
|
+
"@things-factory/attachment-base": "^4.3.591",
|
|
61
|
+
"@things-factory/auth-base": "^4.3.591",
|
|
62
|
+
"@things-factory/auth-ui": "^4.3.591",
|
|
63
|
+
"@things-factory/biz-base": "^4.3.591",
|
|
64
|
+
"@things-factory/biz-ui": "^4.3.591",
|
|
65
|
+
"@things-factory/board-service": "^4.3.591",
|
|
66
|
+
"@things-factory/board-ui": "^4.3.591",
|
|
67
|
+
"@things-factory/code-ui": "^4.3.591",
|
|
68
|
+
"@things-factory/component-ui": "^4.3.591",
|
|
69
|
+
"@things-factory/context-ui": "^4.3.591",
|
|
70
|
+
"@things-factory/document-template-ui": "^4.3.591",
|
|
71
|
+
"@things-factory/export-ui": "^4.3.591",
|
|
72
|
+
"@things-factory/export-ui-csv": "^4.3.591",
|
|
73
|
+
"@things-factory/export-ui-excel": "^4.3.591",
|
|
74
|
+
"@things-factory/geography": "^4.3.591",
|
|
75
|
+
"@things-factory/grist-ui": "^4.3.591",
|
|
76
|
+
"@things-factory/help": "^4.3.591",
|
|
77
|
+
"@things-factory/i18n-base": "^4.3.591",
|
|
78
|
+
"@things-factory/import-ui": "^4.3.591",
|
|
79
|
+
"@things-factory/import-ui-excel": "^4.3.591",
|
|
80
|
+
"@things-factory/integration-accounting": "^4.3.591",
|
|
81
|
+
"@things-factory/integration-fulfillment": "^4.3.591",
|
|
82
|
+
"@things-factory/integration-lmd": "^4.3.591",
|
|
83
|
+
"@things-factory/integration-marketplace": "^4.3.591",
|
|
84
|
+
"@things-factory/integration-pos": "^4.3.591",
|
|
85
|
+
"@things-factory/integration-powrup": "^4.3.591",
|
|
86
|
+
"@things-factory/integration-sellercraft": "^4.3.591",
|
|
87
|
+
"@things-factory/integration-sftp": "^4.3.591",
|
|
88
|
+
"@things-factory/lite-menu": "^4.3.591",
|
|
89
|
+
"@things-factory/marketplace-base": "^4.3.591",
|
|
90
|
+
"@things-factory/more-ui": "^4.3.591",
|
|
91
|
+
"@things-factory/notification": "^4.3.591",
|
|
92
|
+
"@things-factory/pdf": "^4.3.591",
|
|
93
|
+
"@things-factory/product-ui": "^4.3.591",
|
|
94
|
+
"@things-factory/resource-ui": "^4.3.591",
|
|
95
|
+
"@things-factory/sales-base": "^4.3.591",
|
|
96
|
+
"@things-factory/scene-data-transform": "^4.3.591",
|
|
97
|
+
"@things-factory/scene-excel": "^4.3.591",
|
|
98
|
+
"@things-factory/scene-firebase": "^4.3.591",
|
|
99
|
+
"@things-factory/scene-form": "^4.3.591",
|
|
100
|
+
"@things-factory/scene-google-map": "^4.3.591",
|
|
101
|
+
"@things-factory/scene-graphql": "^4.3.591",
|
|
102
|
+
"@things-factory/scene-label": "^4.3.591",
|
|
103
|
+
"@things-factory/scene-marker": "^4.3.591",
|
|
104
|
+
"@things-factory/scene-mqtt": "^4.3.591",
|
|
105
|
+
"@things-factory/scene-restful": "^4.3.591",
|
|
106
|
+
"@things-factory/scene-visualizer": "^4.3.591",
|
|
107
|
+
"@things-factory/setting-ui": "^4.3.591",
|
|
108
|
+
"@things-factory/shell": "^4.3.591",
|
|
109
|
+
"@things-factory/system-ui": "^4.3.591",
|
|
110
|
+
"@things-factory/transport-base": "^4.3.591",
|
|
111
|
+
"@things-factory/warehouse-base": "^4.3.591",
|
|
112
|
+
"@things-factory/worksheet-base": "^4.3.591",
|
|
113
113
|
"cron-parser": "^4.7.0",
|
|
114
114
|
"koa2-swagger-ui": "^5.0.2",
|
|
115
115
|
"swagger-jsdoc": "^5.0.0",
|
|
@@ -117,10 +117,10 @@
|
|
|
117
117
|
"yamljs": "^0.3.0"
|
|
118
118
|
},
|
|
119
119
|
"devDependencies": {
|
|
120
|
-
"@things-factory/builder": "^4.3.
|
|
120
|
+
"@things-factory/builder": "^4.3.591"
|
|
121
121
|
},
|
|
122
122
|
"resolutions": {
|
|
123
123
|
"core-js": "^3.16.0"
|
|
124
124
|
},
|
|
125
|
-
"gitHead": "
|
|
125
|
+
"gitHead": "b8528f316a234ad95d0f285d5ade988b44f1195f"
|
|
126
126
|
}
|
|
@@ -29,98 +29,102 @@ router.post(
|
|
|
29
29
|
await checkMandatoryKey(context, bodyReq)
|
|
30
30
|
debug('post:/add-sales-invoice request.body', bodyReq)
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
const response = await client.mutate({
|
|
33
|
+
mutation: gql`
|
|
34
|
+
mutation createInvoice($invoice: NewInvoice!) {
|
|
35
|
+
createInvoice(invoice: $invoice) {
|
|
36
|
+
id
|
|
37
|
+
name
|
|
38
|
+
refNo1
|
|
39
|
+
refNo2
|
|
40
|
+
refNo3
|
|
41
|
+
issuedOn
|
|
42
|
+
contactPointRefId
|
|
43
|
+
from
|
|
44
|
+
fromContactPhone
|
|
45
|
+
fromAddress1
|
|
46
|
+
fromAddress2
|
|
47
|
+
fromAddress3
|
|
48
|
+
fromAddress4
|
|
49
|
+
fromAddress5
|
|
50
|
+
fromPostcode
|
|
51
|
+
fromCity
|
|
52
|
+
fromState
|
|
53
|
+
fromCountry
|
|
54
|
+
deliverTo
|
|
55
|
+
deliverToPhone
|
|
56
|
+
deliveryAddress1
|
|
57
|
+
deliveryAddress2
|
|
58
|
+
deliveryAddress3
|
|
59
|
+
deliveryAddress4
|
|
60
|
+
deliveryAddress5
|
|
61
|
+
deliveryCity
|
|
62
|
+
deliveryState
|
|
63
|
+
deliveryCountry
|
|
64
|
+
billTo
|
|
65
|
+
billToPhone
|
|
66
|
+
billingAddress1
|
|
67
|
+
billingAddress2
|
|
68
|
+
billingAddress3
|
|
69
|
+
billingAddress4
|
|
70
|
+
billingAddress5
|
|
71
|
+
billingPostcode
|
|
72
|
+
billingCity
|
|
73
|
+
billingState
|
|
74
|
+
billingCountry
|
|
75
|
+
paymentDue
|
|
76
|
+
invoiceProducts {
|
|
77
|
+
id
|
|
78
|
+
name
|
|
79
|
+
product {
|
|
38
80
|
id
|
|
81
|
+
sku
|
|
39
82
|
name
|
|
40
|
-
refNo1
|
|
41
|
-
refNo2
|
|
42
|
-
refNo3
|
|
43
|
-
issuedOn
|
|
44
|
-
contactPointRefId
|
|
45
|
-
from
|
|
46
|
-
fromContactPhone
|
|
47
|
-
fromAddress1
|
|
48
|
-
fromAddress2
|
|
49
|
-
fromAddress3
|
|
50
|
-
fromAddress4
|
|
51
|
-
fromAddress5
|
|
52
|
-
fromPostcode
|
|
53
|
-
fromCity
|
|
54
|
-
fromState
|
|
55
|
-
fromCountry
|
|
56
|
-
deliverTo
|
|
57
|
-
deliverToPhone
|
|
58
|
-
deliveryAddress1
|
|
59
|
-
deliveryAddress2
|
|
60
|
-
deliveryAddress3
|
|
61
|
-
deliveryAddress4
|
|
62
|
-
deliveryAddress5
|
|
63
|
-
deliveryCity
|
|
64
|
-
deliveryState
|
|
65
|
-
deliveryCountry
|
|
66
|
-
billTo
|
|
67
|
-
billToPhone
|
|
68
|
-
billingAddress1
|
|
69
|
-
billingAddress2
|
|
70
|
-
billingAddress3
|
|
71
|
-
billingAddress4
|
|
72
|
-
billingAddress5
|
|
73
|
-
billingPostcode
|
|
74
|
-
billingCity
|
|
75
|
-
billingState
|
|
76
|
-
billingCountry
|
|
77
|
-
paymentDue
|
|
78
|
-
invoiceProducts {
|
|
79
|
-
id
|
|
80
|
-
name
|
|
81
|
-
product {
|
|
82
|
-
id
|
|
83
|
-
sku
|
|
84
|
-
name
|
|
85
|
-
}
|
|
86
|
-
qty
|
|
87
|
-
otherCharges
|
|
88
|
-
unitPrice
|
|
89
|
-
discount
|
|
90
|
-
shippingFeePaidByCustomer
|
|
91
|
-
}
|
|
92
|
-
releaseGood {
|
|
93
|
-
id
|
|
94
|
-
name
|
|
95
|
-
refNo
|
|
96
|
-
refNo2
|
|
97
|
-
refNo3
|
|
98
|
-
}
|
|
99
|
-
creator {
|
|
100
|
-
id
|
|
101
|
-
name
|
|
102
|
-
}
|
|
103
|
-
updater {
|
|
104
|
-
id
|
|
105
|
-
name
|
|
106
|
-
}
|
|
107
|
-
createdAt
|
|
108
|
-
updatedAt
|
|
109
83
|
}
|
|
84
|
+
qty
|
|
85
|
+
otherCharges
|
|
86
|
+
unitPrice
|
|
87
|
+
discount
|
|
88
|
+
shippingFeePaidByCustomer
|
|
89
|
+
}
|
|
90
|
+
releaseGood {
|
|
91
|
+
id
|
|
92
|
+
name
|
|
93
|
+
refNo
|
|
94
|
+
refNo2
|
|
95
|
+
refNo3
|
|
110
96
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
...context,
|
|
115
|
-
state: {
|
|
116
|
-
...context.state,
|
|
117
|
-
domain,
|
|
118
|
-
type: 'api'
|
|
97
|
+
creator {
|
|
98
|
+
id
|
|
99
|
+
name
|
|
119
100
|
}
|
|
101
|
+
updater {
|
|
102
|
+
id
|
|
103
|
+
name
|
|
104
|
+
}
|
|
105
|
+
createdAt
|
|
106
|
+
updatedAt
|
|
120
107
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
108
|
+
}
|
|
109
|
+
`,
|
|
110
|
+
variables: { invoice: { ...bodyReq }},
|
|
111
|
+
context: {
|
|
112
|
+
...context,
|
|
113
|
+
state: {
|
|
114
|
+
...context.state,
|
|
115
|
+
domain,
|
|
116
|
+
type: 'api'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} as any)
|
|
120
|
+
|
|
121
|
+
if (response.errors) {
|
|
122
|
+
context.throw(404, t(`${response.errors[0].message}`))
|
|
123
123
|
}
|
|
124
|
+
context.body = {
|
|
125
|
+
result: response.data
|
|
126
|
+
}
|
|
127
|
+
|
|
124
128
|
createPayloadLog(
|
|
125
129
|
name,
|
|
126
130
|
`/unstable/warehouse/:warehouseId/add-sales-invoice`,
|
|
@@ -18,10 +18,12 @@ router.post(
|
|
|
18
18
|
loggingMiddleware,
|
|
19
19
|
async (context, next) => {
|
|
20
20
|
try {
|
|
21
|
-
const { domain, user } = context.state
|
|
22
|
-
const bodyReq = context.request.body.data
|
|
23
|
-
|
|
24
21
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
22
|
+
const { domain, user } = context.state
|
|
23
|
+
const bodyReq = context.request.body.data
|
|
24
|
+
|
|
25
|
+
await checkExistingInvoice(bodyReq, domain, tx)
|
|
26
|
+
|
|
25
27
|
//save invoice
|
|
26
28
|
let createdInvoice: Invoice = await tx.getRepository(Invoice).save({
|
|
27
29
|
...bodyReq,
|
|
@@ -122,3 +124,23 @@ async function getCustomerCompanyDomain(id, tx): Promise<Bizplace> {
|
|
|
122
124
|
|
|
123
125
|
return customerBizplace.company.domain
|
|
124
126
|
}
|
|
127
|
+
|
|
128
|
+
async function checkExistingInvoice(payload, domain, tx: EntityManager) {
|
|
129
|
+
let conditions: any = {
|
|
130
|
+
domain,
|
|
131
|
+
refNo1: payload?.refNo1,
|
|
132
|
+
refNo2: payload.refNo2
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (payload?.refNo3) {
|
|
136
|
+
conditions.refNo3 = payload?.refNo3
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const existingInvoice: Invoice = await tx.getRepository(Invoice).findOne({
|
|
140
|
+
where: conditions
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
if (existingInvoice) {
|
|
144
|
+
throw new ApiError('E06', `Invoice already exists`)
|
|
145
|
+
}
|
|
146
|
+
}
|