@apideck/unify 0.40.0 → 0.41.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 (96) hide show
  1. package/jsr.json +1 -1
  2. package/lib/config.d.ts +4 -4
  3. package/lib/config.js +4 -4
  4. package/package.json +6 -2
  5. package/src/__tests__/activities.test.ts +1141 -0
  6. package/src/__tests__/agedcreditors.test.ts +280 -0
  7. package/src/__tests__/ageddebtors.test.ts +280 -0
  8. package/src/__tests__/apideckcompanies.test.ts +1082 -0
  9. package/src/__tests__/apideckcustomers.test.ts +364 -0
  10. package/src/__tests__/apideckdepartments.test.ts +497 -0
  11. package/src/__tests__/apiresources.test.ts +62 -0
  12. package/src/__tests__/apis.test.ts +216 -0
  13. package/src/__tests__/applicants.test.ts +1445 -0
  14. package/src/__tests__/applications.test.ts +515 -0
  15. package/src/__tests__/assertions.ts +13 -0
  16. package/src/__tests__/attachments.test.ts +371 -0
  17. package/src/__tests__/balancesheet.test.ts +453 -0
  18. package/src/__tests__/bankaccounts.test.ts +324 -0
  19. package/src/__tests__/bankfeedaccounts.test.ts +343 -0
  20. package/src/__tests__/bankfeedstatements.test.ts +408 -0
  21. package/src/__tests__/billpayments.test.ts +1031 -0
  22. package/src/__tests__/bills.test.ts +1630 -0
  23. package/src/__tests__/categories.test.ts +127 -0
  24. package/src/__tests__/collections.test.ts +120 -0
  25. package/src/__tests__/collectiontags.test.ts +68 -0
  26. package/src/__tests__/collectionticketcomments.test.ts +501 -0
  27. package/src/__tests__/collectiontickets.test.ts +627 -0
  28. package/src/__tests__/collectionusers.test.ts +126 -0
  29. package/src/__tests__/companies.test.ts +1642 -0
  30. package/src/__tests__/companyinfo.test.ts +219 -0
  31. package/src/__tests__/connectionconsent.test.ts +89 -0
  32. package/src/__tests__/connectionconsents.test.ts +31 -0
  33. package/src/__tests__/connectioncustommappings.test.ts +69 -0
  34. package/src/__tests__/connections.test.ts +2127 -0
  35. package/src/__tests__/connectionsettings.test.ts +687 -0
  36. package/src/__tests__/connectordocs.test.ts +29 -0
  37. package/src/__tests__/connectors.test.ts +753 -0
  38. package/src/__tests__/consumerrequestcounts.test.ts +42 -0
  39. package/src/__tests__/consumers.test.ts +523 -0
  40. package/src/__tests__/contacts.test.ts +1421 -0
  41. package/src/__tests__/createcallback.test.ts +36 -0
  42. package/src/__tests__/creditnotes.test.ts +2040 -0
  43. package/src/__tests__/customers.test.ts +1600 -0
  44. package/src/__tests__/customfields.test.ts +52 -0
  45. package/src/__tests__/custommappings.test.ts +65 -0
  46. package/src/__tests__/customobjects.test.ts +408 -0
  47. package/src/__tests__/customobjectschemas.test.ts +734 -0
  48. package/src/__tests__/departments.test.ts +529 -0
  49. package/src/__tests__/drivegroups.test.ts +496 -0
  50. package/src/__tests__/drives.test.ts +487 -0
  51. package/src/__tests__/employeepayrolls.test.ts +491 -0
  52. package/src/__tests__/employees.test.ts +2968 -0
  53. package/src/__tests__/employeeschedules.test.ts +457 -0
  54. package/src/__tests__/eventlogs.test.ts +158 -0
  55. package/src/__tests__/expensecategories.test.ts +324 -0
  56. package/src/__tests__/expensereports.test.ts +634 -0
  57. package/src/__tests__/expenses.test.ts +867 -0
  58. package/src/__tests__/files.test.ts +506 -0
  59. package/src/__tests__/files.ts +56 -0
  60. package/src/__tests__/folders.test.ts +390 -0
  61. package/src/__tests__/invoiceitems.test.ts +855 -0
  62. package/src/__tests__/invoices.test.ts +2173 -0
  63. package/src/__tests__/jobs.test.ts +1150 -0
  64. package/src/__tests__/journalentries.test.ts +1542 -0
  65. package/src/__tests__/leads.test.ts +1341 -0
  66. package/src/__tests__/ledgeraccounts.test.ts +829 -0
  67. package/src/__tests__/locations.test.ts +856 -0
  68. package/src/__tests__/logs.test.ts +137 -0
  69. package/src/__tests__/messages.test.ts +588 -0
  70. package/src/__tests__/notes.test.ts +523 -0
  71. package/src/__tests__/opportunities.test.ts +718 -0
  72. package/src/__tests__/orders.test.ts +854 -0
  73. package/src/__tests__/payments.test.ts +867 -0
  74. package/src/__tests__/payrolls.test.ts +485 -0
  75. package/src/__tests__/pipelines.test.ts +574 -0
  76. package/src/__tests__/products.test.ts +509 -0
  77. package/src/__tests__/profitandloss.test.ts +223 -0
  78. package/src/__tests__/projects.test.ts +480 -0
  79. package/src/__tests__/proxy.test.ts +41 -0
  80. package/src/__tests__/purchaseorders.test.ts +2139 -0
  81. package/src/__tests__/quotes.test.ts +678 -0
  82. package/src/__tests__/refunds.test.ts +812 -0
  83. package/src/__tests__/sessions.test.ts +72 -0
  84. package/src/__tests__/sharedlinks.test.ts +511 -0
  85. package/src/__tests__/stores.test.ts +41 -0
  86. package/src/__tests__/subsidiaries.test.ts +496 -0
  87. package/src/__tests__/suppliers.test.ts +1574 -0
  88. package/src/__tests__/taxrates.test.ts +701 -0
  89. package/src/__tests__/testclient.ts +48 -0
  90. package/src/__tests__/timeoffrequests.test.ts +588 -0
  91. package/src/__tests__/trackingcategories.test.ts +515 -0
  92. package/src/__tests__/uploadsessions.test.ts +221 -0
  93. package/src/__tests__/users.test.ts +1020 -0
  94. package/src/__tests__/validateconnection.test.ts +34 -0
  95. package/src/__tests__/webhooks.test.ts +254 -0
  96. package/src/lib/config.ts +4 -4
@@ -0,0 +1,1630 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { expect, test } from "vitest";
6
+ import { Apideck } from "../index.js";
7
+ import { createTestHTTPClient } from "./testclient.js";
8
+
9
+ test("Bills Accounting Bills All", async () => {
10
+ const testHttpClient = createTestHTTPClient("accounting.billsAll");
11
+
12
+ const apideck = new Apideck({
13
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
14
+ httpClient: testHttpClient,
15
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
16
+ });
17
+
18
+ const result = await apideck.accounting.bills.list({
19
+ consumerId: "test-consumer",
20
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
21
+ serviceId: "salesforce",
22
+ filter: {
23
+ updatedSince: new Date("2020-09-30T07:43:32.000Z"),
24
+ },
25
+ sort: {
26
+ by: "updated_at",
27
+ direction: "desc",
28
+ },
29
+ passThrough: {
30
+ "search": "San Francisco",
31
+ },
32
+ fields: "id,updated_at",
33
+ });
34
+ expect(result.httpMeta.response.status).toBe(200);
35
+ expect(result.getBillsResponse).toBeDefined();
36
+ expect(result.getBillsResponse).toEqual({
37
+ statusCode: 200,
38
+ status: "OK",
39
+ service: "xero",
40
+ resource: "bills",
41
+ operation: "all",
42
+ data: [
43
+ {
44
+ id: "12345",
45
+ downstreamId: "12345",
46
+ billNumber: "10001",
47
+ supplier: {
48
+ id: "12345",
49
+ displayId: "SUPP00101",
50
+ displayName: "Windsurf Shop",
51
+ companyName: "The boring company",
52
+ address: {
53
+ id: "123",
54
+ type: "primary",
55
+ string: "25 Spring Street, Blackburn, VIC 3130",
56
+ name: "HQ US",
57
+ line1: "Main street",
58
+ line2: "apt #",
59
+ line3: "Suite #",
60
+ line4: "delivery instructions",
61
+ streetNumber: "25",
62
+ city: "San Francisco",
63
+ state: "CA",
64
+ postalCode: "94104",
65
+ country: "US",
66
+ latitude: "40.759211",
67
+ longitude: "-73.984638",
68
+ county: "Santa Clara",
69
+ contactName: "Elon Musk",
70
+ salutation: "Mr",
71
+ phoneNumber: "111-111-1111",
72
+ fax: "122-111-1111",
73
+ email: "elon@musk.com",
74
+ website: "https://elonmusk.com",
75
+ notes: "Address notes or delivery instructions.",
76
+ rowVersion: "1-12345",
77
+ },
78
+ },
79
+ companyId: "12345",
80
+ currency: "USD",
81
+ currencyRate: 0.69,
82
+ taxInclusive: true,
83
+ billDate: new Date("2020-09-30"),
84
+ dueDate: new Date("2020-10-30"),
85
+ paidDate: new Date("2020-10-30"),
86
+ poNumber: "90000117",
87
+ reference: "123456",
88
+ lineItems: [
89
+ {
90
+ id: "12345",
91
+ rowId: "12345",
92
+ code: "120-C",
93
+ lineNumber: 1,
94
+ description:
95
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
96
+ type: "expense_account",
97
+ taxAmount: 27500,
98
+ totalAmount: 27500,
99
+ quantity: 1,
100
+ unitPrice: 27500.5,
101
+ unitOfMeasure: "pc.",
102
+ discountPercentage: 0.01,
103
+ discountAmount: 19.99,
104
+ locationId: "12345",
105
+ departmentId: "12345",
106
+ item: {
107
+ id: "12344",
108
+ code: "120-C",
109
+ name: "Model Y",
110
+ },
111
+ taxRate: {
112
+ id: "123456",
113
+ code: "N-T",
114
+ name: "GST on Purchases",
115
+ rate: 10,
116
+ },
117
+ ledgerAccount: {
118
+ id: "123456",
119
+ name: "Bank account",
120
+ nominalCode: "N091",
121
+ code: "453",
122
+ },
123
+ trackingCategories: [
124
+ {
125
+ id: "123456",
126
+ name: "New York",
127
+ },
128
+ {
129
+ id: "123456",
130
+ name: "New York",
131
+ },
132
+ {
133
+ id: "123456",
134
+ name: "New York",
135
+ },
136
+ ],
137
+ rowVersion: "1-12345",
138
+ updatedBy: "12345",
139
+ createdBy: "12345",
140
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
141
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
142
+ },
143
+ {
144
+ id: "12345",
145
+ rowId: "12345",
146
+ code: "120-C",
147
+ lineNumber: 1,
148
+ description:
149
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
150
+ type: "expense_account",
151
+ taxAmount: 27500,
152
+ totalAmount: 27500,
153
+ quantity: 1,
154
+ unitPrice: 27500.5,
155
+ unitOfMeasure: "pc.",
156
+ discountPercentage: 0.01,
157
+ discountAmount: 19.99,
158
+ locationId: "12345",
159
+ departmentId: "12345",
160
+ item: {
161
+ id: "12344",
162
+ code: "120-C",
163
+ name: "Model Y",
164
+ },
165
+ taxRate: {
166
+ id: "123456",
167
+ code: "N-T",
168
+ name: "GST on Purchases",
169
+ rate: 10,
170
+ },
171
+ ledgerAccount: {
172
+ id: "123456",
173
+ name: "Bank account",
174
+ nominalCode: "N091",
175
+ code: "453",
176
+ },
177
+ trackingCategories: [
178
+ {
179
+ id: "123456",
180
+ name: "New York",
181
+ },
182
+ ],
183
+ rowVersion: "1-12345",
184
+ updatedBy: "12345",
185
+ createdBy: "12345",
186
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
187
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
188
+ },
189
+ ],
190
+ terms: "Net 30 days",
191
+ balance: 27500,
192
+ deposit: 0,
193
+ subTotal: 27500,
194
+ totalTax: 2500,
195
+ total: 27500,
196
+ taxCode: "1234",
197
+ notes: "Some notes about this bill.",
198
+ status: "draft",
199
+ ledgerAccount: {
200
+ id: "123456",
201
+ name: "Bank account",
202
+ nominalCode: "N091",
203
+ code: "453",
204
+ },
205
+ paymentMethod: "cash",
206
+ channel: "email",
207
+ language: "EN",
208
+ accountingByRow: false,
209
+ bankAccount: {
210
+ bankName: "Monzo",
211
+ accountNumber: "123465",
212
+ accountName: "SPACEX LLC",
213
+ accountType: "credit_card",
214
+ iban: "CH2989144532982975332",
215
+ bic: "AUDSCHGGXXX",
216
+ routingNumber: "012345678",
217
+ bsbNumber: "062-001",
218
+ branchIdentifier: "001",
219
+ bankCode: "BNH",
220
+ currency: "USD",
221
+ },
222
+ discountPercentage: 5.5,
223
+ sourceDocumentUrl: "https://www.invoicesolution.com/bill/123456",
224
+ trackingCategories: [
225
+ {
226
+ id: "123456",
227
+ name: "New York",
228
+ },
229
+ ],
230
+ updatedBy: "12345",
231
+ createdBy: "12345",
232
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
233
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
234
+ rowVersion: "1-12345",
235
+ customFields: [
236
+ {
237
+ id: "2389328923893298",
238
+ name: "employee_level",
239
+ description: "Employee Level",
240
+ value: {},
241
+ },
242
+ ],
243
+ passThrough: [
244
+ {
245
+ serviceId: "<id>",
246
+ extendPaths: [
247
+ {
248
+ path: "$.nested.property",
249
+ value: {
250
+ "TaxClassificationRef": {
251
+ "value": "EUC-99990201-V1-00020000",
252
+ },
253
+ },
254
+ },
255
+ ],
256
+ },
257
+ {
258
+ serviceId: "<id>",
259
+ extendPaths: [
260
+ {
261
+ path: "$.nested.property",
262
+ value: {
263
+ "TaxClassificationRef": {
264
+ "value": "EUC-99990201-V1-00020000",
265
+ },
266
+ },
267
+ },
268
+ {
269
+ path: "$.nested.property",
270
+ value: {
271
+ "TaxClassificationRef": {
272
+ "value": "EUC-99990201-V1-00020000",
273
+ },
274
+ },
275
+ },
276
+ {
277
+ path: "$.nested.property",
278
+ value: {
279
+ "TaxClassificationRef": {
280
+ "value": "EUC-99990201-V1-00020000",
281
+ },
282
+ },
283
+ },
284
+ ],
285
+ },
286
+ ],
287
+ accountingPeriod: "01-24",
288
+ },
289
+ {
290
+ id: "12345",
291
+ downstreamId: "12345",
292
+ billNumber: "10001",
293
+ supplier: {
294
+ id: "12345",
295
+ displayId: "SUPP00101",
296
+ displayName: "Windsurf Shop",
297
+ companyName: "The boring company",
298
+ address: {
299
+ id: "123",
300
+ type: "primary",
301
+ string: "25 Spring Street, Blackburn, VIC 3130",
302
+ name: "HQ US",
303
+ line1: "Main street",
304
+ line2: "apt #",
305
+ line3: "Suite #",
306
+ line4: "delivery instructions",
307
+ streetNumber: "25",
308
+ city: "San Francisco",
309
+ state: "CA",
310
+ postalCode: "94104",
311
+ country: "US",
312
+ latitude: "40.759211",
313
+ longitude: "-73.984638",
314
+ county: "Santa Clara",
315
+ contactName: "Elon Musk",
316
+ salutation: "Mr",
317
+ phoneNumber: "111-111-1111",
318
+ fax: "122-111-1111",
319
+ email: "elon@musk.com",
320
+ website: "https://elonmusk.com",
321
+ notes: "Address notes or delivery instructions.",
322
+ rowVersion: "1-12345",
323
+ },
324
+ },
325
+ companyId: "12345",
326
+ currency: "USD",
327
+ currencyRate: 0.69,
328
+ taxInclusive: true,
329
+ billDate: new Date("2020-09-30"),
330
+ dueDate: new Date("2020-10-30"),
331
+ paidDate: new Date("2020-10-30"),
332
+ poNumber: "90000117",
333
+ reference: "123456",
334
+ lineItems: [
335
+ {
336
+ id: "12345",
337
+ rowId: "12345",
338
+ code: "120-C",
339
+ lineNumber: 1,
340
+ description:
341
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
342
+ type: "expense_account",
343
+ taxAmount: 27500,
344
+ totalAmount: 27500,
345
+ quantity: 1,
346
+ unitPrice: 27500.5,
347
+ unitOfMeasure: "pc.",
348
+ discountPercentage: 0.01,
349
+ discountAmount: 19.99,
350
+ locationId: "12345",
351
+ departmentId: "12345",
352
+ item: {
353
+ id: "12344",
354
+ code: "120-C",
355
+ name: "Model Y",
356
+ },
357
+ taxRate: {
358
+ id: "123456",
359
+ code: "N-T",
360
+ name: "GST on Purchases",
361
+ rate: 10,
362
+ },
363
+ ledgerAccount: {
364
+ id: "123456",
365
+ name: "Bank account",
366
+ nominalCode: "N091",
367
+ code: "453",
368
+ },
369
+ trackingCategories: [
370
+ {
371
+ id: "123456",
372
+ name: "New York",
373
+ },
374
+ ],
375
+ rowVersion: "1-12345",
376
+ updatedBy: "12345",
377
+ createdBy: "12345",
378
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
379
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
380
+ },
381
+ ],
382
+ terms: "Net 30 days",
383
+ balance: 27500,
384
+ deposit: 0,
385
+ subTotal: 27500,
386
+ totalTax: 2500,
387
+ total: 27500,
388
+ taxCode: "1234",
389
+ notes: "Some notes about this bill.",
390
+ status: "draft",
391
+ ledgerAccount: {
392
+ id: "123456",
393
+ name: "Bank account",
394
+ nominalCode: "N091",
395
+ code: "453",
396
+ },
397
+ paymentMethod: "cash",
398
+ channel: "email",
399
+ language: "EN",
400
+ accountingByRow: false,
401
+ bankAccount: {
402
+ bankName: "Monzo",
403
+ accountNumber: "123465",
404
+ accountName: "SPACEX LLC",
405
+ accountType: "credit_card",
406
+ iban: "CH2989144532982975332",
407
+ bic: "AUDSCHGGXXX",
408
+ routingNumber: "012345678",
409
+ bsbNumber: "062-001",
410
+ branchIdentifier: "001",
411
+ bankCode: "BNH",
412
+ currency: "USD",
413
+ },
414
+ discountPercentage: 5.5,
415
+ sourceDocumentUrl: "https://www.invoicesolution.com/bill/123456",
416
+ trackingCategories: [
417
+ {
418
+ id: "123456",
419
+ name: "New York",
420
+ },
421
+ {
422
+ id: "123456",
423
+ name: "New York",
424
+ },
425
+ {
426
+ id: "123456",
427
+ name: "New York",
428
+ },
429
+ ],
430
+ updatedBy: "12345",
431
+ createdBy: "12345",
432
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
433
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
434
+ rowVersion: "1-12345",
435
+ customFields: [
436
+ {
437
+ id: "2389328923893298",
438
+ name: "employee_level",
439
+ description: "Employee Level",
440
+ value: {},
441
+ },
442
+ {
443
+ id: "2389328923893298",
444
+ name: "employee_level",
445
+ description: "Employee Level",
446
+ value: "Uses Salesforce and Marketo",
447
+ },
448
+ ],
449
+ passThrough: [
450
+ {
451
+ serviceId: "<id>",
452
+ extendPaths: [
453
+ {
454
+ path: "$.nested.property",
455
+ value: {
456
+ "TaxClassificationRef": {
457
+ "value": "EUC-99990201-V1-00020000",
458
+ },
459
+ },
460
+ },
461
+ {
462
+ path: "$.nested.property",
463
+ value: {
464
+ "TaxClassificationRef": {
465
+ "value": "EUC-99990201-V1-00020000",
466
+ },
467
+ },
468
+ },
469
+ ],
470
+ },
471
+ ],
472
+ accountingPeriod: "01-24",
473
+ },
474
+ {
475
+ id: "12345",
476
+ downstreamId: "12345",
477
+ billNumber: "10001",
478
+ supplier: {
479
+ id: "12345",
480
+ displayId: "SUPP00101",
481
+ displayName: "Windsurf Shop",
482
+ companyName: "The boring company",
483
+ address: {
484
+ id: "123",
485
+ type: "primary",
486
+ string: "25 Spring Street, Blackburn, VIC 3130",
487
+ name: "HQ US",
488
+ line1: "Main street",
489
+ line2: "apt #",
490
+ line3: "Suite #",
491
+ line4: "delivery instructions",
492
+ streetNumber: "25",
493
+ city: "San Francisco",
494
+ state: "CA",
495
+ postalCode: "94104",
496
+ country: "US",
497
+ latitude: "40.759211",
498
+ longitude: "-73.984638",
499
+ county: "Santa Clara",
500
+ contactName: "Elon Musk",
501
+ salutation: "Mr",
502
+ phoneNumber: "111-111-1111",
503
+ fax: "122-111-1111",
504
+ email: "elon@musk.com",
505
+ website: "https://elonmusk.com",
506
+ notes: "Address notes or delivery instructions.",
507
+ rowVersion: "1-12345",
508
+ },
509
+ },
510
+ companyId: "12345",
511
+ currency: "USD",
512
+ currencyRate: 0.69,
513
+ taxInclusive: true,
514
+ billDate: new Date("2020-09-30"),
515
+ dueDate: new Date("2020-10-30"),
516
+ paidDate: new Date("2020-10-30"),
517
+ poNumber: "90000117",
518
+ reference: "123456",
519
+ lineItems: [
520
+ {
521
+ id: "12345",
522
+ rowId: "12345",
523
+ code: "120-C",
524
+ lineNumber: 1,
525
+ description:
526
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
527
+ type: "expense_account",
528
+ taxAmount: 27500,
529
+ totalAmount: 27500,
530
+ quantity: 1,
531
+ unitPrice: 27500.5,
532
+ unitOfMeasure: "pc.",
533
+ discountPercentage: 0.01,
534
+ discountAmount: 19.99,
535
+ locationId: "12345",
536
+ departmentId: "12345",
537
+ item: {
538
+ id: "12344",
539
+ code: "120-C",
540
+ name: "Model Y",
541
+ },
542
+ taxRate: {
543
+ id: "123456",
544
+ code: "N-T",
545
+ name: "GST on Purchases",
546
+ rate: 10,
547
+ },
548
+ ledgerAccount: {
549
+ id: "123456",
550
+ name: "Bank account",
551
+ nominalCode: "N091",
552
+ code: "453",
553
+ },
554
+ trackingCategories: [
555
+ {
556
+ id: "123456",
557
+ name: "New York",
558
+ },
559
+ ],
560
+ rowVersion: "1-12345",
561
+ updatedBy: "12345",
562
+ createdBy: "12345",
563
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
564
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
565
+ },
566
+ {
567
+ id: "12345",
568
+ rowId: "12345",
569
+ code: "120-C",
570
+ lineNumber: 1,
571
+ description:
572
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
573
+ type: "expense_account",
574
+ taxAmount: 27500,
575
+ totalAmount: 27500,
576
+ quantity: 1,
577
+ unitPrice: 27500.5,
578
+ unitOfMeasure: "pc.",
579
+ discountPercentage: 0.01,
580
+ discountAmount: 19.99,
581
+ locationId: "12345",
582
+ departmentId: "12345",
583
+ item: {
584
+ id: "12344",
585
+ code: "120-C",
586
+ name: "Model Y",
587
+ },
588
+ taxRate: {
589
+ id: "123456",
590
+ code: "N-T",
591
+ name: "GST on Purchases",
592
+ rate: 10,
593
+ },
594
+ ledgerAccount: {
595
+ id: "123456",
596
+ name: "Bank account",
597
+ nominalCode: "N091",
598
+ code: "453",
599
+ },
600
+ trackingCategories: [
601
+ {
602
+ id: "123456",
603
+ name: "New York",
604
+ },
605
+ {
606
+ id: "123456",
607
+ name: "New York",
608
+ },
609
+ {
610
+ id: "123456",
611
+ name: "New York",
612
+ },
613
+ ],
614
+ rowVersion: "1-12345",
615
+ updatedBy: "12345",
616
+ createdBy: "12345",
617
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
618
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
619
+ },
620
+ ],
621
+ terms: "Net 30 days",
622
+ balance: 27500,
623
+ deposit: 0,
624
+ subTotal: 27500,
625
+ totalTax: 2500,
626
+ total: 27500,
627
+ taxCode: "1234",
628
+ notes: "Some notes about this bill.",
629
+ status: "draft",
630
+ ledgerAccount: {
631
+ id: "123456",
632
+ name: "Bank account",
633
+ nominalCode: "N091",
634
+ code: "453",
635
+ },
636
+ paymentMethod: "cash",
637
+ channel: "email",
638
+ language: "EN",
639
+ accountingByRow: false,
640
+ bankAccount: {
641
+ bankName: "Monzo",
642
+ accountNumber: "123465",
643
+ accountName: "SPACEX LLC",
644
+ accountType: "credit_card",
645
+ iban: "CH2989144532982975332",
646
+ bic: "AUDSCHGGXXX",
647
+ routingNumber: "012345678",
648
+ bsbNumber: "062-001",
649
+ branchIdentifier: "001",
650
+ bankCode: "BNH",
651
+ currency: "USD",
652
+ },
653
+ discountPercentage: 5.5,
654
+ sourceDocumentUrl: "https://www.invoicesolution.com/bill/123456",
655
+ trackingCategories: [
656
+ {
657
+ id: "123456",
658
+ name: "New York",
659
+ },
660
+ {
661
+ id: "123456",
662
+ name: "New York",
663
+ },
664
+ ],
665
+ updatedBy: "12345",
666
+ createdBy: "12345",
667
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
668
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
669
+ rowVersion: "1-12345",
670
+ customFields: [
671
+ {
672
+ id: "2389328923893298",
673
+ name: "employee_level",
674
+ description: "Employee Level",
675
+ value: true,
676
+ },
677
+ {
678
+ id: "2389328923893298",
679
+ name: "employee_level",
680
+ description: "Employee Level",
681
+ value: "Uses Salesforce and Marketo",
682
+ },
683
+ {
684
+ id: "2389328923893298",
685
+ name: "employee_level",
686
+ description: "Employee Level",
687
+ value: 10,
688
+ },
689
+ ],
690
+ passThrough: [
691
+ {
692
+ serviceId: "<id>",
693
+ extendPaths: [
694
+ {
695
+ path: "$.nested.property",
696
+ value: {
697
+ "TaxClassificationRef": {
698
+ "value": "EUC-99990201-V1-00020000",
699
+ },
700
+ },
701
+ },
702
+ ],
703
+ },
704
+ {
705
+ serviceId: "<id>",
706
+ extendPaths: [
707
+ {
708
+ path: "$.nested.property",
709
+ value: {
710
+ "TaxClassificationRef": {
711
+ "value": "EUC-99990201-V1-00020000",
712
+ },
713
+ },
714
+ },
715
+ {
716
+ path: "$.nested.property",
717
+ value: {
718
+ "TaxClassificationRef": {
719
+ "value": "EUC-99990201-V1-00020000",
720
+ },
721
+ },
722
+ },
723
+ {
724
+ path: "$.nested.property",
725
+ value: {
726
+ "TaxClassificationRef": {
727
+ "value": "EUC-99990201-V1-00020000",
728
+ },
729
+ },
730
+ },
731
+ ],
732
+ },
733
+ {
734
+ serviceId: "<id>",
735
+ extendPaths: [
736
+ {
737
+ path: "$.nested.property",
738
+ value: {
739
+ "TaxClassificationRef": {
740
+ "value": "EUC-99990201-V1-00020000",
741
+ },
742
+ },
743
+ },
744
+ {
745
+ path: "$.nested.property",
746
+ value: {
747
+ "TaxClassificationRef": {
748
+ "value": "EUC-99990201-V1-00020000",
749
+ },
750
+ },
751
+ },
752
+ ],
753
+ },
754
+ ],
755
+ accountingPeriod: "01-24",
756
+ },
757
+ ],
758
+ meta: {
759
+ itemsOnPage: 50,
760
+ cursors: {
761
+ previous: "em9oby1jcm06OnBhZ2U6OjE=",
762
+ current: "em9oby1jcm06OnBhZ2U6OjI=",
763
+ next: "em9oby1jcm06OnBhZ2U6OjM=",
764
+ },
765
+ },
766
+ links: {
767
+ previous:
768
+ "https://unify.apideck.com/crm/companies?cursor=em9oby1jcm06OnBhZ2U6OjE%3D",
769
+ current: "https://unify.apideck.com/crm/companies",
770
+ next:
771
+ "https://unify.apideck.com/crm/companies?cursor=em9oby1jcm06OnBhZ2U6OjM",
772
+ },
773
+ });
774
+ });
775
+
776
+ test("Bills Accounting Bills Add", async () => {
777
+ const testHttpClient = createTestHTTPClient("accounting.billsAdd");
778
+
779
+ const apideck = new Apideck({
780
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
781
+ httpClient: testHttpClient,
782
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
783
+ });
784
+
785
+ const result = await apideck.accounting.bills.create({
786
+ consumerId: "test-consumer",
787
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
788
+ serviceId: "salesforce",
789
+ bill: {
790
+ billNumber: "10001",
791
+ supplier: {
792
+ id: "12345",
793
+ displayName: "Windsurf Shop",
794
+ address: {
795
+ id: "123",
796
+ type: "primary",
797
+ string: "25 Spring Street, Blackburn, VIC 3130",
798
+ name: "HQ US",
799
+ line1: "Main street",
800
+ line2: "apt #",
801
+ line3: "Suite #",
802
+ line4: "delivery instructions",
803
+ streetNumber: "25",
804
+ city: "San Francisco",
805
+ state: "CA",
806
+ postalCode: "94104",
807
+ country: "US",
808
+ latitude: "40.759211",
809
+ longitude: "-73.984638",
810
+ county: "Santa Clara",
811
+ contactName: "Elon Musk",
812
+ salutation: "Mr",
813
+ phoneNumber: "111-111-1111",
814
+ fax: "122-111-1111",
815
+ email: "elon@musk.com",
816
+ website: "https://elonmusk.com",
817
+ notes: "Address notes or delivery instructions.",
818
+ rowVersion: "1-12345",
819
+ },
820
+ },
821
+ companyId: "12345",
822
+ currency: "USD",
823
+ currencyRate: 0.69,
824
+ taxInclusive: true,
825
+ billDate: new Date("2020-09-30"),
826
+ dueDate: new Date("2020-10-30"),
827
+ paidDate: new Date("2020-10-30"),
828
+ poNumber: "90000117",
829
+ reference: "123456",
830
+ lineItems: [
831
+ {
832
+ rowId: "12345",
833
+ code: "120-C",
834
+ lineNumber: 1,
835
+ description:
836
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
837
+ type: "expense_account",
838
+ taxAmount: 27500,
839
+ totalAmount: 27500,
840
+ quantity: 1,
841
+ unitPrice: 27500.5,
842
+ unitOfMeasure: "pc.",
843
+ discountPercentage: 0.01,
844
+ discountAmount: 19.99,
845
+ locationId: "12345",
846
+ departmentId: "12345",
847
+ item: {
848
+ id: "12344",
849
+ code: "120-C",
850
+ name: "Model Y",
851
+ },
852
+ taxRate: {
853
+ id: "123456",
854
+ rate: 10,
855
+ },
856
+ ledgerAccount: {
857
+ id: "123456",
858
+ nominalCode: "N091",
859
+ code: "453",
860
+ },
861
+ trackingCategories: [
862
+ {
863
+ id: "123456",
864
+ name: "New York",
865
+ },
866
+ {
867
+ id: "123456",
868
+ name: "New York",
869
+ },
870
+ ],
871
+ rowVersion: "1-12345",
872
+ },
873
+ {
874
+ rowId: "12345",
875
+ code: "120-C",
876
+ lineNumber: 1,
877
+ description:
878
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
879
+ type: "expense_account",
880
+ taxAmount: 27500,
881
+ totalAmount: 27500,
882
+ quantity: 1,
883
+ unitPrice: 27500.5,
884
+ unitOfMeasure: "pc.",
885
+ discountPercentage: 0.01,
886
+ discountAmount: 19.99,
887
+ locationId: "12345",
888
+ departmentId: "12345",
889
+ item: {
890
+ id: "12344",
891
+ code: "120-C",
892
+ name: "Model Y",
893
+ },
894
+ taxRate: {
895
+ id: "123456",
896
+ rate: 10,
897
+ },
898
+ ledgerAccount: {
899
+ id: "123456",
900
+ nominalCode: "N091",
901
+ code: "453",
902
+ },
903
+ trackingCategories: [
904
+ {
905
+ id: "123456",
906
+ name: "New York",
907
+ },
908
+ {
909
+ id: "123456",
910
+ name: "New York",
911
+ },
912
+ ],
913
+ rowVersion: "1-12345",
914
+ },
915
+ ],
916
+ terms: "Net 30 days",
917
+ balance: 27500,
918
+ deposit: 0,
919
+ subTotal: 27500,
920
+ totalTax: 2500,
921
+ total: 27500,
922
+ taxCode: "1234",
923
+ notes: "Some notes about this bill.",
924
+ status: "draft",
925
+ ledgerAccount: {
926
+ id: "123456",
927
+ nominalCode: "N091",
928
+ code: "453",
929
+ },
930
+ paymentMethod: "cash",
931
+ channel: "email",
932
+ language: "EN",
933
+ accountingByRow: false,
934
+ bankAccount: {
935
+ bankName: "Monzo",
936
+ accountNumber: "123465",
937
+ accountName: "SPACEX LLC",
938
+ accountType: "credit_card",
939
+ iban: "CH2989144532982975332",
940
+ bic: "AUDSCHGGXXX",
941
+ routingNumber: "012345678",
942
+ bsbNumber: "062-001",
943
+ branchIdentifier: "001",
944
+ bankCode: "BNH",
945
+ currency: "USD",
946
+ },
947
+ discountPercentage: 5.5,
948
+ sourceDocumentUrl: "https://www.invoicesolution.com/bill/123456",
949
+ trackingCategories: [
950
+ {
951
+ id: "123456",
952
+ name: "New York",
953
+ },
954
+ ],
955
+ rowVersion: "1-12345",
956
+ customFields: [
957
+ {
958
+ id: "2389328923893298",
959
+ name: "employee_level",
960
+ description: "Employee Level",
961
+ value: {
962
+ "0": "<value>",
963
+ "1": "<value>",
964
+ "2": "<value>",
965
+ },
966
+ },
967
+ ],
968
+ passThrough: [
969
+ {
970
+ serviceId: "<id>",
971
+ extendPaths: [
972
+ {
973
+ path: "$.nested.property",
974
+ value: {
975
+ "TaxClassificationRef": {
976
+ "value": "EUC-99990201-V1-00020000",
977
+ },
978
+ },
979
+ },
980
+ ],
981
+ },
982
+ ],
983
+ accountingPeriod: "01-24",
984
+ },
985
+ });
986
+ expect(result.httpMeta.response.status).toBe(201);
987
+ expect(result.createBillResponse).toBeDefined();
988
+ expect(result.createBillResponse).toEqual({
989
+ statusCode: 200,
990
+ status: "OK",
991
+ service: "xero",
992
+ resource: "bills",
993
+ operation: "add",
994
+ data: {
995
+ id: "12345",
996
+ },
997
+ });
998
+ });
999
+
1000
+ test("Bills Accounting Bills One", async () => {
1001
+ const testHttpClient = createTestHTTPClient("accounting.billsOne");
1002
+
1003
+ const apideck = new Apideck({
1004
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
1005
+ httpClient: testHttpClient,
1006
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
1007
+ });
1008
+
1009
+ const result = await apideck.accounting.bills.get({
1010
+ id: "<id>",
1011
+ consumerId: "test-consumer",
1012
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
1013
+ serviceId: "salesforce",
1014
+ fields: "id,updated_at",
1015
+ });
1016
+ expect(result.httpMeta.response.status).toBe(200);
1017
+ expect(result.getBillResponse).toBeDefined();
1018
+ expect(result.getBillResponse).toEqual({
1019
+ statusCode: 200,
1020
+ status: "OK",
1021
+ service: "xero",
1022
+ resource: "bills",
1023
+ operation: "one",
1024
+ data: {
1025
+ id: "12345",
1026
+ downstreamId: "12345",
1027
+ billNumber: "10001",
1028
+ supplier: {
1029
+ id: "12345",
1030
+ displayId: "SUPP00101",
1031
+ displayName: "Windsurf Shop",
1032
+ companyName: "The boring company",
1033
+ address: {
1034
+ id: "123",
1035
+ type: "primary",
1036
+ string: "25 Spring Street, Blackburn, VIC 3130",
1037
+ name: "HQ US",
1038
+ line1: "Main street",
1039
+ line2: "apt #",
1040
+ line3: "Suite #",
1041
+ line4: "delivery instructions",
1042
+ streetNumber: "25",
1043
+ city: "San Francisco",
1044
+ state: "CA",
1045
+ postalCode: "94104",
1046
+ country: "US",
1047
+ latitude: "40.759211",
1048
+ longitude: "-73.984638",
1049
+ county: "Santa Clara",
1050
+ contactName: "Elon Musk",
1051
+ salutation: "Mr",
1052
+ phoneNumber: "111-111-1111",
1053
+ fax: "122-111-1111",
1054
+ email: "elon@musk.com",
1055
+ website: "https://elonmusk.com",
1056
+ notes: "Address notes or delivery instructions.",
1057
+ rowVersion: "1-12345",
1058
+ },
1059
+ },
1060
+ companyId: "12345",
1061
+ currency: "USD",
1062
+ currencyRate: 0.69,
1063
+ taxInclusive: true,
1064
+ billDate: new Date("2020-09-30"),
1065
+ dueDate: new Date("2020-10-30"),
1066
+ paidDate: new Date("2020-10-30"),
1067
+ poNumber: "90000117",
1068
+ reference: "123456",
1069
+ lineItems: [
1070
+ {
1071
+ id: "12345",
1072
+ rowId: "12345",
1073
+ code: "120-C",
1074
+ lineNumber: 1,
1075
+ description:
1076
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
1077
+ type: "expense_account",
1078
+ taxAmount: 27500,
1079
+ totalAmount: 27500,
1080
+ quantity: 1,
1081
+ unitPrice: 27500.5,
1082
+ unitOfMeasure: "pc.",
1083
+ discountPercentage: 0.01,
1084
+ discountAmount: 19.99,
1085
+ locationId: "12345",
1086
+ departmentId: "12345",
1087
+ item: {
1088
+ id: "12344",
1089
+ code: "120-C",
1090
+ name: "Model Y",
1091
+ },
1092
+ taxRate: {
1093
+ id: "123456",
1094
+ code: "N-T",
1095
+ name: "GST on Purchases",
1096
+ rate: 10,
1097
+ },
1098
+ ledgerAccount: {
1099
+ id: "123456",
1100
+ name: "Bank account",
1101
+ nominalCode: "N091",
1102
+ code: "453",
1103
+ },
1104
+ trackingCategories: [
1105
+ {
1106
+ id: "123456",
1107
+ name: "New York",
1108
+ },
1109
+ {
1110
+ id: "123456",
1111
+ name: "New York",
1112
+ },
1113
+ ],
1114
+ rowVersion: "1-12345",
1115
+ updatedBy: "12345",
1116
+ createdBy: "12345",
1117
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
1118
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
1119
+ },
1120
+ {
1121
+ id: "12345",
1122
+ rowId: "12345",
1123
+ code: "120-C",
1124
+ lineNumber: 1,
1125
+ description:
1126
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
1127
+ type: "expense_account",
1128
+ taxAmount: 27500,
1129
+ totalAmount: 27500,
1130
+ quantity: 1,
1131
+ unitPrice: 27500.5,
1132
+ unitOfMeasure: "pc.",
1133
+ discountPercentage: 0.01,
1134
+ discountAmount: 19.99,
1135
+ locationId: "12345",
1136
+ departmentId: "12345",
1137
+ item: {
1138
+ id: "12344",
1139
+ code: "120-C",
1140
+ name: "Model Y",
1141
+ },
1142
+ taxRate: {
1143
+ id: "123456",
1144
+ code: "N-T",
1145
+ name: "GST on Purchases",
1146
+ rate: 10,
1147
+ },
1148
+ ledgerAccount: {
1149
+ id: "123456",
1150
+ name: "Bank account",
1151
+ nominalCode: "N091",
1152
+ code: "453",
1153
+ },
1154
+ trackingCategories: [
1155
+ {
1156
+ id: "123456",
1157
+ name: "New York",
1158
+ },
1159
+ {
1160
+ id: "123456",
1161
+ name: "New York",
1162
+ },
1163
+ ],
1164
+ rowVersion: "1-12345",
1165
+ updatedBy: "12345",
1166
+ createdBy: "12345",
1167
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
1168
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
1169
+ },
1170
+ {
1171
+ id: "12345",
1172
+ rowId: "12345",
1173
+ code: "120-C",
1174
+ lineNumber: 1,
1175
+ description:
1176
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
1177
+ type: "expense_account",
1178
+ taxAmount: 27500,
1179
+ totalAmount: 27500,
1180
+ quantity: 1,
1181
+ unitPrice: 27500.5,
1182
+ unitOfMeasure: "pc.",
1183
+ discountPercentage: 0.01,
1184
+ discountAmount: 19.99,
1185
+ locationId: "12345",
1186
+ departmentId: "12345",
1187
+ item: {
1188
+ id: "12344",
1189
+ code: "120-C",
1190
+ name: "Model Y",
1191
+ },
1192
+ taxRate: {
1193
+ id: "123456",
1194
+ code: "N-T",
1195
+ name: "GST on Purchases",
1196
+ rate: 10,
1197
+ },
1198
+ ledgerAccount: {
1199
+ id: "123456",
1200
+ name: "Bank account",
1201
+ nominalCode: "N091",
1202
+ code: "453",
1203
+ },
1204
+ trackingCategories: [
1205
+ {
1206
+ id: "123456",
1207
+ name: "New York",
1208
+ },
1209
+ {
1210
+ id: "123456",
1211
+ name: "New York",
1212
+ },
1213
+ ],
1214
+ rowVersion: "1-12345",
1215
+ updatedBy: "12345",
1216
+ createdBy: "12345",
1217
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
1218
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
1219
+ },
1220
+ ],
1221
+ terms: "Net 30 days",
1222
+ balance: 27500,
1223
+ deposit: 0,
1224
+ subTotal: 27500,
1225
+ totalTax: 2500,
1226
+ total: 27500,
1227
+ taxCode: "1234",
1228
+ notes: "Some notes about this bill.",
1229
+ status: "draft",
1230
+ ledgerAccount: {
1231
+ id: "123456",
1232
+ name: "Bank account",
1233
+ nominalCode: "N091",
1234
+ code: "453",
1235
+ },
1236
+ paymentMethod: "cash",
1237
+ channel: "email",
1238
+ language: "EN",
1239
+ accountingByRow: false,
1240
+ bankAccount: {
1241
+ bankName: "Monzo",
1242
+ accountNumber: "123465",
1243
+ accountName: "SPACEX LLC",
1244
+ accountType: "credit_card",
1245
+ iban: "CH2989144532982975332",
1246
+ bic: "AUDSCHGGXXX",
1247
+ routingNumber: "012345678",
1248
+ bsbNumber: "062-001",
1249
+ branchIdentifier: "001",
1250
+ bankCode: "BNH",
1251
+ currency: "USD",
1252
+ },
1253
+ discountPercentage: 5.5,
1254
+ sourceDocumentUrl: "https://www.invoicesolution.com/bill/123456",
1255
+ trackingCategories: [
1256
+ {
1257
+ id: "123456",
1258
+ name: "New York",
1259
+ },
1260
+ {
1261
+ id: "123456",
1262
+ name: "New York",
1263
+ },
1264
+ {
1265
+ id: "123456",
1266
+ name: "New York",
1267
+ },
1268
+ ],
1269
+ updatedBy: "12345",
1270
+ createdBy: "12345",
1271
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
1272
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
1273
+ rowVersion: "1-12345",
1274
+ customFields: [
1275
+ {
1276
+ id: "2389328923893298",
1277
+ name: "employee_level",
1278
+ description: "Employee Level",
1279
+ value: true,
1280
+ },
1281
+ {
1282
+ id: "2389328923893298",
1283
+ name: "employee_level",
1284
+ description: "Employee Level",
1285
+ value: 10,
1286
+ },
1287
+ ],
1288
+ passThrough: [
1289
+ {
1290
+ serviceId: "<id>",
1291
+ extendPaths: [
1292
+ {
1293
+ path: "$.nested.property",
1294
+ value: {
1295
+ "TaxClassificationRef": {
1296
+ "value": "EUC-99990201-V1-00020000",
1297
+ },
1298
+ },
1299
+ },
1300
+ {
1301
+ path: "$.nested.property",
1302
+ value: {
1303
+ "TaxClassificationRef": {
1304
+ "value": "EUC-99990201-V1-00020000",
1305
+ },
1306
+ },
1307
+ },
1308
+ {
1309
+ path: "$.nested.property",
1310
+ value: {
1311
+ "TaxClassificationRef": {
1312
+ "value": "EUC-99990201-V1-00020000",
1313
+ },
1314
+ },
1315
+ },
1316
+ ],
1317
+ },
1318
+ ],
1319
+ accountingPeriod: "01-24",
1320
+ },
1321
+ });
1322
+ });
1323
+
1324
+ test("Bills Accounting Bills Update", async () => {
1325
+ const testHttpClient = createTestHTTPClient("accounting.billsUpdate");
1326
+
1327
+ const apideck = new Apideck({
1328
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
1329
+ httpClient: testHttpClient,
1330
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
1331
+ });
1332
+
1333
+ const result = await apideck.accounting.bills.update({
1334
+ id: "<id>",
1335
+ consumerId: "test-consumer",
1336
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
1337
+ serviceId: "salesforce",
1338
+ bill: {
1339
+ billNumber: "10001",
1340
+ supplier: {
1341
+ id: "12345",
1342
+ displayName: "Windsurf Shop",
1343
+ address: {
1344
+ id: "123",
1345
+ type: "primary",
1346
+ string: "25 Spring Street, Blackburn, VIC 3130",
1347
+ name: "HQ US",
1348
+ line1: "Main street",
1349
+ line2: "apt #",
1350
+ line3: "Suite #",
1351
+ line4: "delivery instructions",
1352
+ streetNumber: "25",
1353
+ city: "San Francisco",
1354
+ state: "CA",
1355
+ postalCode: "94104",
1356
+ country: "US",
1357
+ latitude: "40.759211",
1358
+ longitude: "-73.984638",
1359
+ county: "Santa Clara",
1360
+ contactName: "Elon Musk",
1361
+ salutation: "Mr",
1362
+ phoneNumber: "111-111-1111",
1363
+ fax: "122-111-1111",
1364
+ email: "elon@musk.com",
1365
+ website: "https://elonmusk.com",
1366
+ notes: "Address notes or delivery instructions.",
1367
+ rowVersion: "1-12345",
1368
+ },
1369
+ },
1370
+ companyId: "12345",
1371
+ currency: "USD",
1372
+ currencyRate: 0.69,
1373
+ taxInclusive: true,
1374
+ billDate: new Date("2020-09-30"),
1375
+ dueDate: new Date("2020-10-30"),
1376
+ paidDate: new Date("2020-10-30"),
1377
+ poNumber: "90000117",
1378
+ reference: "123456",
1379
+ lineItems: [
1380
+ {
1381
+ rowId: "12345",
1382
+ code: "120-C",
1383
+ lineNumber: 1,
1384
+ description:
1385
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
1386
+ type: "expense_account",
1387
+ taxAmount: 27500,
1388
+ totalAmount: 27500,
1389
+ quantity: 1,
1390
+ unitPrice: 27500.5,
1391
+ unitOfMeasure: "pc.",
1392
+ discountPercentage: 0.01,
1393
+ discountAmount: 19.99,
1394
+ locationId: "12345",
1395
+ departmentId: "12345",
1396
+ item: {
1397
+ id: "12344",
1398
+ code: "120-C",
1399
+ name: "Model Y",
1400
+ },
1401
+ taxRate: {
1402
+ id: "123456",
1403
+ rate: 10,
1404
+ },
1405
+ ledgerAccount: {
1406
+ id: "123456",
1407
+ nominalCode: "N091",
1408
+ code: "453",
1409
+ },
1410
+ trackingCategories: [
1411
+ {
1412
+ id: "123456",
1413
+ name: "New York",
1414
+ },
1415
+ {
1416
+ id: "123456",
1417
+ name: "New York",
1418
+ },
1419
+ ],
1420
+ rowVersion: "1-12345",
1421
+ },
1422
+ {
1423
+ rowId: "12345",
1424
+ code: "120-C",
1425
+ lineNumber: 1,
1426
+ description:
1427
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
1428
+ type: "expense_account",
1429
+ taxAmount: 27500,
1430
+ totalAmount: 27500,
1431
+ quantity: 1,
1432
+ unitPrice: 27500.5,
1433
+ unitOfMeasure: "pc.",
1434
+ discountPercentage: 0.01,
1435
+ discountAmount: 19.99,
1436
+ locationId: "12345",
1437
+ departmentId: "12345",
1438
+ item: {
1439
+ id: "12344",
1440
+ code: "120-C",
1441
+ name: "Model Y",
1442
+ },
1443
+ taxRate: {
1444
+ id: "123456",
1445
+ rate: 10,
1446
+ },
1447
+ ledgerAccount: {
1448
+ id: "123456",
1449
+ nominalCode: "N091",
1450
+ code: "453",
1451
+ },
1452
+ trackingCategories: [
1453
+ {
1454
+ id: "123456",
1455
+ name: "New York",
1456
+ },
1457
+ {
1458
+ id: "123456",
1459
+ name: "New York",
1460
+ },
1461
+ ],
1462
+ rowVersion: "1-12345",
1463
+ },
1464
+ {
1465
+ rowId: "12345",
1466
+ code: "120-C",
1467
+ lineNumber: 1,
1468
+ description:
1469
+ "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
1470
+ type: "expense_account",
1471
+ taxAmount: 27500,
1472
+ totalAmount: 27500,
1473
+ quantity: 1,
1474
+ unitPrice: 27500.5,
1475
+ unitOfMeasure: "pc.",
1476
+ discountPercentage: 0.01,
1477
+ discountAmount: 19.99,
1478
+ locationId: "12345",
1479
+ departmentId: "12345",
1480
+ item: {
1481
+ id: "12344",
1482
+ code: "120-C",
1483
+ name: "Model Y",
1484
+ },
1485
+ taxRate: {
1486
+ id: "123456",
1487
+ rate: 10,
1488
+ },
1489
+ ledgerAccount: {
1490
+ id: "123456",
1491
+ nominalCode: "N091",
1492
+ code: "453",
1493
+ },
1494
+ trackingCategories: [
1495
+ {
1496
+ id: "123456",
1497
+ name: "New York",
1498
+ },
1499
+ {
1500
+ id: "123456",
1501
+ name: "New York",
1502
+ },
1503
+ {
1504
+ id: "123456",
1505
+ name: "New York",
1506
+ },
1507
+ ],
1508
+ rowVersion: "1-12345",
1509
+ },
1510
+ ],
1511
+ terms: "Net 30 days",
1512
+ balance: 27500,
1513
+ deposit: 0,
1514
+ subTotal: 27500,
1515
+ totalTax: 2500,
1516
+ total: 27500,
1517
+ taxCode: "1234",
1518
+ notes: "Some notes about this bill.",
1519
+ status: "draft",
1520
+ ledgerAccount: {
1521
+ id: "123456",
1522
+ nominalCode: "N091",
1523
+ code: "453",
1524
+ },
1525
+ paymentMethod: "cash",
1526
+ channel: "email",
1527
+ language: "EN",
1528
+ accountingByRow: false,
1529
+ bankAccount: {
1530
+ bankName: "Monzo",
1531
+ accountNumber: "123465",
1532
+ accountName: "SPACEX LLC",
1533
+ accountType: "credit_card",
1534
+ iban: "CH2989144532982975332",
1535
+ bic: "AUDSCHGGXXX",
1536
+ routingNumber: "012345678",
1537
+ bsbNumber: "062-001",
1538
+ branchIdentifier: "001",
1539
+ bankCode: "BNH",
1540
+ currency: "USD",
1541
+ },
1542
+ discountPercentage: 5.5,
1543
+ sourceDocumentUrl: "https://www.invoicesolution.com/bill/123456",
1544
+ trackingCategories: [
1545
+ {
1546
+ id: "123456",
1547
+ name: "New York",
1548
+ },
1549
+ {
1550
+ id: "123456",
1551
+ name: "New York",
1552
+ },
1553
+ ],
1554
+ rowVersion: "1-12345",
1555
+ customFields: [
1556
+ {
1557
+ id: "2389328923893298",
1558
+ name: "employee_level",
1559
+ description: "Employee Level",
1560
+ value: {},
1561
+ },
1562
+ {
1563
+ id: "2389328923893298",
1564
+ name: "employee_level",
1565
+ description: "Employee Level",
1566
+ value: {
1567
+ "0": {},
1568
+ },
1569
+ },
1570
+ ],
1571
+ passThrough: [
1572
+ {
1573
+ serviceId: "<id>",
1574
+ extendPaths: [
1575
+ {
1576
+ path: "$.nested.property",
1577
+ value: {
1578
+ "TaxClassificationRef": {
1579
+ "value": "EUC-99990201-V1-00020000",
1580
+ },
1581
+ },
1582
+ },
1583
+ ],
1584
+ },
1585
+ ],
1586
+ accountingPeriod: "01-24",
1587
+ },
1588
+ });
1589
+ expect(result.httpMeta.response.status).toBe(200);
1590
+ expect(result.updateBillResponse).toBeDefined();
1591
+ expect(result.updateBillResponse).toEqual({
1592
+ statusCode: 200,
1593
+ status: "OK",
1594
+ service: "xero",
1595
+ resource: "bills",
1596
+ operation: "update",
1597
+ data: {
1598
+ id: "12345",
1599
+ },
1600
+ });
1601
+ });
1602
+
1603
+ test("Bills Accounting Bills Delete", async () => {
1604
+ const testHttpClient = createTestHTTPClient("accounting.billsDelete");
1605
+
1606
+ const apideck = new Apideck({
1607
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
1608
+ httpClient: testHttpClient,
1609
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
1610
+ });
1611
+
1612
+ const result = await apideck.accounting.bills.delete({
1613
+ id: "<id>",
1614
+ consumerId: "test-consumer",
1615
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
1616
+ serviceId: "salesforce",
1617
+ });
1618
+ expect(result.httpMeta.response.status).toBe(200);
1619
+ expect(result.deleteBillResponse).toBeDefined();
1620
+ expect(result.deleteBillResponse).toEqual({
1621
+ statusCode: 200,
1622
+ status: "OK",
1623
+ service: "xero",
1624
+ resource: "bills",
1625
+ operation: "delete",
1626
+ data: {
1627
+ id: "12345",
1628
+ },
1629
+ });
1630
+ });