/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { expect, test } from "vitest"; import { Apideck } from "../index.js"; import { createTestHTTPClient } from "./testclient.js"; test("Purchaseorders Accounting Purchase Orders All", async () => { const testHttpClient = createTestHTTPClient("accounting.purchaseOrdersAll"); const apideck = new Apideck({ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080", httpClient: testHttpClient, apiKey: process.env["APIDECK_API_KEY"] ?? "value", }); const result = await apideck.accounting.purchaseOrders.list({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", passThrough: { "search": "San Francisco", }, filter: { updatedSince: new Date("2020-09-30T07:43:32.000Z"), supplierId: "1234", }, sort: { by: "updated_at", direction: "desc", }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.getPurchaseOrdersResponse).toBeDefined(); expect(result.getPurchaseOrdersResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "PurchaseOrders", operation: "all", data: [ { id: "12345", downstreamId: "12345", poNumber: "90000117", reference: "123456", supplier: { id: "12345", displayId: "SUPP00101", displayName: "Windsurf Shop", companyName: "The boring company", address: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, }, companyId: "12345", status: "open", issuedDate: new Date("2020-09-30"), deliveryDate: new Date("2020-09-30"), expectedArrivalDate: new Date("2020-09-30"), currency: "USD", currencyRate: 0.69, subTotal: 27500, totalTax: 2500, total: 27500, taxInclusive: true, lineItems: [ { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: 10, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), }, { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), }, ], shippingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, templateId: "123456", discountPercentage: 5.5, bankAccount: { bankName: "Monzo", accountNumber: "123465", accountName: "SPACEX LLC", accountType: "credit_card", iban: "CH2989144532982975332", bic: "AUDSCHGGXXX", routingNumber: "012345678", bsbNumber: "062-001", branchIdentifier: "001", bankCode: "BNH", currency: "USD", }, accountingByRow: false, dueDate: new Date("2020-10-30"), paymentMethod: "cash", taxCode: "1234", channel: "email", memo: "Thank you for the partnership and have a great day!", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: new Date("2020-09-30T07:43:32.000Z"), passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, { id: "12345", downstreamId: "12345", poNumber: "90000117", reference: "123456", supplier: { id: "12345", displayId: "SUPP00101", displayName: "Windsurf Shop", companyName: "The boring company", address: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, }, companyId: "12345", status: "open", issuedDate: new Date("2020-09-30"), deliveryDate: new Date("2020-09-30"), expectedArrivalDate: new Date("2020-09-30"), currency: "USD", currencyRate: 0.69, subTotal: 27500, totalTax: 2500, total: 27500, taxInclusive: true, lineItems: [ { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, "1": {}, }, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), }, ], shippingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, templateId: "123456", discountPercentage: 5.5, bankAccount: { bankName: "Monzo", accountNumber: "123465", accountName: "SPACEX LLC", accountType: "credit_card", iban: "CH2989144532982975332", bic: "AUDSCHGGXXX", routingNumber: "012345678", bsbNumber: "062-001", branchIdentifier: "001", bankCode: "BNH", currency: "USD", }, accountingByRow: false, dueDate: new Date("2020-10-30"), paymentMethod: "cash", taxCode: "1234", channel: "email", memo: "Thank you for the partnership and have a great day!", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: 10, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: new Date("2020-09-30T07:43:32.000Z"), passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, { id: "12345", downstreamId: "12345", poNumber: "90000117", reference: "123456", supplier: { id: "12345", displayId: "SUPP00101", displayName: "Windsurf Shop", companyName: "The boring company", address: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, }, companyId: "12345", status: "open", issuedDate: new Date("2020-09-30"), deliveryDate: new Date("2020-09-30"), expectedArrivalDate: new Date("2020-09-30"), currency: "USD", currencyRate: 0.69, subTotal: 27500, totalTax: 2500, total: 27500, taxInclusive: true, lineItems: [ { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), }, { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: true, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: true, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), }, { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, }, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, }, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), }, ], shippingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, templateId: "123456", discountPercentage: 5.5, bankAccount: { bankName: "Monzo", accountNumber: "123465", accountName: "SPACEX LLC", accountType: "credit_card", iban: "CH2989144532982975332", bic: "AUDSCHGGXXX", routingNumber: "012345678", bsbNumber: "062-001", branchIdentifier: "001", bankCode: "BNH", currency: "USD", }, accountingByRow: false, dueDate: new Date("2020-10-30"), paymentMethod: "cash", taxCode: "1234", channel: "email", memo: "Thank you for the partnership and have a great day!", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: 10, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: new Date("2020-09-30T07:43:32.000Z"), passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, ], meta: { itemsOnPage: 50, cursors: { previous: "em9oby1jcm06OnBhZ2U6OjE=", current: "em9oby1jcm06OnBhZ2U6OjI=", next: "em9oby1jcm06OnBhZ2U6OjM=", }, }, links: { previous: "https://unify.apideck.com/crm/companies?cursor=em9oby1jcm06OnBhZ2U6OjE%3D", current: "https://unify.apideck.com/crm/companies", next: "https://unify.apideck.com/crm/companies?cursor=em9oby1jcm06OnBhZ2U6OjM", }, }); }); test("Purchaseorders Accounting Purchase Orders Add", async () => { const testHttpClient = createTestHTTPClient("accounting.purchaseOrdersAdd"); const apideck = new Apideck({ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080", httpClient: testHttpClient, apiKey: process.env["APIDECK_API_KEY"] ?? "value", }); const result = await apideck.accounting.purchaseOrders.create({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", purchaseOrder: { poNumber: "90000117", reference: "123456", supplier: { id: "12345", displayName: "Windsurf Shop", address: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, }, companyId: "12345", status: "open", issuedDate: new Date("2020-09-30"), deliveryDate: new Date("2020-09-30"), expectedArrivalDate: new Date("2020-09-30"), currency: "USD", currencyRate: 0.69, subTotal: 27500, totalTax: 2500, total: 27500, taxInclusive: true, lineItems: [ { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], rowVersion: "1-12345", }, { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: 10, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], rowVersion: "1-12345", }, ], shippingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, ledgerAccount: { id: "123456", nominalCode: "N091", code: "453", }, templateId: "123456", discountPercentage: 5.5, bankAccount: { bankName: "Monzo", accountNumber: "123465", accountName: "SPACEX LLC", accountType: "credit_card", iban: "CH2989144532982975332", bic: "AUDSCHGGXXX", routingNumber: "012345678", bsbNumber: "062-001", branchIdentifier: "001", bankCode: "BNH", currency: "USD", }, accountingByRow: false, dueDate: new Date("2020-10-30"), paymentMethod: "cash", taxCode: "1234", channel: "email", memo: "Thank you for the partnership and have a great day!", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": "", "1": "", "2": "", }, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: true, }, ], rowVersion: "1-12345", passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); expect(result.httpMeta.response.status).toBe(201); expect(result.createPurchaseOrderResponse).toBeDefined(); expect(result.createPurchaseOrderResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "PurchaseOrders", operation: "add", data: { id: "12345", }, }); }); test("Purchaseorders Accounting Purchase Orders One", async () => { const testHttpClient = createTestHTTPClient("accounting.purchaseOrdersOne"); const apideck = new Apideck({ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080", httpClient: testHttpClient, apiKey: process.env["APIDECK_API_KEY"] ?? "value", }); const result = await apideck.accounting.purchaseOrders.get({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getPurchaseOrderResponse).toBeDefined(); expect(result.getPurchaseOrderResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "PurchaseOrders", operation: "one", data: { id: "12345", downstreamId: "12345", poNumber: "90000117", reference: "123456", supplier: { id: "12345", displayId: "SUPP00101", displayName: "Windsurf Shop", companyName: "The boring company", address: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, }, companyId: "12345", status: "open", issuedDate: new Date("2020-09-30"), deliveryDate: new Date("2020-09-30"), expectedArrivalDate: new Date("2020-09-30"), currency: "USD", currencyRate: 0.69, subTotal: 27500, totalTax: 2500, total: 27500, taxInclusive: true, lineItems: [ { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, }, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), }, { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: 10, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), }, { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: 10, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), }, ], shippingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, templateId: "123456", discountPercentage: 5.5, bankAccount: { bankName: "Monzo", accountNumber: "123465", accountName: "SPACEX LLC", accountType: "credit_card", iban: "CH2989144532982975332", bic: "AUDSCHGGXXX", routingNumber: "012345678", bsbNumber: "062-001", branchIdentifier: "001", bankCode: "BNH", currency: "USD", }, accountingByRow: false, dueDate: new Date("2020-10-30"), paymentMethod: "cash", taxCode: "1234", channel: "email", memo: "Thank you for the partnership and have a great day!", trackingCategories: [ { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: new Date("2020-09-30T07:43:32.000Z"), passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); }); test("Purchaseorders Accounting Purchase Orders Update", async () => { const testHttpClient = createTestHTTPClient( "accounting.purchaseOrdersUpdate", ); const apideck = new Apideck({ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080", httpClient: testHttpClient, apiKey: process.env["APIDECK_API_KEY"] ?? "value", }); const result = await apideck.accounting.purchaseOrders.update({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", purchaseOrder: { poNumber: "90000117", reference: "123456", supplier: { id: "12345", displayName: "Windsurf Shop", address: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, }, companyId: "12345", status: "open", issuedDate: new Date("2020-09-30"), deliveryDate: new Date("2020-09-30"), expectedArrivalDate: new Date("2020-09-30"), currency: "USD", currencyRate: 0.69, subTotal: 27500, totalTax: 2500, total: 27500, taxInclusive: true, lineItems: [ { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, "1": {}, }, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: true, }, ], rowVersion: "1-12345", }, { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, }, }, ], rowVersion: "1-12345", }, { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, locationId: "12345", departmentId: "12345", item: { id: "12344", code: "120-C", name: "Model Y", }, taxRate: { id: "123456", rate: 10, }, trackingCategories: [ { id: "123456", name: "New York", }, ], ledgerAccount: { id: "123456", nominalCode: "N091", code: "453", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], rowVersion: "1-12345", }, ], shippingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, ledgerAccount: { id: "123456", nominalCode: "N091", code: "453", }, templateId: "123456", discountPercentage: 5.5, bankAccount: { bankName: "Monzo", accountNumber: "123465", accountName: "SPACEX LLC", accountType: "credit_card", iban: "CH2989144532982975332", bic: "AUDSCHGGXXX", routingNumber: "012345678", bsbNumber: "062-001", branchIdentifier: "001", bankCode: "BNH", currency: "USD", }, accountingByRow: false, dueDate: new Date("2020-10-30"), paymentMethod: "cash", taxCode: "1234", channel: "email", memo: "Thank you for the partnership and have a great day!", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: 10, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: true, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": "", "1": "", }, }, ], rowVersion: "1-12345", passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.updatePurchaseOrderResponse).toBeDefined(); expect(result.updatePurchaseOrderResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "PurchaseOrders", operation: "update", data: { id: "12345", }, }); }); test("Purchaseorders Accounting Purchase Orders Delete", async () => { const testHttpClient = createTestHTTPClient( "accounting.purchaseOrdersDelete", ); const apideck = new Apideck({ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080", httpClient: testHttpClient, apiKey: process.env["APIDECK_API_KEY"] ?? "value", }); const result = await apideck.accounting.purchaseOrders.delete({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", }); expect(result.httpMeta.response.status).toBe(200); expect(result.deletePurchaseOrderResponse).toBeDefined(); expect(result.deletePurchaseOrderResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "PurchaseOrders", operation: "delete", data: { id: "12345", }, }); });