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.
Files changed (201) hide show
  1. package/README.md +1 -0
  2. package/package.json +23 -0
  3. package/src/index.js +62 -0
  4. package/src/integrations/samples/bc-zudello/account.js +40 -0
  5. package/src/integrations/samples/bc-zudello/accountingPeriod.js +52 -0
  6. package/src/integrations/samples/bc-zudello/currency.js +42 -0
  7. package/src/integrations/samples/bc-zudello/customer.js +45 -0
  8. package/src/integrations/samples/bc-zudello/dimension.js +85 -0
  9. package/src/integrations/samples/bc-zudello/employee.js +38 -0
  10. package/src/integrations/samples/bc-zudello/fixedAsset.js +48 -0
  11. package/src/integrations/samples/bc-zudello/item.js +45 -0
  12. package/src/integrations/samples/bc-zudello/itemCategory.js +37 -0
  13. package/src/integrations/samples/bc-zudello/location.js +37 -0
  14. package/src/integrations/samples/bc-zudello/paymentMethod.js +38 -0
  15. package/src/integrations/samples/bc-zudello/paymentTerm.js +41 -0
  16. package/src/integrations/samples/bc-zudello/project.js +38 -0
  17. package/src/integrations/samples/bc-zudello/purchaseCredit.js +109 -0
  18. package/src/integrations/samples/bc-zudello/purchaseInvoice.js +138 -0
  19. package/src/integrations/samples/bc-zudello/purchaseOrder.js +150 -0
  20. package/src/integrations/samples/bc-zudello/purchaseOrderFetch.js +100 -0
  21. package/src/integrations/samples/bc-zudello/supplier.js +40 -0
  22. package/src/integrations/samples/bc-zudello/taxRate.js +39 -0
  23. package/src/integrations/samples/bc-zudello/uom.js +42 -0
  24. package/src/integrations/samples/dear-zudello/account.js +20 -0
  25. package/src/integrations/samples/dear-zudello/customer.js +23 -0
  26. package/src/integrations/samples/dear-zudello/item.js +30 -0
  27. package/src/integrations/samples/dear-zudello/location.js +19 -0
  28. package/src/integrations/samples/dear-zudello/salesOrder.js +126 -0
  29. package/src/integrations/samples/dear-zudello/supplier.js +23 -0
  30. package/src/integrations/samples/dear-zudello/taxRate.js +19 -0
  31. package/src/integrations/samples/fo-zudello/account.js +20 -0
  32. package/src/integrations/samples/fo-zudello/costCentre.js +20 -0
  33. package/src/integrations/samples/fo-zudello/department.js +20 -0
  34. package/src/integrations/samples/fo-zudello/item.js +21 -0
  35. package/src/integrations/samples/fo-zudello/location.js +20 -0
  36. package/src/integrations/samples/fo-zudello/project.js +18 -0
  37. package/src/integrations/samples/fo-zudello/subsidiary.js +20 -0
  38. package/src/integrations/samples/fo-zudello/supplier.js +23 -0
  39. package/src/integrations/samples/fo-zudello/taxRate.js +20 -0
  40. package/src/integrations/samples/intacct-zudello/account.js +56 -0
  41. package/src/integrations/samples/intacct-zudello/accountGroup.js +54 -0
  42. package/src/integrations/samples/intacct-zudello/accountingPeriod.js +67 -0
  43. package/src/integrations/samples/intacct-zudello/apBill.js +146 -0
  44. package/src/integrations/samples/intacct-zudello/apBillFetch.js +195 -0
  45. package/src/integrations/samples/intacct-zudello/costCentre.js +54 -0
  46. package/src/integrations/samples/intacct-zudello/costType.js +54 -0
  47. package/src/integrations/samples/intacct-zudello/customerCategory.js +54 -0
  48. package/src/integrations/samples/intacct-zudello/customerGroup.js +54 -0
  49. package/src/integrations/samples/intacct-zudello/department.js +54 -0
  50. package/src/integrations/samples/intacct-zudello/employee.js +51 -0
  51. package/src/integrations/samples/intacct-zudello/expense-create.js +156 -0
  52. package/src/integrations/samples/intacct-zudello/item.js +64 -0
  53. package/src/integrations/samples/intacct-zudello/itemCategory.js +54 -0
  54. package/src/integrations/samples/intacct-zudello/itemGroup.js +54 -0
  55. package/src/integrations/samples/intacct-zudello/location.js +54 -0
  56. package/src/integrations/samples/intacct-zudello/paymentTerm.js +56 -0
  57. package/src/integrations/samples/intacct-zudello/project.js +54 -0
  58. package/src/integrations/samples/intacct-zudello/projectGroup.js +54 -0
  59. package/src/integrations/samples/intacct-zudello/projectTask.js +40 -0
  60. package/src/integrations/samples/intacct-zudello/subsidiary.js +54 -0
  61. package/src/integrations/samples/intacct-zudello/supplier.js +168 -0
  62. package/src/integrations/samples/intacct-zudello/supplierCategory.js +54 -0
  63. package/src/integrations/samples/intacct-zudello/supplierGroup.js +54 -0
  64. package/src/integrations/samples/intacct-zudello/supplierV2.js +64 -0
  65. package/src/integrations/samples/intacct-zudello/taxRate.js +34 -0
  66. package/src/integrations/samples/intacct-zudello/taxSolution.js +35 -0
  67. package/src/integrations/samples/intacct-zudello/uom.js +37 -0
  68. package/src/integrations/samples/intacct-zudello/warehouse.js +54 -0
  69. package/src/integrations/samples/intacct-zudello/zone.js +54 -0
  70. package/src/integrations/samples/nexvia-zudello/account.js +20 -0
  71. package/src/integrations/samples/nexvia-zudello/costCentre.js +19 -0
  72. package/src/integrations/samples/nexvia-zudello/costType.js +19 -0
  73. package/src/integrations/samples/nexvia-zudello/currency.js +20 -0
  74. package/src/integrations/samples/nexvia-zudello/department.js +20 -0
  75. package/src/integrations/samples/nexvia-zudello/itemCategory.js +19 -0
  76. package/src/integrations/samples/nexvia-zudello/location.js +20 -0
  77. package/src/integrations/samples/nexvia-zudello/project.js +20 -0
  78. package/src/integrations/samples/nexvia-zudello/supplier.js +21 -0
  79. package/src/integrations/samples/nexvia-zudello/taxRate.js +21 -0
  80. package/src/integrations/samples/nexvia-zudello/uom.js +19 -0
  81. package/src/integrations/samples/nexvia-zudello/zone.js +20 -0
  82. package/src/integrations/samples/zenoti-zudello/location.js +20 -0
  83. package/src/integrations/samples/zenoti-zudello/product.js +32 -0
  84. package/src/integrations/samples/zenoti-zudello/purchaseOrder.js +193 -0
  85. package/src/sdk/Auth.js +42 -0
  86. package/src/sdk/Base.js +118 -0
  87. package/src/sdk/BusinessCentral.js +31 -0
  88. package/src/sdk/Dear.js +31 -0
  89. package/src/sdk/Fo.js +31 -0
  90. package/src/sdk/Intacct.js +103 -0
  91. package/src/sdk/JobReady.js +31 -0
  92. package/src/sdk/MYOBAcumatica.js +33 -0
  93. package/src/sdk/Netsuite.js +31 -0
  94. package/src/sdk/NetsuiteSOAP.js +92 -0
  95. package/src/sdk/Nexvia.js +31 -0
  96. package/src/sdk/RetailExpress.js +31 -0
  97. package/src/sdk/Sybiz.js +31 -0
  98. package/src/sdk/Zenoti.js +31 -0
  99. package/src/sdk/Zudello.js +206 -0
  100. package/src/sdk/submodules/bc/Universal.js +109 -0
  101. package/src/sdk/submodules/dear/Universal.js +110 -0
  102. package/src/sdk/submodules/fo/Universal.js +111 -0
  103. package/src/sdk/submodules/intacct/Account.js +31 -0
  104. package/src/sdk/submodules/intacct/AccountGroup.js +31 -0
  105. package/src/sdk/submodules/intacct/AccountingPeriod.js +31 -0
  106. package/src/sdk/submodules/intacct/ApAdjustment.js +35 -0
  107. package/src/sdk/submodules/intacct/ApBill.js +52 -0
  108. package/src/sdk/submodules/intacct/ApTerm.js +31 -0
  109. package/src/sdk/submodules/intacct/ArAdjustment.js +35 -0
  110. package/src/sdk/submodules/intacct/ArInvoice.js +35 -0
  111. package/src/sdk/submodules/intacct/ArTerm.js +31 -0
  112. package/src/sdk/submodules/intacct/Budget.js +31 -0
  113. package/src/sdk/submodules/intacct/Class.js +31 -0
  114. package/src/sdk/submodules/intacct/CostType.js +31 -0
  115. package/src/sdk/submodules/intacct/Customer.js +31 -0
  116. package/src/sdk/submodules/intacct/CustomerGroup.js +31 -0
  117. package/src/sdk/submodules/intacct/CustomerType.js +31 -0
  118. package/src/sdk/submodules/intacct/Department.js +31 -0
  119. package/src/sdk/submodules/intacct/Employee.js +31 -0
  120. package/src/sdk/submodules/intacct/Entity.js +31 -0
  121. package/src/sdk/submodules/intacct/File.js +26 -0
  122. package/src/sdk/submodules/intacct/Item.js +31 -0
  123. package/src/sdk/submodules/intacct/ItemGroup.js +31 -0
  124. package/src/sdk/submodules/intacct/Location.js +31 -0
  125. package/src/sdk/submodules/intacct/PoDocument.js +52 -0
  126. package/src/sdk/submodules/intacct/ProductLine.js +31 -0
  127. package/src/sdk/submodules/intacct/Project.js +31 -0
  128. package/src/sdk/submodules/intacct/ProjectGroup.js +31 -0
  129. package/src/sdk/submodules/intacct/Task.js +31 -0
  130. package/src/sdk/submodules/intacct/TaxDetail.js +31 -0
  131. package/src/sdk/submodules/intacct/TaxGroups.js +31 -0
  132. package/src/sdk/submodules/intacct/TaxSolution.js +31 -0
  133. package/src/sdk/submodules/intacct/Universal.js +139 -0
  134. package/src/sdk/submodules/intacct/Uom.js +31 -0
  135. package/src/sdk/submodules/intacct/Vendor.js +31 -0
  136. package/src/sdk/submodules/intacct/VendorGroup.js +31 -0
  137. package/src/sdk/submodules/intacct/VendorTypes.js +31 -0
  138. package/src/sdk/submodules/intacct/Warehouse.js +31 -0
  139. package/src/sdk/submodules/intacct/Zone.js +31 -0
  140. package/src/sdk/submodules/intacct/apAdjustment/Item.js +31 -0
  141. package/src/sdk/submodules/intacct/apBill/Item.js +31 -0
  142. package/src/sdk/submodules/intacct/arAdjustment/Item.js +31 -0
  143. package/src/sdk/submodules/intacct/arInvoice/Item.js +31 -0
  144. package/src/sdk/submodules/intacct/poDocument/Item.js +31 -0
  145. package/src/sdk/submodules/jobready/Universal.js +107 -0
  146. package/src/sdk/submodules/myobAcumatica/OData.js +109 -0
  147. package/src/sdk/submodules/myobAcumatica/Universal.js +109 -0
  148. package/src/sdk/submodules/netsuite/Universal.js +97 -0
  149. package/src/sdk/submodules/netsuite-soap/PurchaseOrder.js +39 -0
  150. package/src/sdk/submodules/netsuite-soap/Receipt.js +39 -0
  151. package/src/sdk/submodules/netsuite-soap/Universal.js +124 -0
  152. package/src/sdk/submodules/netsuite-soap/UniversalTransaction.js +138 -0
  153. package/src/sdk/submodules/netsuite-soap/VendorBill.js +41 -0
  154. package/src/sdk/submodules/netsuite-soap/VendorCredit.js +39 -0
  155. package/src/sdk/submodules/nexvia/Universal.js +108 -0
  156. package/src/sdk/submodules/retailExpress/Universal.js +107 -0
  157. package/src/sdk/submodules/sybiz/Universal.js +108 -0
  158. package/src/sdk/submodules/zenoti/Universal.js +110 -0
  159. package/src/sdk/submodules/zudello/Account.js +63 -0
  160. package/src/sdk/submodules/zudello/AccountGroup.js +63 -0
  161. package/src/sdk/submodules/zudello/AccountingPeriod.js +63 -0
  162. package/src/sdk/submodules/zudello/CostCentre.js +63 -0
  163. package/src/sdk/submodules/zudello/CostType.js +63 -0
  164. package/src/sdk/submodules/zudello/Currency.js +63 -0
  165. package/src/sdk/submodules/zudello/Customer.js +63 -0
  166. package/src/sdk/submodules/zudello/CustomerCategory.js +63 -0
  167. package/src/sdk/submodules/zudello/CustomerGroup.js +63 -0
  168. package/src/sdk/submodules/zudello/Department.js +63 -0
  169. package/src/sdk/submodules/zudello/Employee.js +63 -0
  170. package/src/sdk/submodules/zudello/FixedAsset.js +63 -0
  171. package/src/sdk/submodules/zudello/Item.js +63 -0
  172. package/src/sdk/submodules/zudello/ItemCategory.js +63 -0
  173. package/src/sdk/submodules/zudello/ItemGroup.js +63 -0
  174. package/src/sdk/submodules/zudello/Location.js +63 -0
  175. package/src/sdk/submodules/zudello/PaymentMethod.js +63 -0
  176. package/src/sdk/submodules/zudello/PaymentTerm.js +63 -0
  177. package/src/sdk/submodules/zudello/Project.js +63 -0
  178. package/src/sdk/submodules/zudello/ProjectGroup.js +63 -0
  179. package/src/sdk/submodules/zudello/ProjectTask.js +63 -0
  180. package/src/sdk/submodules/zudello/PurchaseOrder.js +63 -0
  181. package/src/sdk/submodules/zudello/Subsidiary.js +63 -0
  182. package/src/sdk/submodules/zudello/Supplier.js +63 -0
  183. package/src/sdk/submodules/zudello/SupplierCategory.js +63 -0
  184. package/src/sdk/submodules/zudello/SupplierGroup.js +63 -0
  185. package/src/sdk/submodules/zudello/Universal.js +31 -0
  186. package/src/sdk/submodules/zudello/Uom.js +63 -0
  187. package/src/sdk/submodules/zudello/Warehouse.js +63 -0
  188. package/src/sdk/submodules/zudello/Zone.js +63 -0
  189. package/src/sdk/submodules/zudello/tax/Rate.js +63 -0
  190. package/src/sdk/submodules/zudello/tax/Solution.js +63 -0
  191. package/src/utils/apiInstance.js +198 -0
  192. package/src/utils/config.js +18 -0
  193. package/src/utils/logger.js +122 -0
  194. package/src/utils/metadata.js +102 -0
  195. package/src/utils/miscHelper.js +24 -0
  196. package/src/utils/modelHelper.js +140 -0
  197. package/src/utils/properties.js +32 -0
  198. package/src/utils/responseHandler.js +28 -0
  199. package/src/utils/s3Client.js +128 -0
  200. package/src/utils/tags.js +32 -0
  201. package/src/utils/validator.js +73 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # integration-sdk
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "zudello-integration-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Zudello Integrations SDK",
5
+ "main": "./src/index.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/zudello/integration-sdk.git"
9
+ },
10
+ "files": [
11
+ "src"
12
+ ],
13
+ "dependencies": {
14
+ "@aws-sdk/client-s3": "^3.658.0",
15
+ "axios": "^1.6.7",
16
+ "dotenv": "^16.4.5",
17
+ "lodash": "^4.17.21",
18
+ "moment-timezone": "^0.5.45",
19
+ "perf_hooks": "^0.0.1",
20
+ "standard": "^17.1.0"
21
+ },
22
+ "license": "MIT"
23
+ }
package/src/index.js ADDED
@@ -0,0 +1,62 @@
1
+ 'use strict'
2
+
3
+ const Auth = require('./sdk/Auth')
4
+ const ZudelloSDK = require('./sdk/Zudello')
5
+ const NetsuiteSDK = require('./sdk/Netsuite')
6
+ const NetsuiteSoapSDK = require('./sdk/NetsuiteSOAP')
7
+ const IntacctSDK = require('./sdk/Intacct')
8
+ const BusinessCentralSDK = require('./sdk/BusinessCentral')
9
+ const ZenotiSDK = require('./sdk/Zenoti')
10
+ const DearSDK = require('./sdk/Dear')
11
+ const NexviaSDK = require('./sdk/Nexvia')
12
+ const FoSDK = require('./sdk/Fo')
13
+ const RetailExpressSDK = require('./sdk/RetailExpress')
14
+ const MYOBAcumaticaSDK = require('./sdk/MYOBAcumatica')
15
+ const SybizSDK = require('./sdk/Sybiz')
16
+ const JobReadySDK = require('./sdk/JobReady')
17
+
18
+ const Logger = require('./utils/logger')
19
+ const Metadata = require('./utils/metadata')
20
+ const Tags = require('./utils/tags')
21
+ const Properties = require('./utils/properties')
22
+ const MiscHelper = require('./utils/miscHelper')
23
+ const ModelHelper = require('./utils/modelHelper')
24
+ const {
25
+ getFileContent,
26
+ uploadFile,
27
+ listFiles,
28
+ deleteFile,
29
+ deleteFiles
30
+ } = require('./utils/s3Client')
31
+
32
+ const S3Client = {
33
+ getFileContent,
34
+ uploadFile,
35
+ listFiles,
36
+ deleteFile,
37
+ deleteFiles
38
+ }
39
+
40
+ module.exports = {
41
+ Auth,
42
+ ZudelloSDK,
43
+ NetsuiteSDK,
44
+ NetsuiteSoapSDK,
45
+ IntacctSDK,
46
+ BusinessCentralSDK,
47
+ ZenotiSDK,
48
+ DearSDK,
49
+ NexviaSDK,
50
+ FoSDK,
51
+ RetailExpressSDK,
52
+ MYOBAcumaticaSDK,
53
+ SybizSDK,
54
+ JobReadySDK,
55
+ Logger,
56
+ Metadata,
57
+ Tags,
58
+ Properties,
59
+ MiscHelper,
60
+ ModelHelper,
61
+ S3Client
62
+ }
@@ -0,0 +1,40 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'accounts', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "number"),
18
+ "name": _.get(item, "displayName"),
19
+ "status": (item.blocked == false && item.directPosting == true) ? "ACTIVE" : "INACTIVE",
20
+ // "account_group": _.get(item, "category"),
21
+ "account_type": _.get(item, "accountType")
22
+ }
23
+ })
24
+
25
+ logger.log(data)
26
+
27
+ const result = await Zudello.account.updateOrCreate({ data })
28
+
29
+ logger.log(result)
30
+
31
+ if (result.success) {
32
+ const lastObject = _.last(items.data.value)
33
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
34
+
35
+ if (updatedLastModifiedDateTime) {
36
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
37
+ }
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,52 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'accountingPeriods', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ const itemData = {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "id"),
18
+ "name": _.get(item, "name"),
19
+ "status": "ACTIVE",
20
+ "custom": JSON.stringify({
21
+ "newFiscalYear": _.get(item, "newFiscalYear")
22
+ }),
23
+ "is_closed": _.get(item, "closed"),
24
+ "ap_locked": _.get(item, "dateLocked"),
25
+ "ar_locked": _.get(item, "dateLocked")
26
+ }
27
+
28
+ const startDate = _.get(item, "startingDate")
29
+
30
+ if (startDate) {
31
+ itemData["start_date"] = moment(startDate).format("YYYY-MM-DD")
32
+ }
33
+
34
+ return itemData
35
+ })
36
+
37
+ logger.log(data)
38
+
39
+ const result = await Zudello.accountingPeriod.updateOrCreate({ data })
40
+
41
+ logger.log(result)
42
+
43
+ if (result.success) {
44
+ const lastObject = _.last(items.data.value)
45
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
46
+
47
+ if (updatedLastModifiedDateTime) {
48
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
49
+ }
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,42 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'currencies', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "code"),
18
+ "name": _.get(item, "displayName"),
19
+ "symbol": _.get(item, "symbol"),
20
+ "status": "ACTIVE",
21
+ "custom": JSON.stringify({
22
+ "amountRoundingPrecision": _.get(item, "amountRoundingPrecision")
23
+ })
24
+ }
25
+ })
26
+
27
+ logger.log(data)
28
+
29
+ const result = await Zudello.currency.updateOrCreate({ data })
30
+
31
+ logger.log(result)
32
+
33
+ if (result.success) {
34
+ const lastObject = _.last(items.data.value)
35
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
36
+
37
+ if (updatedLastModifiedDateTime) {
38
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
39
+ }
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,45 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'customers', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "number"),
18
+ "legal_name": _.get(item, "displayName"),
19
+ "trading_name": _.get(item, "displayName"),
20
+ "country": _.get(item, "country"),
21
+ "currency": _.get(item, "currencyCode"),
22
+ "payment_term": _.get(item, "paymentTermsId"),
23
+ "tax_number": _.get(item, "taxRegistrationNumber"),
24
+ "status": item.blocked == "_x0020_" ? "ACTIVE" : "INACTIVE",
25
+ "phone": _.get(item, "phone"),
26
+ "email": _.get(item, "email"),
27
+ }
28
+ })
29
+
30
+ logger.log(data)
31
+
32
+ const result = await Zudello.customer.updateOrCreate({ data })
33
+
34
+ logger.log(result)
35
+
36
+ if (result.success) {
37
+ const lastObject = _.last(items.data.value)
38
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
39
+
40
+ if (updatedLastModifiedDateTime) {
41
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
42
+ }
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,85 @@
1
+ const handler = async (providedData) => {
2
+ const dimensions = await BC.universal.list({ url: 'dimensions', method: 'GET' })
3
+
4
+ logger.log(dimensions)
5
+
6
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
7
+ const fetchData = { url: 'dimensionValues', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
8
+
9
+ if (lastModifiedDateTime) {
10
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
11
+ }
12
+
13
+ logger.log(fetchData)
14
+
15
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
16
+ const dimenionValueGroups = _.groupBy(items.data.value, "dimensionId")
17
+
18
+ logger.log(dimenionValueGroups)
19
+
20
+ Object.keys(dimenionValueGroups).forEach(async dimensionId => {
21
+ const dimensionObj = _.head(
22
+ _.filter(dimensions.data.value, { "id": _.get(_.head(dimenionValueGroups[dimensionId]), "dimensionId") })
23
+ )
24
+
25
+ logger.log(dimensionObj)
26
+
27
+ let result = null
28
+
29
+ if (dimensionObj) {
30
+ const metafield = metadata.get('dimension_' + dimensionObj.code , "")
31
+
32
+ logger.log(dimensionObj.code)
33
+ logger.log(metafield)
34
+
35
+ if (metafield) {
36
+ const data = _.map(dimenionValueGroups[dimensionId], (item) => {
37
+ return {
38
+ "external_id": _.get(item, "id"),
39
+ "code": _.get(item, "code"),
40
+ "name": _.get(item, "displayName")
41
+ }
42
+ })
43
+
44
+ logger.log(data)
45
+
46
+ switch (_.toUpper(metafield)) {
47
+ case 'PROJECT': {
48
+ result = await Zudello.project.updateOrCreate({ data })
49
+ logger.log(result)
50
+
51
+ break
52
+ }
53
+ case 'DEPARTMENT': {
54
+ result = await Zudello.department.updateOrCreate({ data })
55
+ logger.log(result)
56
+
57
+ break
58
+ }
59
+ case 'COST_CENTRE': {
60
+ result = await Zudello.costCentre.updateOrCreate({ data })
61
+ logger.log(result)
62
+
63
+ break
64
+ }
65
+ case 'COST_TYPE': {
66
+ result = await Zudello.costType.updateOrCreate({ data })
67
+ logger.log(result)
68
+
69
+ break
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ if (result && result.success) {
76
+ const lastObject = _.last(items.data.value)
77
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
78
+
79
+ if (updatedLastModifiedDateTime) {
80
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
81
+ }
82
+ }
83
+ })
84
+ }
85
+ }
@@ -0,0 +1,38 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'employees', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "number"),
18
+ "first_name": _.get(item, "givenName"),
19
+ "last_name": _.get(item, "surname")
20
+ }
21
+ })
22
+
23
+ logger.log(data)
24
+
25
+ const result = await Zudello.employee.updateOrCreate({ data })
26
+
27
+ logger.log(result)
28
+
29
+ if (result.success) {
30
+ const lastObject = _.last(items.data.value)
31
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
32
+
33
+ if (updatedLastModifiedDateTime) {
34
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
35
+ }
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,48 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'fixedAssets', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "number"),
18
+ "name": _.get(item, "displayName"),
19
+ "status": item.blocked ? "INACTIVE" : "ACTIVE",
20
+ "custom": JSON.stringify({
21
+ "fixedAssetLocationCode": _.get(item, "fixedAssetLocationCode"),
22
+ "fixedAssetLocationId": _.get(item, "fixedAssetLocationId"),
23
+ "classCode": _.get(item, "classCode"),
24
+ "subclassCode": _.get(item, "subclassCode"),
25
+ "serialNumber": _.get(item, "serialNumber"),
26
+ "employeeNumber": _.get(item, "employeeNumber"),
27
+ "employeeId": _.get(item, "employeeId"),
28
+ "underMaintenance": _.get(item, "underMaintenance")
29
+ })
30
+ }
31
+ })
32
+
33
+ logger.log(data)
34
+
35
+ const result = await Zudello.fixedAsset.updateOrCreate({ data })
36
+
37
+ logger.log(result)
38
+
39
+ if (result.success) {
40
+ const lastObject = _.last(items.data.value)
41
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
42
+
43
+ if (updatedLastModifiedDateTime) {
44
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
45
+ }
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,45 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'items', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "sku": _.get(item, "number"),
18
+ "item_category": _.get(item, "itemCategoryId"),
19
+ "item_type": _.get(item, "type"),
20
+ "short_description": _.get(item, "displayName"),
21
+ "description": _.get(item, "displayName2"),
22
+ "purchase_price": _.get(item, "unitCost"),
23
+ "sell_price": _.get(item, "unitPrice"),
24
+ "tax_rate": _.get(item, "taxGroupId"),
25
+ "unit_of_measure": _.get(item, "baseUnitOfMeasureId"),
26
+ "status": item.blocked == false ? "ACTIVE" : "INACTIVE",
27
+ }
28
+ })
29
+
30
+ logger.log(data)
31
+
32
+ const result = await Zudello.item.updateOrCreate({ data })
33
+
34
+ logger.log(result)
35
+
36
+ if (result.success) {
37
+ const lastObject = _.last(items.data.value)
38
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
39
+
40
+ if (updatedLastModifiedDateTime) {
41
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
42
+ }
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,37 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'itemCategories', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "code"),
18
+ "name": _.get(item, "displayName")
19
+ }
20
+ })
21
+
22
+ logger.log(data)
23
+
24
+ const result = await Zudello.itemCategory.updateOrCreate({ data })
25
+
26
+ logger.log(result)
27
+
28
+ if (result.success) {
29
+ const lastObject = _.last(items.data.value)
30
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
31
+
32
+ if (updatedLastModifiedDateTime) {
33
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
34
+ }
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,37 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'locations', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "code"),
18
+ "name": _.get(item, "displayName")
19
+ }
20
+ })
21
+
22
+ logger.log(data)
23
+
24
+ const result = await Zudello.location.updateOrCreate({ data })
25
+
26
+ logger.log(result)
27
+
28
+ if (result.success) {
29
+ const lastObject = _.last(items.data.value)
30
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
31
+
32
+ if (updatedLastModifiedDateTime) {
33
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
34
+ }
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,38 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'paymentMethods', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "code"),
18
+ "name": _.get(item, "displayName"),
19
+ "status": "ACTIVE"
20
+ }
21
+ })
22
+
23
+ logger.log(data)
24
+
25
+ const result = await Zudello.paymentMethod.updateOrCreate({ data })
26
+
27
+ logger.log(result)
28
+
29
+ if (result.success) {
30
+ const lastObject = _.last(items.data.value)
31
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
32
+
33
+ if (updatedLastModifiedDateTime) {
34
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
35
+ }
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,41 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'paymentTerms', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "code"),
18
+ "name": _.get(item, "displayName"),
19
+ "status": "ACTIVE",
20
+ "custom": JSON.stringify({
21
+ "dueDateCalculation": _.get(item, "dueDateCalculation")
22
+ })
23
+ }
24
+ })
25
+
26
+ logger.log(data)
27
+
28
+ const result = await Zudello.paymentTerm.updateOrCreate({ data })
29
+
30
+ logger.log(result)
31
+
32
+ if (result.success) {
33
+ const lastObject = _.last(items.data.value)
34
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
35
+
36
+ if (updatedLastModifiedDateTime) {
37
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
38
+ }
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,38 @@
1
+ const handler = async (providedData) => {
2
+ const lastModifiedDateTime = metadata.get('lastModifiedDateTime')
3
+ const fetchData = { url: 'projects', method: 'GET', qs: { $orderby: 'lastModifiedDateTime' } }
4
+
5
+ if (lastModifiedDateTime) {
6
+ fetchData.qs.$filter = `lastModifiedDateTime gt ${lastModifiedDateTime}`
7
+ }
8
+
9
+ logger.log(fetchData)
10
+
11
+ for await (const items of BC.universal.autoPaginationList(fetchData)) {
12
+ logger.log(items)
13
+
14
+ const data = _.map(items.data.value, (item) => {
15
+ return {
16
+ "external_id": _.get(item, "id"),
17
+ "code": _.get(item, "number"),
18
+ "name": _.get(item, "displayName"),
19
+ "status": "ACTIVE"
20
+ }
21
+ })
22
+
23
+ logger.log(data)
24
+
25
+ const result = await Zudello.project.updateOrCreate({ data })
26
+
27
+ logger.log(result)
28
+
29
+ if (result.success) {
30
+ const lastObject = _.last(items.data.value)
31
+ const updatedLastModifiedDateTime = lastObject ? lastObject.lastModifiedDateTime : null
32
+
33
+ if (updatedLastModifiedDateTime) {
34
+ metadata.set('lastModifiedDateTime', updatedLastModifiedDateTime)
35
+ }
36
+ }
37
+ }
38
+ }