zudello-integration-sdk 1.0.56 → 1.0.58
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/package.json
CHANGED
package/src/sdk/Zudello.js
CHANGED
|
@@ -9,6 +9,7 @@ const AccountingPeriodModule = require("./submodules/zudello/AccountingPeriod");
|
|
|
9
9
|
const AmortizationScheduleModule = require("./submodules/zudello/AmortizationSchedule");
|
|
10
10
|
const BatchModule = require("./submodules/zudello/Batch");
|
|
11
11
|
const BinModule = require("./submodules/zudello/Bin");
|
|
12
|
+
const BudgetModule = require("./submodules/zudello/Budget");
|
|
12
13
|
const CostCentreModule = require("./submodules/zudello/CostCentre");
|
|
13
14
|
const CostTypeModule = require("./submodules/zudello/CostType");
|
|
14
15
|
const CustomerModule = require("./submodules/zudello/Customer");
|
|
@@ -26,6 +27,7 @@ const TaxSolutionModule = require("./submodules/zudello/tax/Solution");
|
|
|
26
27
|
const ItemModule = require("./submodules/zudello/Item");
|
|
27
28
|
const ItemCategoryModule = require("./submodules/zudello/ItemCategory");
|
|
28
29
|
const ItemGroupModule = require("./submodules/zudello/ItemGroup");
|
|
30
|
+
const JournalModule = require("./submodules/zudello/Journal");
|
|
29
31
|
const PurchaseOrderModule = require("./submodules/zudello/PurchaseOrder");
|
|
30
32
|
const PaymentTermModule = require("./submodules/zudello/PaymentTerm");
|
|
31
33
|
const PaymentMethodModule = require("./submodules/zudello/PaymentMethod");
|
|
@@ -76,6 +78,7 @@ class ZudelloSDK extends BaseSDK {
|
|
|
76
78
|
this.amortizationSchedule = new AmortizationScheduleModule(this);
|
|
77
79
|
this.batch = new BatchModule(this);
|
|
78
80
|
this.bin = new BinModule(this);
|
|
81
|
+
this.budget = new BudgetModule(this);
|
|
79
82
|
this.costCentre = new CostCentreModule(this);
|
|
80
83
|
this.costType = new CostTypeModule(this);
|
|
81
84
|
this.customer = new CustomerModule(this);
|
|
@@ -91,6 +94,7 @@ class ZudelloSDK extends BaseSDK {
|
|
|
91
94
|
this.item = new ItemModule(this);
|
|
92
95
|
this.itemCategory = new ItemCategoryModule(this);
|
|
93
96
|
this.itemGroup = new ItemGroupModule(this);
|
|
97
|
+
this.journal = new JournalModule(this);
|
|
94
98
|
this.purchaseOrder = new PurchaseOrderModule(this);
|
|
95
99
|
this.paymentTerm = new PaymentTermModule(this);
|
|
96
100
|
this.paymentMethod = new PaymentMethodModule(this);
|
|
@@ -18,7 +18,7 @@ class UniversalModule {
|
|
|
18
18
|
* @param {boolean} appendLimit Append limit & offset to URL.
|
|
19
19
|
* @returns {object} Universal Request Response.
|
|
20
20
|
*/
|
|
21
|
-
async request({ url, method, qs = {}, body = {}
|
|
21
|
+
async request({ url, method, qs = {}, body = {}}) {
|
|
22
22
|
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
23
23
|
|
|
24
24
|
if (!validateIsEmpty.valid) {
|
|
@@ -53,54 +53,61 @@ class UniversalModule {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* Universal List By URL.
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {
|
|
59
|
-
* @param {
|
|
56
|
+
* Universal List By URL and Method.
|
|
57
|
+
* @param {string} url URL of listed data.
|
|
58
|
+
* @param {string} method Method of listed data.
|
|
59
|
+
* @param {object} qs Some available filters inside: Page, Limit.
|
|
60
|
+
* @param {object} body Some available data inside.
|
|
60
61
|
* @returns {object} Universal List Response.
|
|
61
62
|
*/
|
|
62
|
-
async list({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
async list({ url, method, qs = {}, body = {} }) {
|
|
64
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
65
|
+
|
|
66
|
+
if (!validateIsEmpty.valid) {
|
|
67
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!qs.page) {
|
|
71
|
+
qs.page = 1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!qs.pagesize) {
|
|
75
|
+
qs.pagesize = 100;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return await this.request({ url, method, qs, body });
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
/**
|
|
77
|
-
* Universal Auto Pagination Listing.
|
|
78
|
-
* @param {
|
|
79
|
-
* @param {
|
|
80
|
-
* @param {
|
|
82
|
+
* Universal Auto Pagination Listing By URL and Method.
|
|
83
|
+
* @param {string} url URL of listed data.
|
|
84
|
+
* @param {string} method Method of listed data.
|
|
85
|
+
* @param {object} qs Some available filters inside: Page, Limit.
|
|
86
|
+
* @param {object} body Some available data inside.
|
|
81
87
|
* @returns {object} Auto Pagination responses.
|
|
82
88
|
*/
|
|
83
|
-
async *autoPaginationList({
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
async *autoPaginationList({ url, method, qs = {}, body = {} }) {
|
|
90
|
+
if (!qs.page) {
|
|
91
|
+
qs.page = 1;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!qs.pagesize) {
|
|
95
|
+
qs.pagesize = 100;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let response = await this.list({ url, method, qs, body });
|
|
99
|
+
let currentPageCount = response?.data?.length;
|
|
91
100
|
|
|
92
101
|
yield response;
|
|
93
102
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
after = pageInfo.endCursor;
|
|
103
|
+
if (currentPageCount && currentPageCount === qs.pagesize) {
|
|
104
|
+
while (currentPageCount === qs.pagesize) {
|
|
105
|
+
qs.page = qs.page + 1;
|
|
98
106
|
|
|
99
|
-
response = await this.list({
|
|
107
|
+
response = await this.list({ url, method, qs, body });
|
|
108
|
+
currentPageCount = response?.data?.length;
|
|
100
109
|
|
|
101
110
|
yield response;
|
|
102
|
-
|
|
103
|
-
pageInfo = _.get(response, pageInfoPath);
|
|
104
111
|
}
|
|
105
112
|
}
|
|
106
113
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
class BudgetModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of ZudelloV3 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule
|
|
10
|
+
|
|
11
|
+
this.staticFields = {
|
|
12
|
+
model: 'Budget',
|
|
13
|
+
module: 'BUDGETS',
|
|
14
|
+
submodule: 'BUDGET',
|
|
15
|
+
documentType: 'BUDGET',
|
|
16
|
+
enrich: false,
|
|
17
|
+
extractedEvent: false,
|
|
18
|
+
update: true,
|
|
19
|
+
create: true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async fetch({ uuid, fetchDetails = true, simplified = true }) {
|
|
24
|
+
const validateIsEmpty = this.module.validator.isEmpty({ uuid })
|
|
25
|
+
|
|
26
|
+
if (!validateIsEmpty.valid) {
|
|
27
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return await this.module.fetch({
|
|
31
|
+
model: this.staticFields.model,
|
|
32
|
+
uuid,
|
|
33
|
+
fetchDetails,
|
|
34
|
+
simplified
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async updateOrCreate({ data, clearNulls = true, simplified = false, submit = false, updateStatus = false }) {
|
|
39
|
+
const validateIsEmpty = this.module.validator.isEmpty({ data })
|
|
40
|
+
|
|
41
|
+
if (!validateIsEmpty.valid) {
|
|
42
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.module.logger.log(`[UPDATE OR CREATE]: ZudelloV3 [model - ${this.staticFields.model}]`)
|
|
46
|
+
this.module.logger.log('[PAGE DATA]:')
|
|
47
|
+
this.module.logger.log(data)
|
|
48
|
+
|
|
49
|
+
data = this.module.mapUpdateOrCreateData({
|
|
50
|
+
data,
|
|
51
|
+
staticFields: this.staticFields,
|
|
52
|
+
submit,
|
|
53
|
+
updateStatus
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
this.module.logger.log('[MAPPED PAGE DATA]:')
|
|
57
|
+
this.module.logger.log(data)
|
|
58
|
+
|
|
59
|
+
return await this.module.updateOrCreate({ data, clearNulls, simplified })
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = BudgetModule
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
class JournalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of ZudelloV3 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule
|
|
10
|
+
|
|
11
|
+
this.staticFields = {
|
|
12
|
+
model: 'Transaction',
|
|
13
|
+
module: 'LEDGER',
|
|
14
|
+
submodule: 'JOURNAL',
|
|
15
|
+
documentType: 'JOURNAL',
|
|
16
|
+
enrich: true,
|
|
17
|
+
extractedEvent: false,
|
|
18
|
+
update: true,
|
|
19
|
+
create: true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async fetch({ uuid, fetchDetails = true, simplified = true }) {
|
|
24
|
+
const validateIsEmpty = this.module.validator.isEmpty({ uuid })
|
|
25
|
+
|
|
26
|
+
if (!validateIsEmpty.valid) {
|
|
27
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return await this.module.fetch({
|
|
31
|
+
model: this.staticFields.model,
|
|
32
|
+
uuid,
|
|
33
|
+
fetchDetails,
|
|
34
|
+
simplified
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async updateOrCreate({ data, clearNulls = true, simplified = false, submit = false, updateStatus = false }) {
|
|
39
|
+
const validateIsEmpty = this.module.validator.isEmpty({ data })
|
|
40
|
+
|
|
41
|
+
if (!validateIsEmpty.valid) {
|
|
42
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.module.logger.log(`[UPDATE OR CREATE]: ZudelloV3 [model - ${this.staticFields.model}]`)
|
|
46
|
+
this.module.logger.log('[PAGE DATA]:')
|
|
47
|
+
this.module.logger.log(data)
|
|
48
|
+
|
|
49
|
+
data = this.module.mapUpdateOrCreateData({
|
|
50
|
+
data,
|
|
51
|
+
staticFields: this.staticFields,
|
|
52
|
+
submit,
|
|
53
|
+
updateStatus
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
this.module.logger.log('[MAPPED PAGE DATA]:')
|
|
57
|
+
this.module.logger.log(data)
|
|
58
|
+
|
|
59
|
+
return await this.module.updateOrCreate({ data, clearNulls, simplified })
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = JournalModule
|