zudello-integration-sdk 1.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/README.md +1 -0
- package/package.json +23 -0
- package/src/index.js +62 -0
- package/src/integrations/samples/bc-zudello/account.js +40 -0
- package/src/integrations/samples/bc-zudello/accountingPeriod.js +52 -0
- package/src/integrations/samples/bc-zudello/currency.js +42 -0
- package/src/integrations/samples/bc-zudello/customer.js +45 -0
- package/src/integrations/samples/bc-zudello/dimension.js +85 -0
- package/src/integrations/samples/bc-zudello/employee.js +38 -0
- package/src/integrations/samples/bc-zudello/fixedAsset.js +48 -0
- package/src/integrations/samples/bc-zudello/item.js +45 -0
- package/src/integrations/samples/bc-zudello/itemCategory.js +37 -0
- package/src/integrations/samples/bc-zudello/location.js +37 -0
- package/src/integrations/samples/bc-zudello/paymentMethod.js +38 -0
- package/src/integrations/samples/bc-zudello/paymentTerm.js +41 -0
- package/src/integrations/samples/bc-zudello/project.js +38 -0
- package/src/integrations/samples/bc-zudello/purchaseCredit.js +109 -0
- package/src/integrations/samples/bc-zudello/purchaseInvoice.js +138 -0
- package/src/integrations/samples/bc-zudello/purchaseOrder.js +150 -0
- package/src/integrations/samples/bc-zudello/purchaseOrderFetch.js +100 -0
- package/src/integrations/samples/bc-zudello/supplier.js +40 -0
- package/src/integrations/samples/bc-zudello/taxRate.js +39 -0
- package/src/integrations/samples/bc-zudello/uom.js +42 -0
- package/src/integrations/samples/dear-zudello/account.js +20 -0
- package/src/integrations/samples/dear-zudello/customer.js +23 -0
- package/src/integrations/samples/dear-zudello/item.js +30 -0
- package/src/integrations/samples/dear-zudello/location.js +19 -0
- package/src/integrations/samples/dear-zudello/salesOrder.js +126 -0
- package/src/integrations/samples/dear-zudello/supplier.js +23 -0
- package/src/integrations/samples/dear-zudello/taxRate.js +19 -0
- package/src/integrations/samples/fo-zudello/account.js +20 -0
- package/src/integrations/samples/fo-zudello/costCentre.js +20 -0
- package/src/integrations/samples/fo-zudello/department.js +20 -0
- package/src/integrations/samples/fo-zudello/item.js +21 -0
- package/src/integrations/samples/fo-zudello/location.js +20 -0
- package/src/integrations/samples/fo-zudello/project.js +18 -0
- package/src/integrations/samples/fo-zudello/subsidiary.js +20 -0
- package/src/integrations/samples/fo-zudello/supplier.js +23 -0
- package/src/integrations/samples/fo-zudello/taxRate.js +20 -0
- package/src/integrations/samples/intacct-zudello/account.js +56 -0
- package/src/integrations/samples/intacct-zudello/accountGroup.js +54 -0
- package/src/integrations/samples/intacct-zudello/accountingPeriod.js +67 -0
- package/src/integrations/samples/intacct-zudello/apBill.js +146 -0
- package/src/integrations/samples/intacct-zudello/apBillFetch.js +195 -0
- package/src/integrations/samples/intacct-zudello/costCentre.js +54 -0
- package/src/integrations/samples/intacct-zudello/costType.js +54 -0
- package/src/integrations/samples/intacct-zudello/customerCategory.js +54 -0
- package/src/integrations/samples/intacct-zudello/customerGroup.js +54 -0
- package/src/integrations/samples/intacct-zudello/department.js +54 -0
- package/src/integrations/samples/intacct-zudello/employee.js +51 -0
- package/src/integrations/samples/intacct-zudello/expense-create.js +156 -0
- package/src/integrations/samples/intacct-zudello/item.js +64 -0
- package/src/integrations/samples/intacct-zudello/itemCategory.js +54 -0
- package/src/integrations/samples/intacct-zudello/itemGroup.js +54 -0
- package/src/integrations/samples/intacct-zudello/location.js +54 -0
- package/src/integrations/samples/intacct-zudello/paymentTerm.js +56 -0
- package/src/integrations/samples/intacct-zudello/project.js +54 -0
- package/src/integrations/samples/intacct-zudello/projectGroup.js +54 -0
- package/src/integrations/samples/intacct-zudello/projectTask.js +40 -0
- package/src/integrations/samples/intacct-zudello/subsidiary.js +54 -0
- package/src/integrations/samples/intacct-zudello/supplier.js +168 -0
- package/src/integrations/samples/intacct-zudello/supplierCategory.js +54 -0
- package/src/integrations/samples/intacct-zudello/supplierGroup.js +54 -0
- package/src/integrations/samples/intacct-zudello/supplierV2.js +64 -0
- package/src/integrations/samples/intacct-zudello/taxRate.js +34 -0
- package/src/integrations/samples/intacct-zudello/taxSolution.js +35 -0
- package/src/integrations/samples/intacct-zudello/uom.js +37 -0
- package/src/integrations/samples/intacct-zudello/warehouse.js +54 -0
- package/src/integrations/samples/intacct-zudello/zone.js +54 -0
- package/src/integrations/samples/nexvia-zudello/account.js +20 -0
- package/src/integrations/samples/nexvia-zudello/costCentre.js +19 -0
- package/src/integrations/samples/nexvia-zudello/costType.js +19 -0
- package/src/integrations/samples/nexvia-zudello/currency.js +20 -0
- package/src/integrations/samples/nexvia-zudello/department.js +20 -0
- package/src/integrations/samples/nexvia-zudello/itemCategory.js +19 -0
- package/src/integrations/samples/nexvia-zudello/location.js +20 -0
- package/src/integrations/samples/nexvia-zudello/project.js +20 -0
- package/src/integrations/samples/nexvia-zudello/supplier.js +21 -0
- package/src/integrations/samples/nexvia-zudello/taxRate.js +21 -0
- package/src/integrations/samples/nexvia-zudello/uom.js +19 -0
- package/src/integrations/samples/nexvia-zudello/zone.js +20 -0
- package/src/integrations/samples/zenoti-zudello/location.js +20 -0
- package/src/integrations/samples/zenoti-zudello/product.js +32 -0
- package/src/integrations/samples/zenoti-zudello/purchaseOrder.js +193 -0
- package/src/sdk/Auth.js +42 -0
- package/src/sdk/Base.js +118 -0
- package/src/sdk/BusinessCentral.js +31 -0
- package/src/sdk/Dear.js +31 -0
- package/src/sdk/Fo.js +31 -0
- package/src/sdk/Intacct.js +103 -0
- package/src/sdk/JobReady.js +31 -0
- package/src/sdk/MYOBAcumatica.js +33 -0
- package/src/sdk/Netsuite.js +31 -0
- package/src/sdk/NetsuiteSOAP.js +92 -0
- package/src/sdk/Nexvia.js +31 -0
- package/src/sdk/RetailExpress.js +31 -0
- package/src/sdk/Sybiz.js +31 -0
- package/src/sdk/Zenoti.js +31 -0
- package/src/sdk/Zudello.js +206 -0
- package/src/sdk/submodules/bc/Universal.js +109 -0
- package/src/sdk/submodules/dear/Universal.js +110 -0
- package/src/sdk/submodules/fo/Universal.js +111 -0
- package/src/sdk/submodules/intacct/Account.js +31 -0
- package/src/sdk/submodules/intacct/AccountGroup.js +31 -0
- package/src/sdk/submodules/intacct/AccountingPeriod.js +31 -0
- package/src/sdk/submodules/intacct/ApAdjustment.js +35 -0
- package/src/sdk/submodules/intacct/ApBill.js +52 -0
- package/src/sdk/submodules/intacct/ApTerm.js +31 -0
- package/src/sdk/submodules/intacct/ArAdjustment.js +35 -0
- package/src/sdk/submodules/intacct/ArInvoice.js +35 -0
- package/src/sdk/submodules/intacct/ArTerm.js +31 -0
- package/src/sdk/submodules/intacct/Budget.js +31 -0
- package/src/sdk/submodules/intacct/Class.js +31 -0
- package/src/sdk/submodules/intacct/CostType.js +31 -0
- package/src/sdk/submodules/intacct/Customer.js +31 -0
- package/src/sdk/submodules/intacct/CustomerGroup.js +31 -0
- package/src/sdk/submodules/intacct/CustomerType.js +31 -0
- package/src/sdk/submodules/intacct/Department.js +31 -0
- package/src/sdk/submodules/intacct/Employee.js +31 -0
- package/src/sdk/submodules/intacct/Entity.js +31 -0
- package/src/sdk/submodules/intacct/File.js +26 -0
- package/src/sdk/submodules/intacct/Item.js +31 -0
- package/src/sdk/submodules/intacct/ItemGroup.js +31 -0
- package/src/sdk/submodules/intacct/Location.js +31 -0
- package/src/sdk/submodules/intacct/PoDocument.js +52 -0
- package/src/sdk/submodules/intacct/ProductLine.js +31 -0
- package/src/sdk/submodules/intacct/Project.js +31 -0
- package/src/sdk/submodules/intacct/ProjectGroup.js +31 -0
- package/src/sdk/submodules/intacct/Task.js +31 -0
- package/src/sdk/submodules/intacct/TaxDetail.js +31 -0
- package/src/sdk/submodules/intacct/TaxGroups.js +31 -0
- package/src/sdk/submodules/intacct/TaxSolution.js +31 -0
- package/src/sdk/submodules/intacct/Universal.js +139 -0
- package/src/sdk/submodules/intacct/Uom.js +31 -0
- package/src/sdk/submodules/intacct/Vendor.js +31 -0
- package/src/sdk/submodules/intacct/VendorGroup.js +31 -0
- package/src/sdk/submodules/intacct/VendorTypes.js +31 -0
- package/src/sdk/submodules/intacct/Warehouse.js +31 -0
- package/src/sdk/submodules/intacct/Zone.js +31 -0
- package/src/sdk/submodules/intacct/apAdjustment/Item.js +31 -0
- package/src/sdk/submodules/intacct/apBill/Item.js +31 -0
- package/src/sdk/submodules/intacct/arAdjustment/Item.js +31 -0
- package/src/sdk/submodules/intacct/arInvoice/Item.js +31 -0
- package/src/sdk/submodules/intacct/poDocument/Item.js +31 -0
- package/src/sdk/submodules/jobready/Universal.js +107 -0
- package/src/sdk/submodules/myobAcumatica/OData.js +109 -0
- package/src/sdk/submodules/myobAcumatica/Universal.js +109 -0
- package/src/sdk/submodules/netsuite/Universal.js +97 -0
- package/src/sdk/submodules/netsuite-soap/PurchaseOrder.js +39 -0
- package/src/sdk/submodules/netsuite-soap/Receipt.js +39 -0
- package/src/sdk/submodules/netsuite-soap/Universal.js +124 -0
- package/src/sdk/submodules/netsuite-soap/UniversalTransaction.js +138 -0
- package/src/sdk/submodules/netsuite-soap/VendorBill.js +41 -0
- package/src/sdk/submodules/netsuite-soap/VendorCredit.js +39 -0
- package/src/sdk/submodules/nexvia/Universal.js +108 -0
- package/src/sdk/submodules/retailExpress/Universal.js +107 -0
- package/src/sdk/submodules/sybiz/Universal.js +108 -0
- package/src/sdk/submodules/zenoti/Universal.js +110 -0
- package/src/sdk/submodules/zudello/Account.js +63 -0
- package/src/sdk/submodules/zudello/AccountGroup.js +63 -0
- package/src/sdk/submodules/zudello/AccountingPeriod.js +63 -0
- package/src/sdk/submodules/zudello/CostCentre.js +63 -0
- package/src/sdk/submodules/zudello/CostType.js +63 -0
- package/src/sdk/submodules/zudello/Currency.js +63 -0
- package/src/sdk/submodules/zudello/Customer.js +63 -0
- package/src/sdk/submodules/zudello/CustomerCategory.js +63 -0
- package/src/sdk/submodules/zudello/CustomerGroup.js +63 -0
- package/src/sdk/submodules/zudello/Department.js +63 -0
- package/src/sdk/submodules/zudello/Employee.js +63 -0
- package/src/sdk/submodules/zudello/FixedAsset.js +63 -0
- package/src/sdk/submodules/zudello/Item.js +63 -0
- package/src/sdk/submodules/zudello/ItemCategory.js +63 -0
- package/src/sdk/submodules/zudello/ItemGroup.js +63 -0
- package/src/sdk/submodules/zudello/Location.js +63 -0
- package/src/sdk/submodules/zudello/PaymentMethod.js +63 -0
- package/src/sdk/submodules/zudello/PaymentTerm.js +63 -0
- package/src/sdk/submodules/zudello/Project.js +63 -0
- package/src/sdk/submodules/zudello/ProjectGroup.js +63 -0
- package/src/sdk/submodules/zudello/ProjectTask.js +63 -0
- package/src/sdk/submodules/zudello/PurchaseOrder.js +63 -0
- package/src/sdk/submodules/zudello/Subsidiary.js +63 -0
- package/src/sdk/submodules/zudello/Supplier.js +63 -0
- package/src/sdk/submodules/zudello/SupplierCategory.js +63 -0
- package/src/sdk/submodules/zudello/SupplierGroup.js +63 -0
- package/src/sdk/submodules/zudello/Universal.js +31 -0
- package/src/sdk/submodules/zudello/Uom.js +63 -0
- package/src/sdk/submodules/zudello/Warehouse.js +63 -0
- package/src/sdk/submodules/zudello/Zone.js +63 -0
- package/src/sdk/submodules/zudello/tax/Rate.js +63 -0
- package/src/sdk/submodules/zudello/tax/Solution.js +63 -0
- package/src/utils/apiInstance.js +198 -0
- package/src/utils/config.js +18 -0
- package/src/utils/logger.js +122 -0
- package/src/utils/metadata.js +102 -0
- package/src/utils/miscHelper.js +24 -0
- package/src/utils/modelHelper.js +140 -0
- package/src/utils/properties.js +32 -0
- package/src/utils/responseHandler.js +28 -0
- package/src/utils/s3Client.js +128 -0
- package/src/utils/tags.js +32 -0
- package/src/utils/validator.js +73 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
const lastModified = metadata.get('lastModified')
|
|
3
|
+
const fetchData = { pageSize: 2000, offset: 0, include: ['WHENMODIFIED'], filters: [{ fName: "VENDTYPE", operator: "notequalto", fValue: "Employees" }], orderBy: 'WHENMODIFIED' }
|
|
4
|
+
|
|
5
|
+
if (lastModified) {
|
|
6
|
+
fetchData.filters.push({
|
|
7
|
+
fName: { value: 'WHENMODIFIED' },
|
|
8
|
+
operator: { value: 'greaterthan' },
|
|
9
|
+
fValue: { value: lastModified }
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
logger.log(fetchData)
|
|
14
|
+
|
|
15
|
+
for await (const items of Intacct.vendor.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "VENDORID"),
|
|
21
|
+
"code": _.get(result, "VENDORID"),
|
|
22
|
+
"legal_name": _.get(result, "NAME"),
|
|
23
|
+
"trading_name": _.get(result, "NAME"),
|
|
24
|
+
"accounts": _.get(result, "APACCOUNT"),
|
|
25
|
+
"accounts": {
|
|
26
|
+
"replace": true,
|
|
27
|
+
"items": (_.get(result, "APACCOUNT")) ? [
|
|
28
|
+
{
|
|
29
|
+
"fetch": true,
|
|
30
|
+
"data": {
|
|
31
|
+
"external_id": _.get(result, "APACCOUNT")
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
] : []
|
|
35
|
+
},
|
|
36
|
+
"bank_account_name": _.get(result, "VENDORBANKFILEDETAILS.vendorbankfiledetail.ACCOUNTNAME"),
|
|
37
|
+
"bank_account_number": _.get(result, "VENDORBANKFILEDETAILS.vendorbankfiledetail.BANKACCOUNTNUMBER"),
|
|
38
|
+
"bank_bsb": _.get(result, "VENDORBANKFILEDETAILS.vendorbankfiledetail.BSBNUMBER"),
|
|
39
|
+
"country": {
|
|
40
|
+
"fetch": true,
|
|
41
|
+
"data": (_.get(result, "DISPLAYCONTACT.MAILADDRESS.COUNTRY")) ? { "code": _.get(result, "DISPLAYCONTACT.MAILADDRESS.COUNTRY")} : {}
|
|
42
|
+
},
|
|
43
|
+
"currency": {
|
|
44
|
+
"fetch": true,
|
|
45
|
+
"data": (_.get(result, "CURRENCY")) ? { "code": _.get(result, "CURRENCY")} : {}
|
|
46
|
+
},
|
|
47
|
+
"supplier_category": {
|
|
48
|
+
"fetch": true,
|
|
49
|
+
"data": (_.get(result, "VENDTYPE")) ? { "external_id": _.get(result, "VENDTYPE")} : {}
|
|
50
|
+
},
|
|
51
|
+
"departments": {
|
|
52
|
+
"replace": true,
|
|
53
|
+
"items": (_.get(result, "RESTRICTEDDEPARTMENTS")) ? [
|
|
54
|
+
{
|
|
55
|
+
"fetch": true,
|
|
56
|
+
"data": {
|
|
57
|
+
"external_id": _.get(result, "RESTRICTEDDEPARTMENTS")
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
] : []
|
|
61
|
+
},
|
|
62
|
+
"locations": {
|
|
63
|
+
"replace": true,
|
|
64
|
+
"items": (_.get(result, "RESTRICTEDLOCATIONS")) ? [
|
|
65
|
+
{
|
|
66
|
+
"fetch": true,
|
|
67
|
+
"data": {
|
|
68
|
+
"external_id": _.get(result, "RESTRICTEDLOCATIONS")
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
] : []
|
|
72
|
+
},
|
|
73
|
+
"payment_method": {
|
|
74
|
+
"fetch": true,
|
|
75
|
+
"data": (_.get(result, "PAYMETHODKEY")) ? { "external_id": _.get(result, "PAYMETHODKEY")} : {}
|
|
76
|
+
},
|
|
77
|
+
"payment_term": {
|
|
78
|
+
"fetch": true,
|
|
79
|
+
"data": (_.get(result, "TERMNAME")) ? { "external_id": _.get(result, "TERMNAME")} : {}
|
|
80
|
+
},
|
|
81
|
+
"subsidiaries": {
|
|
82
|
+
"replace": true,
|
|
83
|
+
"items": (_.get(result, "MEGAENTITYID")) ? [
|
|
84
|
+
{
|
|
85
|
+
"fetch": true,
|
|
86
|
+
"data": {
|
|
87
|
+
"external_id": _.get(result, "MEGAENTITYID")
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
] : []
|
|
91
|
+
},
|
|
92
|
+
"tax_number": _.get(result, "TAXID"),
|
|
93
|
+
"tax_rate": {
|
|
94
|
+
"fetch": true,
|
|
95
|
+
"data": (_.get(result, "DISPLAYCONTACT.TAXSCHEDULE")) ? { "external_id": _.get(result, "DISPLAYCONTACT.TAXSCHEDULE")} : {}
|
|
96
|
+
},
|
|
97
|
+
"status": _.get(result, "STATUS").toUpperCase(),
|
|
98
|
+
"phones": {
|
|
99
|
+
"replace": true,
|
|
100
|
+
"items": [
|
|
101
|
+
{
|
|
102
|
+
"create": true,
|
|
103
|
+
"data": {
|
|
104
|
+
// "external_id": _.get(result, "")
|
|
105
|
+
"phone": _.get(result, "")
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
"emails": {
|
|
111
|
+
"replace": true,
|
|
112
|
+
"items": [
|
|
113
|
+
{
|
|
114
|
+
"create": true,
|
|
115
|
+
// "update": true,
|
|
116
|
+
"data": {
|
|
117
|
+
// "external_id": _.get(result, "")
|
|
118
|
+
"email": _.get(result, "")
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"depends_on": {
|
|
124
|
+
"replace": true,
|
|
125
|
+
"items": [
|
|
126
|
+
{
|
|
127
|
+
"create": true,
|
|
128
|
+
"model": "Subsidiary",
|
|
129
|
+
"data": {
|
|
130
|
+
"external_id": ""
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
const batchSize = 100
|
|
139
|
+
|
|
140
|
+
for (let i = 0; i < data.length; i += batchSize) {
|
|
141
|
+
const batch = data.slice(i, i + batchSize)
|
|
142
|
+
|
|
143
|
+
logger.log(batch)
|
|
144
|
+
|
|
145
|
+
const result = await Zudello.supplier.updateOrCreate({ data: batch })
|
|
146
|
+
|
|
147
|
+
logger.log(result)
|
|
148
|
+
logger.log(`Processed batch ${Math.ceil((i + batchSize) / batchSize)} of ${Math.ceil(data.length / batchSize)}`)
|
|
149
|
+
|
|
150
|
+
if (result.success) {
|
|
151
|
+
const lastObject = _.last(items.data)
|
|
152
|
+
const updatedLastModified = lastObject ? lastObject.WHENMODIFIED : null
|
|
153
|
+
|
|
154
|
+
if (updatedLastModified) {
|
|
155
|
+
metadata.set('lastModified', updatedLastModified)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Introduce a delay of 3 seconds (3000 milliseconds) after each batch
|
|
160
|
+
if (i + batchSize < data.length) {
|
|
161
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
// Currencies oftern wont have external ID, unless created by the integaration
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
const lastModified = metadata.get('lastModified')
|
|
3
|
+
const fetchData = { pageSize: 2000, offset: 0, include: ['WHENMODIFIED'], orderBy: 'WHENMODIFIED' }
|
|
4
|
+
|
|
5
|
+
if (lastModified) {
|
|
6
|
+
fetchData.filters = [{
|
|
7
|
+
fName: { value: 'WHENMODIFIED' },
|
|
8
|
+
operator: { value: 'greaterthan' },
|
|
9
|
+
fValue: { value: lastModified }
|
|
10
|
+
}]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
logger.log(fetchData)
|
|
14
|
+
|
|
15
|
+
for await (const items of Intacct.vendorTypes.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "RECORDNO"),
|
|
21
|
+
"code": _.get(result, "RECORDNO"),
|
|
22
|
+
"name": _.get(result, "NAME"),
|
|
23
|
+
"status": _.get(result, "STATUS", "ACTIVE").toUpperCase()
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const batchSize = 100
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < data.length; i += batchSize) {
|
|
30
|
+
const batch = data.slice(i, i + batchSize)
|
|
31
|
+
|
|
32
|
+
logger.log(batch)
|
|
33
|
+
|
|
34
|
+
const result = await Zudello.supplierCategory.updateOrCreate({ data: batch })
|
|
35
|
+
|
|
36
|
+
logger.log(result)
|
|
37
|
+
logger.log(`Processed batch ${Math.ceil((i + batchSize) / batchSize)} of ${Math.ceil(data.length / batchSize)}`)
|
|
38
|
+
|
|
39
|
+
if (result.success) {
|
|
40
|
+
const lastObject = _.last(items.data)
|
|
41
|
+
const updatedLastModified = lastObject ? lastObject.WHENMODIFIED : null
|
|
42
|
+
|
|
43
|
+
if (updatedLastModified) {
|
|
44
|
+
metadata.set('lastModified', updatedLastModified)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Introduce a delay of 3 seconds (3000 milliseconds) after each batch
|
|
49
|
+
if (i + batchSize < data.length) {
|
|
50
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
const lastModified = metadata.get('lastModified')
|
|
3
|
+
const fetchData = { pageSize: 2000, offset: 0, include: ['WHENMODIFIED'], orderBy: 'WHENMODIFIED' }
|
|
4
|
+
|
|
5
|
+
if (lastModified) {
|
|
6
|
+
fetchData.filters = [{
|
|
7
|
+
fName: { value: 'WHENMODIFIED' },
|
|
8
|
+
operator: { value: 'greaterthan' },
|
|
9
|
+
fValue: { value: lastModified }
|
|
10
|
+
}]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
logger.log(fetchData)
|
|
14
|
+
|
|
15
|
+
for await (const items of Intacct.vendorGroup.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "ID"),
|
|
21
|
+
"code": _.get(result, "ID"),
|
|
22
|
+
"name": _.get(result, "NAME"),
|
|
23
|
+
"status": "ACTIVE"
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const batchSize = 100
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < data.length; i += batchSize) {
|
|
30
|
+
const batch = data.slice(i, i + batchSize)
|
|
31
|
+
|
|
32
|
+
logger.log(batch)
|
|
33
|
+
|
|
34
|
+
const result = await Zudello.supplierGroup.updateOrCreate({ data: batch })
|
|
35
|
+
|
|
36
|
+
logger.log(result)
|
|
37
|
+
logger.log(`Processed batch ${Math.ceil((i + batchSize) / batchSize)} of ${Math.ceil(data.length / batchSize)}`)
|
|
38
|
+
|
|
39
|
+
if (result.success) {
|
|
40
|
+
const lastObject = _.last(items.data)
|
|
41
|
+
const updatedLastModified = lastObject ? lastObject.WHENMODIFIED : null
|
|
42
|
+
|
|
43
|
+
if (updatedLastModified) {
|
|
44
|
+
metadata.set('lastModified', updatedLastModified)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Introduce a delay of 3 seconds (3000 milliseconds) after each batch
|
|
49
|
+
if (i + batchSize < data.length) {
|
|
50
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
const lastModified = metadata.get('lastModified')
|
|
3
|
+
const fetchData = { pageSize: 100, offset: 0, include: ['WHENMODIFIED'], orderBy: 'WHENMODIFIED' }
|
|
4
|
+
|
|
5
|
+
if (lastModified) {
|
|
6
|
+
fetchData.filters = [{
|
|
7
|
+
fName: { value: 'WHENMODIFIED' },
|
|
8
|
+
operator: { value: 'greaterthan' },
|
|
9
|
+
fValue: { value: lastModified }
|
|
10
|
+
}]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
logger.log(fetchData)
|
|
14
|
+
|
|
15
|
+
for await (const itemPaginated of Intacct.vendor.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(itemPaginated)
|
|
17
|
+
|
|
18
|
+
const itemIds = itemPaginated?.data?.map(pageItem => pageItem["RECORDNO"])
|
|
19
|
+
const items = await Intacct.universal.read({ type: "VENDOR", keys: itemIds.join(', ') })
|
|
20
|
+
|
|
21
|
+
logger.log(items?.data?.response[0]?.operation[0]?.result[0]?.data[0]?.VENDOR)
|
|
22
|
+
|
|
23
|
+
const data = _.map(items?.data?.response[0]?.operation[0]?.result[0]?.data[0]?.VENDOR, (result) => {
|
|
24
|
+
return {
|
|
25
|
+
"external_id": _.get(result, "VENDORID.0"),
|
|
26
|
+
"code": _.get(result, "VENDORID.0"),
|
|
27
|
+
"legal_name": _.get(result, "NAME.0"),
|
|
28
|
+
"trading_name": _.get(result, "NAME.0"),
|
|
29
|
+
"bank_account_name": _.get(result, 'VENDORBANKFILEDETAILS.0.vendorbankfiledetail.0.ACCOUNTNAME.0'),
|
|
30
|
+
"bank_account_number": _.get(result, 'VENDORBANKFILEDETAILS.0.vendorbankfiledetail.0.BANKACCOUNTNUMBER.0'),
|
|
31
|
+
"bank_bsb": _.replace(_.get(result, 'VENDORBANKFILEDETAILS.0.vendorbankfiledetail.0.BSBNUMBER.0'), /-/g, ''),
|
|
32
|
+
"tax_number": _.get(result, "TAXID.0"),
|
|
33
|
+
"status": _.get(result, "STATUS.0", "ACTIVE").toUpperCase()
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const batchSize = 100
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < data.length; i += batchSize) {
|
|
40
|
+
const batch = data.slice(i, i + batchSize)
|
|
41
|
+
|
|
42
|
+
logger.log(batch)
|
|
43
|
+
|
|
44
|
+
const result = await Zudello.supplier.updateOrCreate({ data: batch })
|
|
45
|
+
|
|
46
|
+
logger.log(result)
|
|
47
|
+
logger.log(`Processed batch ${Math.ceil((i + batchSize) / batchSize)} of ${Math.ceil(data.length / batchSize)}`)
|
|
48
|
+
|
|
49
|
+
if (result.success) {
|
|
50
|
+
const lastObject = _.last(itemPaginated.data)
|
|
51
|
+
const updatedLastModified = lastObject ? lastObject.WHENMODIFIED : null
|
|
52
|
+
|
|
53
|
+
if (updatedLastModified) {
|
|
54
|
+
metadata.set('lastModified', updatedLastModified)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Introduce a delay of 3 seconds (3000 milliseconds) after each batch
|
|
59
|
+
if (i + batchSize < data.length) {
|
|
60
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Intacct.taxDetails.autoPaginationList({ pageSize: 2000, offset: 0 })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.filter(item => item.DETAILID), (result) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(result, "DETAILID"),
|
|
8
|
+
"code": _.get(result, "DETAILID"),
|
|
9
|
+
"name": _.get(result, "DESCRIPTION"),
|
|
10
|
+
"status": _.get(result, "STATUS", "ACTIVE").toUpperCase(),
|
|
11
|
+
"rate": _.get(result, "VALUE"),
|
|
12
|
+
// "tax_solution__external_id": _.get(result, "TAXSOLUTIONID")
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const batchSize = 100
|
|
17
|
+
|
|
18
|
+
for (let i = 0; i < data.length; i += batchSize) {
|
|
19
|
+
const batch = data.slice(i, i + batchSize)
|
|
20
|
+
|
|
21
|
+
logger.log(batch)
|
|
22
|
+
|
|
23
|
+
const result = await Zudello.tax.rate.updateOrCreate({ data: batch })
|
|
24
|
+
|
|
25
|
+
logger.log(result)
|
|
26
|
+
logger.log(`Processed batch ${Math.ceil((i + batchSize) / batchSize)} of ${Math.ceil(data.length / batchSize)}`)
|
|
27
|
+
|
|
28
|
+
// Introduce a delay of 3 seconds (3000 milliseconds) after each batch
|
|
29
|
+
if (i + batchSize < data.length) {
|
|
30
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Intacct.taxSolution.autoPaginationList({ pageSize: 2000, offset: 0 })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data, (result) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(result, "DETAILID"),
|
|
8
|
+
"code": _.get(result, "DETAILID"),
|
|
9
|
+
"name": _.get(result, "DESCRIPTION"),
|
|
10
|
+
"status": _.get(result, "STATUS", "ACTIVE").toUpperCase(),
|
|
11
|
+
"rate": _.get(result, "VALUE"),
|
|
12
|
+
"tax_solution": _.get(result, "TAXSOLUTIONID"),
|
|
13
|
+
"type": _.get(result, "TAXTYPE"),
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const batchSize = 100
|
|
18
|
+
|
|
19
|
+
for (let i = 0; i < data.length; i += batchSize) {
|
|
20
|
+
const batch = data.slice(i, i + batchSize)
|
|
21
|
+
|
|
22
|
+
logger.log(batch)
|
|
23
|
+
|
|
24
|
+
const result = await Zudello.tax.solution.updateOrCreate({ data: batch })
|
|
25
|
+
|
|
26
|
+
logger.log(result)
|
|
27
|
+
logger.log(`Processed batch ${Math.ceil((i + batchSize) / batchSize)} of ${Math.ceil(data.length / batchSize)}`)
|
|
28
|
+
|
|
29
|
+
// Introduce a delay of 3 seconds (3000 milliseconds) after each batch
|
|
30
|
+
if (i + batchSize < data.length) {
|
|
31
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
const lastModified = metadata.get('lastModified')
|
|
3
|
+
const fetchData = { pageSize: 2000, offset: 0, include: ['WHENMODIFIED'], orderBy: 'WHENMODIFIED' }
|
|
4
|
+
|
|
5
|
+
if (lastModified) {
|
|
6
|
+
fetchData.filters = [{
|
|
7
|
+
fName: { value: 'WHENMODIFIED' },
|
|
8
|
+
operator: { value: 'greaterthan' },
|
|
9
|
+
fValue: { value: lastModified }
|
|
10
|
+
}]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
logger.log(fetchData)
|
|
14
|
+
|
|
15
|
+
for await (const items of Intacct.uom.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "RECORDNO"),
|
|
21
|
+
"code": _.get(result, "INVUOM"),
|
|
22
|
+
"name": _.get(result, "NAME"),
|
|
23
|
+
"status": _.get(result, "STATUS", "ACTIVE").toUpperCase()
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const result = await Zudello.uom.updateOrCreate({ data })
|
|
28
|
+
if (result.success) {
|
|
29
|
+
const lastObject = _.last(items.data)
|
|
30
|
+
const updatedLastModified = lastObject ? lastObject.WHENMODIFIED : null
|
|
31
|
+
|
|
32
|
+
if (updatedLastModified) {
|
|
33
|
+
metadata.set('lastModified', updatedLastModified)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
const lastModified = metadata.get('lastModified')
|
|
3
|
+
const fetchData = { pageSize: 2000, offset: 0, include: ['WHENMODIFIED'], orderBy: 'WHENMODIFIED' }
|
|
4
|
+
|
|
5
|
+
if (lastModified) {
|
|
6
|
+
fetchData.filters = [{
|
|
7
|
+
fName: { value: 'WHENMODIFIED' },
|
|
8
|
+
operator: { value: 'greaterthan' },
|
|
9
|
+
fValue: { value: lastModified }
|
|
10
|
+
}]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
logger.log(fetchData)
|
|
14
|
+
|
|
15
|
+
for await (const items of Intacct.warehouse.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "RECORDNO"),
|
|
21
|
+
"code": _.get(result, "LOCATIONID"),
|
|
22
|
+
"name": _.get(result, "NAME"),
|
|
23
|
+
"status": _.get(result, "STATUS", "ACTIVE").toUpperCase()
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const batchSize = 100
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < data.length; i += batchSize) {
|
|
30
|
+
const batch = data.slice(i, i + batchSize)
|
|
31
|
+
|
|
32
|
+
logger.log(batch)
|
|
33
|
+
|
|
34
|
+
const result = await Zudello.warehouse.updateOrCreate({ data: batch })
|
|
35
|
+
|
|
36
|
+
logger.log(result)
|
|
37
|
+
logger.log(`Processed batch ${Math.ceil((i + batchSize) / batchSize)} of ${Math.ceil(data.length / batchSize)}`)
|
|
38
|
+
|
|
39
|
+
if (result.success) {
|
|
40
|
+
const lastObject = _.last(items.data)
|
|
41
|
+
const updatedLastModified = lastObject ? lastObject.WHENMODIFIED : null
|
|
42
|
+
|
|
43
|
+
if (updatedLastModified) {
|
|
44
|
+
metadata.set('lastModified', updatedLastModified)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Introduce a delay of 3 seconds (3000 milliseconds) after each batch
|
|
49
|
+
if (i + batchSize < data.length) {
|
|
50
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
const lastModified = metadata.get('lastModified')
|
|
3
|
+
const fetchData = { pageSize: 2000, offset: 0, include: ['WHENMODIFIED'], orderBy: 'WHENMODIFIED' }
|
|
4
|
+
|
|
5
|
+
if (lastModified) {
|
|
6
|
+
fetchData.filters = [{
|
|
7
|
+
fName: { value: 'WHENMODIFIED' },
|
|
8
|
+
operator: { value: 'greaterthan' },
|
|
9
|
+
fValue: { value: lastModified }
|
|
10
|
+
}]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
logger.log(fetchData)
|
|
14
|
+
|
|
15
|
+
for await (const items of Intacct.zone.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "ZONEID"),
|
|
21
|
+
"code": _.get(result, "ZONEID"),
|
|
22
|
+
"name": _.get(result, "ZONEDESC"),
|
|
23
|
+
"status": "ACTIVE"
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const batchSize = 100
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < data.length; i += batchSize) {
|
|
30
|
+
const batch = data.slice(i, i + batchSize)
|
|
31
|
+
|
|
32
|
+
logger.log(batch)
|
|
33
|
+
|
|
34
|
+
const result = await Zudello.zone.updateOrCreate({ data: batch })
|
|
35
|
+
|
|
36
|
+
logger.log(result)
|
|
37
|
+
logger.log(`Processed batch ${Math.ceil((i + batchSize) / batchSize)} of ${Math.ceil(data.length / batchSize)}`)
|
|
38
|
+
|
|
39
|
+
if (result.success) {
|
|
40
|
+
const lastObject = _.last(items.data)
|
|
41
|
+
const updatedLastModified = lastObject ? lastObject.WHENMODIFIED : null
|
|
42
|
+
|
|
43
|
+
if (updatedLastModified) {
|
|
44
|
+
metadata.set('lastModified', updatedLastModified)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Introduce a delay of 3 seconds (3000 milliseconds) after each batch
|
|
49
|
+
if (i + batchSize < data.length) {
|
|
50
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Nexvia.universal.autoPaginationList({ url: 'chart-of-accounts', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, "id"),
|
|
8
|
+
"code": _.get(item, "accountNo"),
|
|
9
|
+
"name": _.get(item, "accountName"),
|
|
10
|
+
"status": (_.get(item, "status") != "deleted") ? "ACTIVE" : "INACTIVE"
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
logger.log(data)
|
|
15
|
+
|
|
16
|
+
const result = await Zudello.account.updateOrCreate({ data })
|
|
17
|
+
|
|
18
|
+
logger.log(result)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Nexvia.universal.autoPaginationList({ url: 'cost-categories', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, "id"),
|
|
8
|
+
"name": _.get(item, "name"),
|
|
9
|
+
"status": (_.get(item, "status") != "deleted") ? "ACTIVE" : "INACTIVE"
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
logger.log(data)
|
|
14
|
+
|
|
15
|
+
const result = await Zudello.costCentre.updateOrCreate({ data })
|
|
16
|
+
|
|
17
|
+
logger.log(result)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Nexvia.universal.autoPaginationList({ url: 'services', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, "id"),
|
|
8
|
+
"name": _.get(item, "name"),
|
|
9
|
+
"status": (_.get(item, "status") != "deleted") ? "ACTIVE" : "INACTIVE"
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
logger.log(data)
|
|
14
|
+
|
|
15
|
+
const result = await Zudello.costType.updateOrCreate({ data })
|
|
16
|
+
|
|
17
|
+
logger.log(result)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Nexvia.universal.autoPaginationList({ url: 'currencies', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, "id"),
|
|
8
|
+
"code": _.get(item, "alpha3"),
|
|
9
|
+
"name": _.get(item, "name"),
|
|
10
|
+
"status": "ACTIVE"
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
logger.log(data)
|
|
15
|
+
|
|
16
|
+
const result = await Zudello.currency.updateOrCreate({ data })
|
|
17
|
+
|
|
18
|
+
logger.log(result)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Nexvia.universal.autoPaginationList({ url: 'departments', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, "id"),
|
|
8
|
+
"code": _.get(item, "code"),
|
|
9
|
+
"name": _.get(item, "name"),
|
|
10
|
+
"status": (_.get(item, "status") != "deleted") ? "ACTIVE" : "INACTIVE"
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
logger.log(data)
|
|
15
|
+
|
|
16
|
+
const result = await Zudello.department.updateOrCreate({ data })
|
|
17
|
+
|
|
18
|
+
logger.log(result)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Nexvia.universal.autoPaginationList({ url: 'budget-item-categories', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, "id"),
|
|
8
|
+
"name": _.get(item, "name"),
|
|
9
|
+
"status": (_.get(item, "Status") == "active") ? "ACTIVE" : "INACTIVE"
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
logger.log(data)
|
|
14
|
+
|
|
15
|
+
const result = await Zudello.warehouse.updateOrCreate({ data })
|
|
16
|
+
|
|
17
|
+
logger.log(result)
|
|
18
|
+
}
|
|
19
|
+
}
|