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,30 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Dear.universal.autoPaginationList({ url: 'product', method: 'GET', qs: {
|
|
3
|
+
"IncludeAttachments": false,
|
|
4
|
+
"IncludeBOM": false,
|
|
5
|
+
"IncludeDeprecated": false,
|
|
6
|
+
"IncludeMovements": false,
|
|
7
|
+
"IncludeReorderLevels": false,
|
|
8
|
+
"IncludeSuppliers": true,
|
|
9
|
+
"ModifiedSince": "2024-07-30"
|
|
10
|
+
}
|
|
11
|
+
})) {
|
|
12
|
+
logger.log(items)
|
|
13
|
+
|
|
14
|
+
const data = _.map(items.data.Products, (item) => {
|
|
15
|
+
return {
|
|
16
|
+
"external_id": _.get(item, "ID"),
|
|
17
|
+
"sku": _.get(item, "SKU"),
|
|
18
|
+
"description": _.get(item, "Name"),
|
|
19
|
+
"short_description": _.get(item, "Name"),
|
|
20
|
+
"status": (_.get(item, "Status") == "Active") ? "ACTIVE" : "INACTIVE"
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
logger.log(data)
|
|
25
|
+
|
|
26
|
+
const result = await Zudello.item.updateOrCreate({ data })
|
|
27
|
+
|
|
28
|
+
logger.log(result)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Dear.universal.autoPaginationList({ url: 'ref/location', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.LocationList, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, "ID"),
|
|
8
|
+
"name": _.get(item, "Name"),
|
|
9
|
+
"status": (_.get(item, "IsDeprecated")) ? "INACTIVE" : "ACTIVE"
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
logger.log(data)
|
|
14
|
+
|
|
15
|
+
const result = await Zudello.location.updateOrCreate({ data })
|
|
16
|
+
|
|
17
|
+
logger.log(result)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
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?.data || null
|
|
18
|
+
|
|
19
|
+
if (!data) {
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
logger.log(data)
|
|
24
|
+
|
|
25
|
+
const lines = _.get(data, "lines") ?? []
|
|
26
|
+
|
|
27
|
+
const createPayload = {
|
|
28
|
+
"CustomerID": data.customer?.external_id,
|
|
29
|
+
"Customer": data.customer?.legal_name,
|
|
30
|
+
"CurrencyRate": "1",
|
|
31
|
+
"Location": lines[0]?.location?.name,
|
|
32
|
+
"SkipQuote": "true"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
logger.log(createPayload)
|
|
36
|
+
|
|
37
|
+
const createResponse = await Dear.universal.request({ method: 'POST', url: 'sale', body: createPayload })
|
|
38
|
+
|
|
39
|
+
logger.log(createResponse)
|
|
40
|
+
|
|
41
|
+
if (!createResponse || !createResponse.success || !createResponse.data) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const mapItemLine = line => ({
|
|
46
|
+
"ProductID": line.item?.external_id,
|
|
47
|
+
"SKU": line.item?.sku,
|
|
48
|
+
"Name": line.description,
|
|
49
|
+
"Price": line.unit_price,
|
|
50
|
+
"Total": line.total,
|
|
51
|
+
"Quantity": `${line.quantity}.0000`,
|
|
52
|
+
// "Tax": line.tax_amount,
|
|
53
|
+
"TaxRule": "GST on Income",
|
|
54
|
+
"Comment": line.note,
|
|
55
|
+
// "DropShip": false,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const itemLines = lines.map(mapItemLine)
|
|
59
|
+
|
|
60
|
+
const mapLCLine = line => ({
|
|
61
|
+
"Description": line.description,
|
|
62
|
+
"Price": line.unit_price,
|
|
63
|
+
"Quantity": line.quantity,
|
|
64
|
+
"Tax": line.tax_amount,
|
|
65
|
+
"Total": line.total,
|
|
66
|
+
"TaxRule": "Tax on Sales",
|
|
67
|
+
"Comment": ""
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const lcLines = lines.map(mapLCLine)
|
|
71
|
+
|
|
72
|
+
const createOrderPyload = {
|
|
73
|
+
"SaleID": createResponse.data.ID,
|
|
74
|
+
"Status": "DRAFT",
|
|
75
|
+
"Memo": data.reference,
|
|
76
|
+
"Lines": itemLines,
|
|
77
|
+
"CombineAdditionalCharges": false,
|
|
78
|
+
// "AutoPickPackShipMode": "NOPICK",
|
|
79
|
+
// "AdditionalCharges": lcLines,
|
|
80
|
+
// "TotalBeforeTax": data.subtotal,
|
|
81
|
+
// "Tax": data.tax,
|
|
82
|
+
// "Total": data.total + data.tax
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
logger.log(createOrderPyload)
|
|
86
|
+
|
|
87
|
+
const createOrderResponse = await Dear.universal.request({ method: 'POST', url: 'sale/order', body: createOrderPyload })
|
|
88
|
+
|
|
89
|
+
logger.log(createOrderResponse)
|
|
90
|
+
|
|
91
|
+
let status = "COMPLETE"
|
|
92
|
+
|
|
93
|
+
if (!createOrderResponse || !createOrderResponse.success || !createOrderResponse.data) {
|
|
94
|
+
status = "UNABLE"
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const resultPayload = {
|
|
98
|
+
model,
|
|
99
|
+
module: data.module,
|
|
100
|
+
submodule: data.submodule,
|
|
101
|
+
data: {
|
|
102
|
+
uuid,
|
|
103
|
+
status,
|
|
104
|
+
external_id: createOrderResponse.data.SaleID,
|
|
105
|
+
log_messages: status === "UNABLE" ? {
|
|
106
|
+
replace: true,
|
|
107
|
+
items: [{
|
|
108
|
+
create: true,
|
|
109
|
+
data: {
|
|
110
|
+
status_code: 404,
|
|
111
|
+
body: JSON.stringify({ message: 'Unable to create Sale/Order.' }),
|
|
112
|
+
parse_as: "SENTENCE_ERROR"
|
|
113
|
+
}
|
|
114
|
+
}]
|
|
115
|
+
} : null
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
logger.log(resultPayload)
|
|
120
|
+
|
|
121
|
+
const zudelloUpdateResponse = await Zudello.update(resultPayload)
|
|
122
|
+
|
|
123
|
+
logger.log(zudelloUpdateResponse)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Dear.universal.autoPaginationList({ url: 'supplier', method: 'GET', qs: {
|
|
3
|
+
"ModifiedSince": "2024-07-30"
|
|
4
|
+
} })) {
|
|
5
|
+
logger.log(items)
|
|
6
|
+
|
|
7
|
+
const data = _.map(items.data.SupplierList, (item) => {
|
|
8
|
+
return {
|
|
9
|
+
"external_id": _.get(item, "ID"),
|
|
10
|
+
"legal_name": _.get(item, "Name"),
|
|
11
|
+
"trading_name": _.get(item, "Name"),
|
|
12
|
+
"tax_number": _.get(item, "TaxNumber"),
|
|
13
|
+
"status": (_.get(item, "Status") == "Active") ? "ACTIVE" : "INACTIVE"
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
logger.log(data)
|
|
18
|
+
|
|
19
|
+
const result = await Zudello.supplier.updateOrCreate({ data })
|
|
20
|
+
|
|
21
|
+
logger.log(result)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of Dear.universal.autoPaginationList({ url: 'ref/tax', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.TaxRuleList, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, "ID"),
|
|
8
|
+
"name": _.get(item, "Name"),
|
|
9
|
+
"status": (_.get(item, "IsActive")) ? "ACTIVE" : "INACTIVE"
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
logger.log(data)
|
|
14
|
+
|
|
15
|
+
const result = await Zudello.tax.rate.updateOrCreate({ data })
|
|
16
|
+
|
|
17
|
+
logger.log(result)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of FO.universal.autoPaginationList({ url: 'MainAccounts', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.value, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, 'MainAccountId'),
|
|
8
|
+
"code": _.get(item, 'MainAccountId'),
|
|
9
|
+
"name": _.get(item, 'Name'),
|
|
10
|
+
"status": "ACTIVE"
|
|
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,20 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of FO.universal.autoPaginationList({ url: 'CostCenters', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.value, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, 'OperatingUnitNumber'),
|
|
8
|
+
"code": _.get(item, 'OperatingUnitNumber'),
|
|
9
|
+
"name": _.get(item, 'Name'),
|
|
10
|
+
"status": "ACTIVE"
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
logger.log(data)
|
|
15
|
+
|
|
16
|
+
const result = await Zudello.costCentre.updateOrCreate({ data })
|
|
17
|
+
|
|
18
|
+
logger.log(result)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of FO.universal.autoPaginationList({ url: 'Departments', method: 'GET'})) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.value, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, 'OperatingUnitNumber'),
|
|
8
|
+
"code": _.get(item, 'OperatingUnitNumber'),
|
|
9
|
+
"name": _.get(item, 'Name'),
|
|
10
|
+
"status": "ACTIVE"
|
|
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,21 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of FO.universal.autoPaginationList({ url: 'RetailEcoResProduct', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.value, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, 'DisplayProductNumber'),
|
|
8
|
+
"sku": _.get(item, 'DisplayProductNumber'),
|
|
9
|
+
"short_description": _.get(item, 'SearchName'),
|
|
10
|
+
"description": _.get(item, 'SearchName'),
|
|
11
|
+
"status": "ACTIVE"
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
logger.log(data)
|
|
16
|
+
|
|
17
|
+
const result = await Zudello.item.updateOrCreate({ data })
|
|
18
|
+
|
|
19
|
+
logger.log(result)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of FO.universal.autoPaginationList({ url: 'BusinessUnits', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.value, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, 'OperatingUnitNumber'),
|
|
8
|
+
"code": _.get(item, 'OperatingUnitNumber'),
|
|
9
|
+
"name": _.get(item, 'Name'),
|
|
10
|
+
"status": "ACTIVE"
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
logger.log(data)
|
|
15
|
+
|
|
16
|
+
const result = await Zudello.location.updateOrCreate({ data })
|
|
17
|
+
|
|
18
|
+
logger.log(result)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of FO.universal.autoPaginationList({ url: 'Projects', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.value, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, 'ProjectID'),
|
|
8
|
+
"name": _.get(item, 'Description'),
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
logger.log(data)
|
|
13
|
+
|
|
14
|
+
const result = await Zudello.project.updateOrCreate({ data })
|
|
15
|
+
|
|
16
|
+
logger.log(result)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of FO.universal.autoPaginationList({ url: 'LegalEntities', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.value, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, 'LegalEntityId'),
|
|
8
|
+
"code": _.get(item, 'LegalEntityId'),
|
|
9
|
+
"name": _.get(item, 'Name'),
|
|
10
|
+
"status": "ACTIVE"
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
logger.log(data)
|
|
15
|
+
|
|
16
|
+
const result = await Zudello.subsidiary.updateOrCreate({ data })
|
|
17
|
+
|
|
18
|
+
logger.log(result)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of FO.universal.autoPaginationList({ url: 'VendorsV2', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.value, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, 'VendorAccountNumber'),
|
|
8
|
+
"code": _.get(item, 'VendorAccountNumber'),
|
|
9
|
+
"legal_name": _.get(item, "VendorOrganizationName"),
|
|
10
|
+
"trading_name": _.get(item, "VendorOrganizationName"),
|
|
11
|
+
// "tradingName": _.get(item, 'VendorSearchName'),
|
|
12
|
+
"tax_number": _.get(item, 'TaxExemptNumber'),
|
|
13
|
+
"status": "ACTIVE"
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
logger.log(data)
|
|
18
|
+
|
|
19
|
+
const result = await Zudello.supplier.updateOrCreate({ data })
|
|
20
|
+
|
|
21
|
+
logger.log(result)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
for await (const items of FO.universal.autoPaginationList({ url: 'data/TaxItemGroups', method: 'GET' })) {
|
|
3
|
+
logger.log(items)
|
|
4
|
+
|
|
5
|
+
const data = _.map(items.data.value, (item) => {
|
|
6
|
+
return {
|
|
7
|
+
"external_id": _.get(item, 'TaxCodeId'),
|
|
8
|
+
"code": _.get(item, 'TaxCodeId'),
|
|
9
|
+
"name": _.get(item, 'Description'),
|
|
10
|
+
"status": "ACTIVE"
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
logger.log(data)
|
|
15
|
+
|
|
16
|
+
const result = await Zudello.tax.rate.updateOrCreate({ data })
|
|
17
|
+
|
|
18
|
+
logger.log(result)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const handler = async (providedData) => {
|
|
2
|
+
const lastModified = metadata.get('lastModified')
|
|
3
|
+
const fetchData = { pageSize: 2000, offset: 0, 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.account.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (item) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(item, "ACCOUNTNO"),
|
|
21
|
+
"code": _.get(item, "ACCOUNTNO"),
|
|
22
|
+
"name": _.get(item, "TITLE"),
|
|
23
|
+
"status": _.get(item, "STATUS", "ACTIVE").toUpperCase(),
|
|
24
|
+
"account_group": null,
|
|
25
|
+
"account_type": _.get(item, "ACCOUNTTYPE"),
|
|
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.account.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.accountGroup.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items.data)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (item) => {
|
|
19
|
+
return {
|
|
20
|
+
"external_id": _.get(item, "RECORDNO"),
|
|
21
|
+
"code": _.get(item, "RECORDNO"),
|
|
22
|
+
"name": _.get(item, "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.accountGroup.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,67 @@
|
|
|
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.accountingPeriod.autoPaginationList(fetchData)) {
|
|
16
|
+
logger.log(items)
|
|
17
|
+
|
|
18
|
+
const data = _.map(items.data, (item) => {
|
|
19
|
+
const itemData = {
|
|
20
|
+
"external_id": _.get(item, "RECORDNO"),
|
|
21
|
+
"code": _.get(item, "RECORDNO"),
|
|
22
|
+
"name": _.get(item, "NAME"),
|
|
23
|
+
"status": _.get(item, "STATUS", "ACTIVE").toUpperCase()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const startDate = _.get(item, "START_DATE")
|
|
27
|
+
const endDate = _.get(item, "END_DATE")
|
|
28
|
+
|
|
29
|
+
if (startDate) {
|
|
30
|
+
itemData["start_date"] = moment(startDate).format("YYYY-MM-DD")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (endDate) {
|
|
34
|
+
itemData["end_date"] = moment(endDate).format("YYYY-MM-DD")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return itemData
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const batchSize = 100
|
|
41
|
+
|
|
42
|
+
for (let i = 0; i < data.length; i += batchSize) {
|
|
43
|
+
const batch = data.slice(i, i + batchSize)
|
|
44
|
+
|
|
45
|
+
logger.log(batch)
|
|
46
|
+
|
|
47
|
+
const result = await Zudello.accountingPeriod.updateOrCreate({ data: batch })
|
|
48
|
+
|
|
49
|
+
logger.log(result)
|
|
50
|
+
logger.log(`Processed batch ${Math.ceil((i + batchSize) / batchSize)} of ${Math.ceil(data.length / batchSize)}`)
|
|
51
|
+
|
|
52
|
+
if (result.success) {
|
|
53
|
+
const lastObject = _.last(items.data)
|
|
54
|
+
const updatedLastModified = lastObject ? lastObject.WHENMODIFIED : null
|
|
55
|
+
|
|
56
|
+
if (updatedLastModified) {
|
|
57
|
+
metadata.set('lastModified', updatedLastModified)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Introduce a delay of 3 seconds (3000 milliseconds) after each batch
|
|
62
|
+
if (i + batchSize < data.length) {
|
|
63
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|