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,156 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
const { payload } = providedData
|
|
3
|
+
|
|
4
|
+
const model = payload?.resource?.model || null
|
|
5
|
+
const uuid = payload?.resource?.uuid || null
|
|
6
|
+
|
|
7
|
+
logger.log(payload)
|
|
8
|
+
logger.log(model)
|
|
9
|
+
logger.log(uuid)
|
|
10
|
+
|
|
11
|
+
if (model && uuid) {
|
|
12
|
+
const fetchedItem = await Zudello.fetch({ model, uuid })
|
|
13
|
+
|
|
14
|
+
logger.log(fetchedItem)
|
|
15
|
+
|
|
16
|
+
if (fetchedItem && fetchedItem.data) {
|
|
17
|
+
const data = fetchedItem.data
|
|
18
|
+
const today = moment().tz('Australia/Sydney').format('MM/DD/YYYY')
|
|
19
|
+
const todayHuman = moment().tz('Australia/Sydney').format('DD-MM-YYYY')
|
|
20
|
+
const todayZudello = moment().tz('Australia/Sydney').format('YYYY-MM-DD')
|
|
21
|
+
|
|
22
|
+
logger.log("----Begin Data----")
|
|
23
|
+
logger.log(JSON.stringify(data))
|
|
24
|
+
logger.log("----End Data----")
|
|
25
|
+
logger.log(JSON.stringify(_.get(data, "data.source_transactions")))
|
|
26
|
+
|
|
27
|
+
const milestones = _.get(data, "data.approvals.0.milestones", [])
|
|
28
|
+
let managementApprover = ''
|
|
29
|
+
|
|
30
|
+
milestones.forEach(milestone => {
|
|
31
|
+
milestone.steps.forEach(step => {
|
|
32
|
+
if (step.name === "Manager Approval") {
|
|
33
|
+
step.approver_responses.forEach(response => {
|
|
34
|
+
if (response.response === 'APPROVED') {
|
|
35
|
+
managementApprover += `${response.user.first_name} ${response.user.last_name}, `
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
managementApprover = managementApprover.trim()
|
|
43
|
+
|
|
44
|
+
const lines = _.flatten(_.map(_.get(data, "data.source_transactions"), transaction => {
|
|
45
|
+
return _.map(_.get(transaction, "lines"), line => {
|
|
46
|
+
let desc = _.get(transaction, "reference")
|
|
47
|
+
const type = _.get(transaction, "document_type")
|
|
48
|
+
|
|
49
|
+
if (type === "CLIENT_REIMBURSEMENT") {
|
|
50
|
+
desc = `${_.get(transaction, "reference")} ${_.get(transaction, "guests_names")} ${_.get(transaction, "custom.claim_number")}`
|
|
51
|
+
} else if (type === "ENTERTAINMENT") {
|
|
52
|
+
desc = `${_.get(transaction, "reference")} ${_.get(transaction, "guests_names")} ${_.get(transaction, "custom.guests_qty")}`
|
|
53
|
+
} else if (type === "EXPENSE_COPY1") {
|
|
54
|
+
desc = `${_.get(transaction, "reference")} ${_.get(transaction, "po_number")}`
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
TAXTYPE: _.get(line, "tax_rate.external_id"),
|
|
59
|
+
ACCOUNTNO: _.get(line, "account.external_id"),
|
|
60
|
+
LOCATIONID: _.get(line, "location.external_id"),
|
|
61
|
+
DEPARTMENTID: _.get(line, "department.external_id"),
|
|
62
|
+
SUBSIDIARYID: _.get(line, "subsidiary.external_id"),
|
|
63
|
+
TRXAMOUNT: _.get(line, "total_exclusive"),
|
|
64
|
+
TAXAMOUNT: _.get(line, "tax_amount"),
|
|
65
|
+
ENTRYDESCRIPTION: desc
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}))
|
|
69
|
+
|
|
70
|
+
logger.log(JSON.stringify(lines))
|
|
71
|
+
|
|
72
|
+
const lineResult = _(lines)
|
|
73
|
+
.groupBy(item => `${item.TAXTYPE}|${item.ACCOUNTNO}|${item.LOCATIONID}|${item.ENTRYDESCRIPTION}`)
|
|
74
|
+
.map(group => ({
|
|
75
|
+
TAXTYPE: _.head(group).TAXTYPE,
|
|
76
|
+
ACCOUNTNO: _.head(group).ACCOUNTNO,
|
|
77
|
+
LOCATIONID: _.head(group).LOCATIONID,
|
|
78
|
+
DEPARTMENTID: _.head(group).DEPARTMENTID,
|
|
79
|
+
SUBSIDIARYID: _.head(group).SUBSIDIARYID,
|
|
80
|
+
TRXAMOUNT: _.sumBy(group, 'TRXAMOUNT'),
|
|
81
|
+
TAXAMOUNT: _.sumBy(group, 'TAXAMOUNT'),
|
|
82
|
+
ENTRYDESCRIPTION: _.head(group).ENTRYDESCRIPTION
|
|
83
|
+
}))
|
|
84
|
+
.values()
|
|
85
|
+
.value()
|
|
86
|
+
|
|
87
|
+
logger.log(JSON.stringify(lineResult))
|
|
88
|
+
|
|
89
|
+
const docNumber = `${_.get(data, "data.employee.first_name")} ${_.get(data, "data.employee.last_name")} ${todayHuman} ${Date.now()}`
|
|
90
|
+
|
|
91
|
+
const customFields = [
|
|
92
|
+
{ field_name: 'MANAGEMENT_APPROVAL', field_value: managementApprover },
|
|
93
|
+
{ field_name: 'ZUDELLO_URL', field_value: _.get(data, "short_url") }
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
const createPayload = {
|
|
97
|
+
ENTITYID: { isMap: false, value: _.get(data, "data.locations.0.external_id") },
|
|
98
|
+
VENDORID: { isMap: false, value: _.get(data, "data.employee.external_id") },
|
|
99
|
+
WHENCREATED: { isMap: false, value: today },
|
|
100
|
+
WHENPOSTED: { isMap: false, value: today },
|
|
101
|
+
WHENDUE: { isMap: false, value: today },
|
|
102
|
+
EXCH_RATE_DATE: { isMap: false, value: today },
|
|
103
|
+
RECORDID: { isMap: false, value: docNumber },
|
|
104
|
+
DOCNUMBER: { isMap: false, value: "" },
|
|
105
|
+
DESCRIPTION: { isMap: false, value: docNumber },
|
|
106
|
+
CURRENCY: { isMap: false, value: _.get(data, "data.currency.code") },
|
|
107
|
+
BASECURR: { isMap: false, value: _.get(data, "data.currency.code") },
|
|
108
|
+
TAXSOLUTIONID: { isMap: false, value: "Australia - GST" },
|
|
109
|
+
APBILLITEMS: { isMap: true, value: `{{${JSON.stringify(lineResult)}}}` },
|
|
110
|
+
customFields: { isMap: true, value: `{{${JSON.stringify(customFields)}}}` }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
logger.log(JSON.stringify(createPayload))
|
|
114
|
+
|
|
115
|
+
const apBillResponse = await Intacct.apBill.create(createPayload)
|
|
116
|
+
|
|
117
|
+
logger.log(JSON.stringify(apBillResponse))
|
|
118
|
+
|
|
119
|
+
if (apBillResponse && apBillResponse.data) {
|
|
120
|
+
const apBillResponseData = apBillResponse.data
|
|
121
|
+
|
|
122
|
+
if (_.get(apBillResponseData, "data.0.operation.0.result.0.status.0") === "failure") {
|
|
123
|
+
logger.log(_.get(apBillResponseData, "data.0.operation.0.result.0.errormessage.0.error.0.description2.0"))
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const zudelloUpdateResponse = await Zudello.update({
|
|
128
|
+
model,
|
|
129
|
+
data: {
|
|
130
|
+
module: "EXPENSES",
|
|
131
|
+
submodule: "CLAIM",
|
|
132
|
+
uuid,
|
|
133
|
+
document_number: docNumber,
|
|
134
|
+
date_issued: todayZudello,
|
|
135
|
+
status: "CLOSED",
|
|
136
|
+
external_id: _.get(apBillResponseData, "data.0.operation.0.result.0.data.0.apbill.0.RECORDNO.0")
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
logger.log(JSON.stringify(zudelloUpdateResponse))
|
|
141
|
+
|
|
142
|
+
/*_.each(_.get(data, "data.source_transactions"), async (expense) => {
|
|
143
|
+
const updateResponse = await Zudello.update({
|
|
144
|
+
model,
|
|
145
|
+
data: {
|
|
146
|
+
uuid: _.get(expense, "uuid"),
|
|
147
|
+
status: "COMPLETE"
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
logger.log(updateResponse)
|
|
152
|
+
})*/
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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.item.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "ITEMID"),
|
|
21
|
+
"sku": _.get(result, "ITEMID"),
|
|
22
|
+
"barcode": _.get(result, "UPC"),
|
|
23
|
+
"country": _.get(result, "PRIMARYCOUNTRYOFORIGIN"),
|
|
24
|
+
"item_category": _.get(result, "CATEGORY"),
|
|
25
|
+
"item_type": _.get(result, "ITEMTYPE"),
|
|
26
|
+
"description": _.get(result, "NAME"),
|
|
27
|
+
"purchase_price": _.get(result, "STANDARD_COST"),
|
|
28
|
+
"short_description": _.get(result, "EXTENDED_DESCRIPTION"),
|
|
29
|
+
"subsidiaries": _.get(result, "MEGAENTITYID"),
|
|
30
|
+
"tax_rate": _.get(result, "TAXGROUP.NAME"),
|
|
31
|
+
// "unit_of_meaasure": _.get(result, "BASEUOM"),
|
|
32
|
+
// "warehouse": _.get(result, "DEFAULT_WAREHOUSE"),
|
|
33
|
+
"status": _.get(result, "STATUS", "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.item.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(items.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,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.productLine.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "PRODUCTLINEID"),
|
|
21
|
+
"code": _.get(result, "PRODUCTLINEID"),
|
|
22
|
+
"name": _.get(result, "DESCRIPTION"),
|
|
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.itemCategory.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.itemGroup.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.itemGroup.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.location.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "LOCATIONID"),
|
|
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.location.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,56 @@
|
|
|
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.apTerm.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, "ANEM"),
|
|
22
|
+
"name": _.get(result, "DESCRIPTION"),
|
|
23
|
+
"type": "DAYS_AFTER_DATE",
|
|
24
|
+
"unit": _.get(result, "DUEDATE"),
|
|
25
|
+
"status": _.get(result, "STATUS", "ACTIVE").toUpperCase()
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const batchSize = 100
|
|
30
|
+
|
|
31
|
+
for (let i = 0; i < data.length; i += batchSize) {
|
|
32
|
+
const batch = data.slice(i, i + batchSize)
|
|
33
|
+
|
|
34
|
+
logger.log(batch)
|
|
35
|
+
|
|
36
|
+
const result = await Zudello.paymentTerm.updateOrCreate({ data: batch })
|
|
37
|
+
|
|
38
|
+
logger.log(result)
|
|
39
|
+
logger.log(`Processed batch ${Math.ceil((i + batchSize) / batchSize)} of ${Math.ceil(data.length / batchSize)}`)
|
|
40
|
+
|
|
41
|
+
if (result.success) {
|
|
42
|
+
const lastObject = _.last(items.data)
|
|
43
|
+
const updatedLastModified = lastObject ? lastObject.WHENMODIFIED : null
|
|
44
|
+
|
|
45
|
+
if (updatedLastModified) {
|
|
46
|
+
metadata.set('lastModified', updatedLastModified)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Introduce a delay of 3 seconds (3000 milliseconds) after each batch
|
|
51
|
+
if (i + batchSize < data.length) {
|
|
52
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -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.project.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "PROJECTID"),
|
|
21
|
+
"code": _.get(result, "PROJECTID"),
|
|
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.project.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.projectGroup.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.projectGroup.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,40 @@
|
|
|
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.task.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "TASKID"),
|
|
21
|
+
"code": _.get(result, "TASKID"),
|
|
22
|
+
"name": _.get(result, "NAME"),
|
|
23
|
+
"status": _.get(result, "STATUS", "ACTIVE").toUpperCase()
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const result = await Zudello.projectTask.updateOrCreate({ data })
|
|
28
|
+
|
|
29
|
+
logger.log(result)
|
|
30
|
+
|
|
31
|
+
if (result.success) {
|
|
32
|
+
const lastObject = _.last(items.data)
|
|
33
|
+
const updatedLastModified = lastObject ? lastObject.WHENMODIFIED : null
|
|
34
|
+
|
|
35
|
+
if (updatedLastModified) {
|
|
36
|
+
metadata.set('lastModified', updatedLastModified)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -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.entity.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (result) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(result, "LOCATIONID"),
|
|
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.subsidiary.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
|
+
}
|