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AGA,aAAqBmF,SAAYhN,EAAauH,EAAwB,CAGpE,OAFkB,MAAM,KAAKmH,YAAY1O,EAAKuH,CAAI,GAEtCM,IACd,CAGA,aAAqB6G,YAAe1O,EAAauH,EAAwB,CACvE,IAAIwJ,EAEJ,GAAI,CACFA,EAAW,MAAM9C,EAAAA,EAAiBjB,SAAShN,EAAIc,SAAS,EAAGqN,KAAKC,UAAU7G,CAAI,EAAG,CAC/E,eAAgB,kBAClB,CAAC,CACH,MAAQ,CACN,MAAM,IAAI0H,EAAAA,EACRzC,EACAD,EAAW0H,gCACb,CACF,CAEA,MAAMnF,EAAO,MAAMiC,EAASjC,KAAK,EAEjC,GAAI,CAACA,EAAKE,UACR,MAAM,IAAIC,EAAAA,EAAcH,EAAKI,QAASJ,EAAKK,SAAS,EAGtD,OAAOL,CACT,CAGA,aAAqBtB,UAAaxN,EAAUuH,EAAwB,CAClE,IAAIwJ,EAEJ,GAAI,CACFA,EAAW,MAAM9C,EAAAA,EAAiBT,UAAUxN,EAAIc,SAAS,EAAGqN,KAAKC,UAAU7G,CAAI,EAAG,CAChF,eAAgB,kBAClB,CAAC,CACH,MAAQ,CACN,MAAM,IAAI0H,EAAAA,EACRzC,EACAD,EAAW0H,gCACb,CACF,CAEA,MAAMnF,EAAO,MAAMiC,EAASjC,KAAK,EAEjC,GAAI,CAACA,EAAKE,UACR,MAAM,IAAIC,EAAAA,EAAcH,EAAKI,QAASJ,EAAKK,SAAS,EAGtD,OAAOL,EAAKjH,IACd,CACF,C,mCCnoCe,MAAMoH,UAAsBiF,KAAM,CAK/CC,YAAYjF,EAAiBiB,EAAiB,CAC5C,MAAMjB,CAAO,EACb,KAAKiB,OAASA,CAChB,CACF,C","sources":["webpack:///./features/accounting-software/api/helpers.ts","webpack:///./features/accounting-software/utils/getAccountingSoftwareName.ts","webpack:///./features/accounting-software/types/AccountingSoftwareBillStatus.ts","webpack:///./features/accounting-software/services/companyAccountingSoftware.ts","webpack:///./features/accounting-software/types/SyncType.ts","webpack:///./features/accounting-software/types/reconciliationSettings.ts","webpack:///./legacy/features/companies/documents/services/document.ts","webpack:///./legacy/features/companies/documents/services/documentError.ts"],"sourcesContent":["import { API_PREFIX } from './constants';\n\n/**\n * Returns an API URL for accounting software endpoints\n * @param companyId Company ID\n * @param endpoint Accounting software endpoint\n * @param query Query string parameters\n * @returns API URL\n * @throws Error if `companyId` or `endpoint` is not provided\n * @example\n * ```\n * apiUrl('companyId', 'endpoint');\n * // => 'https://api.plooto.com/v1/companies/companyId/accountingSoftware/endpoint'\n * ```\n */\nconst apiUrl = (companyId: string, endpoint?: string, query?: Record): string => {\n const cleanEndpoint = endpoint ? `/${endpoint.replace(/^\\//, '')}` : '';\n const url = new URL(\n `${import.meta.env.APP_URLS_API_URL}/${API_PREFIX}` +\n `/companies/${companyId}/accountingSoftware${cleanEndpoint}`\n );\n\n if (query) {\n Object.entries(query).forEach(([key, value]) => {\n url.searchParams.set(key, value);\n });\n }\n\n return url.toString();\n};\n\nexport { apiUrl };\n","import { Instance as companyAccountingSoftwareService } from '../services/companyAccountingSoftware';\n\n/**\n * Get name of accounting software package for the current company.\n */\nexport function getAccountingSoftwareName(): string {\n const accountingSoftware = companyAccountingSoftwareService.softwarePackage;\n return accountingSoftware?.name ?? '';\n}\n","enum AccountingSoftwareBillStatus {\n Unknown = 'Unknown',\n /** This is the first step at marking the bill for payment */\n PayBill = 'PayBill',\n /** Wait until we have a payment that's scheduled so we can proceed with other reconcilation parts */\n WaitForScheduledPayment = 'WaitForScheduledPayment',\n TransferFromClearingToBank = 'TransferFromClearingToBank',\n TransferFeeFromClearing = 'TransferFeeFromClearing',\n ForexTransferBetweenPlootoClearing = 'ForexTransferBetweenPlootoClearing',\n Completed = 'Completed',\n Deleted = 'Deleted',\n Error = 'Error',\n UnreconciliationCompleted = 'UnreconciliationCompleted',\n ManuallyReconciled = 'ManuallyReconciled',\n ManuallyUnreconciled = 'ManuallyUnreconciled',\n UpdateFxRate = 'UpdateFxRate',\n PendingUnreconciliation = 'PendingUnreconciliation',\n}\n\nexport default AccountingSoftwareBillStatus;\n","import * as ko from 'knockout';\nimport $ from 'jquery';\nimport { isNil } from 'lodash-es';\n\nimport { SUPPORTED_ACCOUNTING_CURRENCIES } from '@/config/env';\nimport { ApiService } from '@/features/api';\nimport { AccountingSoftwareIntegrationEventsServiceEventType } from '@/legacy/features/companies/accountingSoftware/analytics/helper';\nimport { Instance as companyService, PermissionId } from '@/legacy/services/company';\nimport CompanyEventService from '@/legacy/services/companyEventService';\nimport * as viewModels from '@/legacy/viewmodels/viewModels';\n\nimport { apiUrl } from '../api/helpers';\nimport AccountingSoftwareBillAttachmentDetails from '../types/AccountingSoftwareBillAttachmentDetails';\nimport AccountingSoftwareBillViewModel from '../types/AccountingSoftwareBillViewModel';\nimport AttachmentDetails from '../types/AttachmentDetails';\nimport Bill from '../types/Bill';\nimport FileAttachment from '../types/FileAttachment';\nimport Invoice from '../types/Invoice';\nimport { SupportedAccountingSoftware } from '../types/SupportedAccountingSoftware';\nimport { SyncState } from '../types/SyncState';\nimport SyncType from '../types/SyncType';\n\nimport { Instance as accountingSoftwareService } from './accountingSoftware';\n\ntype ResyncOptions = {\n /** Type of synchronization (default: auto) */\n syncType?: SyncType;\n /** Synchronize bills (default: true) */\n syncBills?: boolean;\n /** Synchronize invoices (default: true) */\n syncInvoices?: boolean;\n};\n\nexport class CompanyAccountingSoftwareService {\n private companyService = companyService;\n\n private accountingSoftwareService = accountingSoftwareService;\n\n public static billsLoadingError = ko.observable('');\n\n public static newBills = ko.observableArray();\n\n public static invoicesLoadingError = ko.observable('');\n\n public static newInvoices = ko.observableArray();\n\n /**\n * Sync status of the company accounting software\n *\n * WARNING: Sets state to idle when the sync is complete and adds special error states\n * @deprecated use `syncState` instead\n */\n public syncStatus = ko.observable('idle');\n\n /**\n * Sync state of the company accounting software\n */\n public syncState = ko.observable('idle');\n\n public lastSyncedAt = ko.observable();\n\n public HasUnsupportedBills = ko.observable(false);\n\n public HasUnsupportedInvoices = ko.observable(false);\n\n private get companyId(): string {\n return this.companyService.CompanyId();\n }\n\n /** Accounting software package type observable for current company */\n public softwareTypeObservable = ko.pureComputed({\n read: () => {\n const companyMembership = this.companyService.membership();\n if (companyMembership === undefined || !ko.isObservable(companyMembership.company)) {\n return undefined;\n }\n const retVal = companyMembership.company().accountingSoftware();\n return retVal;\n },\n deferEvaluation: true,\n });\n\n /** Accounting software package observable for current company */\n public softwarePackageObservable = ko.pureComputed({\n read: () => {\n const id = this.softwareTypeObservable();\n return id ? this.accountingSoftwareService.GetPackage(id) : undefined;\n },\n deferEvaluation: true,\n });\n\n /** Accounting software package for current company */\n public get softwarePackage() {\n return this.softwarePackageObservable();\n }\n\n /** Check if company has accounting software connected and configured */\n public hasSoftwareConnected: KnockoutComputed = ko.pureComputed({\n read: () => !isNil(this.softwarePackageObservable()),\n deferEvaluation: true,\n });\n\n /**\n * Resync company accounting software, along with bills and invoices (by default),\n * if allowed by current user permissions\n * @param options {@link ResyncOptions}\n * @returns Promise that resolves when the sync is complete\n */\n public resync({\n syncType = SyncType.Auto,\n syncBills = true,\n syncInvoices = true,\n }: ResyncOptions = {}) {\n if (!this.hasSoftwareConnected()) {\n return undefined;\n }\n\n let syncBillsAccordingToPermissions = syncBills;\n let syncInvoicesAccordingToPermissions = syncInvoices;\n if (!this.companyService.HasPermissionTo(PermissionId.PAYMENT_ADD_EDIT)) {\n syncBillsAccordingToPermissions = false;\n syncInvoicesAccordingToPermissions = false;\n }\n\n this.clearSelectedPayments();\n\n this.syncStatus('syncing');\n this.syncState('syncing');\n\n // See `if (!this.hasSoftwareConnected())` above.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.softwarePackage!.SyncData(syncType)\n .then(() => (syncBillsAccordingToPermissions ? this.UpdateBills() : Promise.resolve()))\n .then(() => (syncInvoicesAccordingToPermissions ? this.UpdateInvoices() : Promise.resolve()))\n .then(() => {\n const state = 'connected';\n\n this.syncStatus('idle');\n this.syncState(state);\n this.fireAccountingSoftwareSyncEvent(state);\n this.lastSyncedAt(new Date());\n })\n .catch((errorInfo) => {\n const state = 'error';\n\n this.syncStatus(state);\n this.syncState(state);\n this.fireAccountingSoftwareSyncEvent(\n errorInfo?.type === 'expired.oauth' ? 'expired' : state\n );\n\n this.clearSelectedPayments();\n\n if (\n errorInfo &&\n (errorInfo.type === 'expired.oauth' || errorInfo.type === 'error.tooManyRequests')\n ) {\n this.syncStatus(errorInfo.type);\n }\n });\n }\n\n public RefreshInvoices() {\n if (!this.hasSoftwareConnected()) {\n return undefined;\n }\n\n return this.UpdateInvoices();\n }\n\n public RefreshBills() {\n if (!this.hasSoftwareConnected()) {\n return undefined;\n }\n\n return this.UpdateBills();\n }\n\n /** Disconnect company from accounting software */\n public async disconnect(): Promise {\n if (!this.hasSoftwareConnected()) {\n return;\n }\n\n // See `if (!this.hasSoftwareConnected())` above.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const accountingPlatform = this.softwarePackage!.id;\n\n await ApiService.remove(apiUrl(this.companyId));\n\n this.syncState('unset');\n this.lastSyncedAt(undefined);\n\n this.clearSelectedPayments();\n\n CompanyEventService.emit(\n AccountingSoftwareIntegrationEventsServiceEventType.AccountingPlatformDisconnected,\n {\n accountingPlatform,\n state: 'unlinked',\n }\n );\n }\n\n /**\n * Reset company accounting software sync state and clear selected payments\n */\n public resetSyncState() {\n this.syncState('idle');\n this.lastSyncedAt(undefined);\n\n this.clearSelectedPayments();\n }\n\n /**\n * Expire company accounting software sync state for current\n * company and clear selected payments\n */\n public expireSyncState() {\n this.syncState('expired');\n\n this.clearSelectedPayments();\n }\n\n /**\n * Clear selected bills and invoices\n */\n private clearSelectedPayments() {\n CompanyAccountingSoftwareService.newBills.removeAll();\n CompanyAccountingSoftwareService.newInvoices.removeAll();\n\n this.HasUnsupportedBills(false);\n this.HasUnsupportedInvoices(false);\n }\n\n private async UpdateBills(): Promise {\n const { newBills } = CompanyAccountingSoftwareService;\n const { billsLoadingError } = CompanyAccountingSoftwareService;\n\n if (!this.hasSoftwareConnected()) {\n return;\n }\n\n try {\n // See `if (!this.hasSoftwareConnected())` above.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const bills = await this.softwarePackage!.GetBills();\n\n const supportedBills = bills.filter((checkBill) =>\n SUPPORTED_ACCOUNTING_CURRENCIES.includes(checkBill.currency)\n );\n\n if (supportedBills.length !== bills.length) {\n this.HasUnsupportedBills(true);\n }\n\n if (this.hasSoftwareConnected()) {\n // grab currently selected bills\n const payableBills = newBills().filter((checkBill) => checkBill.pay());\n\n newBills.removeAll();\n newBills(supportedBills);\n\n // re-select bills that were previously selected\n payableBills.forEach((payableBill) => {\n newBills().forEach((checkBill) => {\n if (checkBill.id === payableBill.id) {\n checkBill.pay(true);\n }\n });\n });\n }\n } catch (error) {\n billsLoadingError(error?.type ?? 'error');\n throw error;\n }\n }\n\n private async UpdateInvoices(): Promise {\n const { newInvoices } = CompanyAccountingSoftwareService;\n const { invoicesLoadingError } = CompanyAccountingSoftwareService;\n\n // if accounting software doesn't support invoices we'll skip the invoice sync\n if (!this.softwarePackage?.supportsInvoices) {\n return;\n }\n\n try {\n const invoices = await this.softwarePackage.GetInvoices();\n\n const supportedInvoices = invoices.filter((checkInvoice) =>\n SUPPORTED_ACCOUNTING_CURRENCIES.includes(checkInvoice.currency)\n );\n\n if (supportedInvoices.length !== invoices.length) {\n this.HasUnsupportedInvoices(true);\n }\n\n if (this.hasSoftwareConnected()) {\n // grab currently selected invoices\n const payableInvoices = newInvoices().filter((checkInvoice) => checkInvoice.pay());\n newInvoices.removeAll();\n newInvoices(supportedInvoices);\n\n // re-select invoices that were previously selected\n payableInvoices.forEach((payableInvoice) => {\n newInvoices().forEach((checkInvoice) => {\n if (checkInvoice.id === payableInvoice.id) {\n checkInvoice.pay(true);\n }\n });\n });\n }\n } catch (error) {\n invoicesLoadingError(error?.type ?? 'error');\n throw error;\n }\n }\n\n public getAttachments(paymentId: string): Promise> {\n return ApiService.get(apiUrl(this.companyId, `payments/${paymentId}/bill/attachments`));\n }\n\n public getPaymentRequestAttachments(paymentRequestId: string): Promise> {\n if (!paymentRequestId) {\n return Promise.resolve([]);\n }\n\n return ApiService.get>(\n apiUrl(this.companyId, `paymentRequests/${paymentRequestId}/attachments`)\n );\n }\n\n public getAttachmentsForBillId(\n billId: string\n ): Promise> {\n if (!billId) {\n return Promise.resolve([]);\n }\n\n const softwarePackage = this.softwarePackageObservable();\n if (\n softwarePackage == null ||\n // We don't support attachments for QBD, but there will still be a defined billId value.\n softwarePackage.id === SupportedAccountingSoftware.QuickBooksDesktop\n ) {\n return Promise.resolve([]);\n }\n\n return ApiService.get>(\n apiUrl(this.companyId, `/bills/${billId}/attachments`)\n );\n }\n\n public getAttachmentsForInvoiceId(\n invoiceId: string\n ): Promise> {\n return ApiService.get>(\n apiUrl(this.companyId, `/invoices/${invoiceId}/attachments`)\n );\n }\n\n public mapBillsToPaymentImport(\n bills: Array\n ): JQueryPromise> {\n return $.Deferred>((dfd) => {\n ApiService.post>(\n apiUrl(this.companyId, 'mapBillsToPaymentImport'),\n { body: bills }\n )\n .then((paymentsData) => {\n dfd.resolve(paymentsData);\n })\n .catch((error) => {\n dfd.reject(error);\n });\n }).promise();\n }\n\n public mapInvoicesToInvoiceImport(\n invoices: Array\n ): JQueryPromise> {\n return $.Deferred>((dfd) => {\n ApiService.post>(\n apiUrl(this.companyId, 'mapInvoicesToPaymentRequestImport'),\n { body: invoices }\n )\n .then((paymentsData) => {\n dfd.resolve(paymentsData);\n })\n .catch((error) => {\n dfd.reject(error);\n });\n }).promise();\n }\n\n public getPaymentAccountingSoftwareBills(\n paymentId: string\n ): JQueryPromise> {\n return $.Deferred>((dfd) => {\n const url = apiUrl(this.companyId, `/payments/${paymentId}/accountingSoftwareBills`);\n ApiService.get>(url)\n .then((data) => {\n dfd.resolve(data);\n })\n .catch((error) => {\n dfd.reject(error);\n });\n }).promise();\n }\n\n public getAccountingSoftwareAvailability(accountingSoftwareName: string) {\n return ApiService.get(apiUrl(this.companyId, `/integrationEnabled/${accountingSoftwareName}`));\n }\n\n private fireAccountingSoftwareSyncEvent(state: SyncState) {\n const accountingPlatform = this.softwarePackage?.id;\n\n CompanyEventService.emit(\n AccountingSoftwareIntegrationEventsServiceEventType.AccountingPlatformSync,\n {\n buttonName: 'Accounting Platform Sync',\n accountingPlatform,\n state,\n }\n );\n }\n\n public requeueFailedCompanyAccountingSoftwareBill(billId: string) {\n const url = apiUrl(this.companyId, `/bills/${billId}/requeue`);\n return ApiService.post(url);\n }\n}\n\nexport const Instance = new CompanyAccountingSoftwareService();\n","enum SyncType {\n Manual,\n Auto,\n BypassCache,\n}\n\nexport default SyncType;\n","/**\n * Reconciliation method for reconciliation settings XHRs\n * @private\n */\nexport enum ReconciliationMethod {\n AutomaticReconciliation = 'AutomaticReconciliation',\n ManualReconciliation = 'ManualReconciliation',\n}\n\n/**\n * Response model for reconciliation settings XHRs\n */\nexport interface ReconciliationSettingsResponseModel {\n reconciliationMethod: ReconciliationMethod;\n skipBills: boolean;\n skipInvoices: boolean;\n /** QuickBooks Desktop Only **/\n skipContactsSync?: boolean;\n /** QuickBooks Desktop Only **/\n includeCustomerName?: boolean;\n}\n\n/**\n * Request model for reconciliation settings XHRs\n */\nexport type ReconciliationSettingsRequestModel = Partial;\n","import ko from 'knockout';\n\nimport { SUPPORTED_CURRENCIES } from '@/config/env';\nimport parseStringArray from '@/config/helpers/parseStringArray';\nimport { AccountingSoftware } from '@/features/accounting-software';\nimport { Instance as companyAccountingSoftwareService } from '@/features/accounting-software/services/companyAccountingSoftware';\nimport { getAuthorizationHeaderValue } from '@/features/api';\nimport type { Contact, TrackingCategoryOption } from '@/legacy/features/companies/documents/models';\nimport {\n AccountingSoftwareAccount,\n AccountingSoftwarePreferences,\n ApiResult,\n CompanyDocumentUploadSettings,\n ContactAddress,\n ContactDocumentUploadSettings,\n Currency,\n Document,\n DocumentBill,\n DocumentSubStatus,\n DocumentSuperStatus,\n DocumentType,\n EditorDocument,\n ExpenseItem,\n PaymentMethod,\n Supplier,\n TaxAccount,\n Terms,\n TrackingCategory,\n} from '@/legacy/features/companies/documents/models';\nimport Customer from '@/legacy/features/companies/documents/models/customer';\nimport AuthFetchService from '@/legacy/services/authFetch';\nimport * as companyService from '@/legacy/services/company';\nimport * as userService from '@/legacy/services/user';\n\nimport BillsPage from '../models/billsPage';\nimport BillsRequest from '../models/billsRequest';\n\nimport DocumentError from './documentError';\n\nfunction getCurrentUserId(): string {\n return userService.Instance.UserId();\n}\n\nfunction getCurrentCompanyId(): string {\n return companyService.Instance.CompanyId();\n}\n\nfunction apiURL(statics, ...dynamics): string {\n const finalUrl = [\n import.meta.env.FEATURE_DOCUMENTS_BASE_URL,\n import.meta.env.FEATURE_DOCUMENTS_API_BASE,\n ];\n statics.forEach((string, i) => {\n finalUrl.push(string, dynamics[i]);\n });\n return finalUrl.join('');\n}\n\nfunction getUpdateDocumentPayeeUrl(companyId: string): string {\n return apiURL`/company/${companyId}/document/payee`;\n}\n\nfunction documentListPage(companyId: string, page = 1): string {\n return apiURL`/files/${companyId}/${page}`;\n}\n\nfunction documentDataAPI(companyID: string, documentID: string): string {\n return apiURL`/company/${companyID}/document/${documentID}/data`;\n}\n\nfunction getCompanyDocumentsCountUrl(companyId: string): string {\n return apiURL`/companies/${companyId}/documents/count`;\n}\n\nfunction documentDataBulkAPI(companyID: string): string {\n return apiURL`/company/${companyID}/document`;\n}\n\nfunction documentDeleteDataBulkAPI(companyID: string): string {\n return apiURL`/company/${companyID}/document`;\n}\n\nfunction apiFileImageUrl(companyID: string, document: Document): string {\n return apiURL`/company/${companyID}/document/${document.id}/preview`;\n}\n\nfunction apiFileImageDownloadUrl(companyID: string): string {\n return apiURL`/company/${companyID}/document/download`;\n}\n\nfunction apiFileImagePreviewCodeUrl(companyID: string, documentId: string): string {\n return apiURL`/company/${companyID}/document/${documentId}/previewCode`;\n}\n\nfunction rawContactInfo(companyID: string, documentID: string): string {\n return apiURL`/company/${companyID}/document/${documentID}/rawcontactinfo`;\n}\n\nfunction signalrConnection(): string {\n return apiURL`/realtime/Negotiate`;\n}\n\nfunction signalrRegisterToCompany(): string {\n return apiURL`/realtime/RegisterToCompany`;\n}\n\nfunction documentAuditTrail(companyID: string, documentID: string): string {\n return apiURL`/company/${companyID}/document/${documentID}/audit`;\n}\n\nfunction getCompanyDocumentUploadSettingsUrl(\n companyId: string,\n accountingSoftware: string\n): string {\n return apiURL`/companies/${companyId}/documentUploadSettings?accountingSoftware=${accountingSoftware}`;\n}\n\nfunction getContactDocumentUploadSettingsUrl(\n companyId: string,\n contactId: string,\n accountingSoftware: string\n): string {\n return apiURL`/companies/${companyId}/contacts/${contactId}/documentUploadSettings?accountingSoftware=${accountingSoftware}`;\n}\n\nfunction getExpenseAccountsUrl(\n companyId: string,\n accountingSoftware: string,\n filterOutExcludedAccounts: boolean,\n includeAssetAndLiabilityAccounts: boolean,\n name?: string\n): string {\n const url = new URL(apiURL`/companies/${companyId}/${accountingSoftware}/expenseAccounts`);\n const { searchParams } = url;\n searchParams.append('filterOutExcludedAccounts', filterOutExcludedAccounts.toString());\n searchParams.append(\n 'includeAssetAndLiabilityAccounts',\n includeAssetAndLiabilityAccounts.toString()\n );\n if (name) {\n searchParams.append('name', name);\n }\n return url.toString();\n}\n\nfunction getMarkAsPaidAccountsUrl(\n companyId: string,\n accountingSoftware: string,\n name?: string\n): string {\n const url = new URL(apiURL`/companies/${companyId}/${accountingSoftware}/markAsPaidAccounts`);\n const { searchParams } = url;\n if (name) {\n searchParams.append('name', name);\n }\n return url.toString();\n}\n\nfunction getAssetAndLiabilityAccountsUrl(\n companyId: string,\n accountingSoftware: string,\n name?: string\n): string {\n const url = new URL(\n apiURL`/companies/${companyId}/${accountingSoftware}/assetAndLiabilityAccounts`\n );\n const { searchParams } = url;\n if (name) {\n searchParams.append('name', name);\n }\n return url.toString();\n}\n\nfunction getPaymentAccountsUrl(\n companyId: string,\n accountingSoftware: string,\n paymentMethodId?: string,\n name?: string\n): string {\n const url = new URL(apiURL`/companies/${companyId}/${accountingSoftware}/payment-accounts`);\n const { searchParams } = url;\n if (paymentMethodId) {\n searchParams.append('payment-method', paymentMethodId);\n }\n if (name) {\n searchParams.append('name', name);\n }\n return url.toString();\n}\n\nfunction getTaxAccountsUrl(\n companyId: string,\n accountingSoftware: string,\n filterOutExcludedAccounts: boolean\n): string {\n return apiURL`/companies/${companyId}/${accountingSoftware}/taxAccounts?filterOutExcludedAccounts=${filterOutExcludedAccounts}`;\n}\n\nfunction getExpenseItemsUrl(companyID: string, accountingSoftware: string, name?: string): string {\n const url = new URL(apiURL`/companies/${companyID}/${accountingSoftware}/items`);\n const { searchParams } = url;\n if (name) {\n searchParams.append('name', name);\n }\n return url.toString();\n}\n\nfunction getCustomersUrl(companyID: string, accountingSoftware: string, name: string): string {\n return apiURL`/companies/${companyID}/${accountingSoftware}/customers?name=${name}`;\n}\n\nfunction documentPublishingUrl(companyID: string): string {\n return apiURL`/companies/${companyID}/bill`;\n}\n\nfunction getSuppliersUrl(companyId: string, accountingSoftware?: string, name?: string): string {\n const url = new URL(apiURL`/company/${companyId}/suppliers`);\n const { searchParams } = url;\n\n searchParams.append('accountingSoftware', accountingSoftware);\n\n if (name) {\n searchParams.append('name', name);\n }\n\n return url.toString();\n}\n\nfunction getCheckPermissionsUrl(companyID: string, accountingSoftware: string): string {\n return apiURL`/companies/${companyID}/${accountingSoftware}/permissions/bill/publish`;\n}\n\nfunction getCurrenciesUrl(companyId: string, accountingSoftware: string): string {\n return apiURL`/company/${companyId}/${accountingSoftware}/currencies`;\n}\n\nfunction getBillsUrl(companyId: string, query?: BillsQuery): string {\n const url = new URL(apiURL`/company/${companyId}/bills`);\n const { searchParams } = url;\n if (query) {\n Object.keys(query).forEach((key) => {\n if (key && query[key]) {\n searchParams.append(key, query[key]);\n }\n });\n }\n return url.toString();\n}\n\nfunction getSearchBillsUrl(companyId: string): string {\n const url = new URL(apiURL`/company/${companyId}/bills/search`);\n return url.toString();\n}\n\nfunction getBillsCurrenciesUrl(companyId: string): string {\n const url = new URL(apiURL`/company/${companyId}/bills/currencies`);\n return url.toString();\n}\n\nfunction getBillsByPaymentIdUrl(companyId: string, paymentId: string): string {\n return apiURL`/company/${companyId}/payments/${paymentId}/bills`;\n}\n\nfunction deleteBillsUrl(companyId: string): string {\n return apiURL`/company/${companyId}/bills`;\n}\n\nfunction createContactUrl(companyId: string, accountingSoftware: string): string {\n return apiURL`/companies/${companyId}/${accountingSoftware}/contacts`;\n}\n\nfunction getClassesUrl(companyId: string, accountingSoftware: string, name?: string) {\n const url = new URL(apiURL`/companies/${companyId}/${accountingSoftware}/classes`);\n const { searchParams } = url;\n if (name) {\n searchParams.append('name', name);\n }\n return url.toString();\n}\n\nfunction getDepartmentsUrl(companyId: string, accountingSoftware: string, name?: string) {\n const url = new URL(apiURL`/companies/${companyId}/${accountingSoftware}/departments`);\n const { searchParams } = url;\n if (name) {\n searchParams.append('name', name);\n }\n return url.toString();\n}\n\nfunction getLocationsUrl(companyId: string, accountingSoftware: string, name?: string) {\n const url = new URL(apiURL`/companies/${companyId}/${accountingSoftware}/locations`);\n const { searchParams } = url;\n if (name) {\n searchParams.append('name', name);\n }\n return url.toString();\n}\n\nfunction getPaymentMethodsUrl(companyId: string, accountingSoftware: string): string {\n return apiURL`/companies/${companyId}/${accountingSoftware}/payment-methods`;\n}\n\nfunction getTermsUrl(companyId: string, accountingSoftware: string): string {\n return apiURL`/companies/${companyId}/${accountingSoftware}/terms`;\n}\n\nfunction getRotateDocumentUrl(companyId: string, documentFileId: string): string {\n return apiURL`/company/${companyId}/document/${documentFileId}/rotate`;\n}\n\nfunction getTrackingCategoriesUrl(companyID: string, accountingSoftware: string): string {\n return apiURL`/companies/${companyID}/${accountingSoftware}/tracking-categories`;\n}\n\nfunction getAccountingSoftwarePreferencesUrl(companyId: string, accountingSoftware: string) {\n return apiURL`/companies/${companyId}/${accountingSoftware}/preferences`;\n}\n\nenum ErrorCodes {\n FailedToSendRequestToDocumentApi = 401,\n FailedToGetDownloadLinkDutToPermissions = 423,\n}\n\nconst failedToSendRequestMessage = 'Failed to send request';\n\ninterface BillsQuery {\n orderBy?: string;\n orderDirection?: string;\n skip?: number;\n take?: number;\n}\n\ninterface DocumentQuery {\n suppliers?: Array;\n /**\n * Possible Document statuses: Published (true | false).\n * Defaults to unpublished\n */\n superStatus?: DocumentSuperStatus;\n /**\n * Document status. Multiselect is possible.\n * Defaults to all\n */\n status?: Array;\n /**\n * Document amount.\n */\n pageSize?: number;\n /**\n * The date type to sort documents with\n * Defaults to UploadDate\n */\n sortKey?: string;\n /**\n * The direction of sorting for value.\n * True for oldest to newest, where nulls are first (for other than UploadDate)\n */\n ascending?: boolean;\n startInvoiceDate?: string;\n endInvoiceDate?: string;\n documentType?: DocumentType | null;\n}\n\ninterface DocumentsResponse extends ApiResult> {\n total: number;\n hasNext: boolean;\n page: number;\n}\n\ntype DocumentDataDictionary = { [id: string]: EditorDocument };\n\ninterface DocumentsUploadRequest {\n companyId: string;\n files: Array;\n}\n\ninterface DocumentsUploadResponse {\n isSuccess: boolean;\n}\n\n/**\n * Paginated response with next page indicator.\n */\ninterface HasNextResponse {\n total: number;\n hasNext: boolean;\n data: T;\n}\n\ninterface DocumentFileResponse {\n documentData: Blob;\n isPdf: boolean;\n}\n\ninterface ContactData {\n readonly address?: string;\n readonly city?: string;\n readonly companyName?: string;\n readonly contactMail?: string;\n readonly contactName?: string;\n readonly country?: string;\n readonly customerNumber?: string;\n readonly postcode?: string;\n readonly taxNumber?: string;\n readonly vatId?: string;\n}\n\ninterface AuditTrail {\n readonly date: string;\n readonly id: string;\n readonly email: string;\n readonly method: string;\n readonly name: string;\n readonly originalDocumentUri?: string;\n readonly publishedBy?: string;\n readonly publishedDate?: string;\n}\n\ninterface ContactViewModel {\n id: string;\n name: string;\n email: string;\n displayName: string;\n phoneNumber: string;\n address: ContactAddress;\n accountNumber: string;\n defaultExpenseAccountId: string;\n defaultTaxAccountId: string;\n defaultCustomerId: string;\n defaultCurrency: string;\n defaultMemo: string;\n isCustomer: boolean;\n isSupplier: boolean;\n optionsText: string;\n}\n\nexport default class DocumentService {\n static getCurrentAccountingSoftware() {\n return companyAccountingSoftwareService.softwareTypeObservable();\n }\n\n /** Check whether the current company's accounting software type is supported by the Documents feature. Not all types are. */\n static readonly isAccountingSoftwareSupported: KnockoutComputed = ko.pureComputed(() => {\n const companySoftwareType = companyAccountingSoftwareService.softwareTypeObservable();\n const hasSupportedAccountingSoftware = parseStringArray(\n import.meta.env.FEATURE_DOCUMENTS_SUPPORTED_ACCOUNTING_SOFTWARE\n ).includes(companySoftwareType);\n return hasSupportedAccountingSoftware;\n });\n\n static async rotateDocument(documentId: string): Promise {\n const url = getRotateDocumentUrl(getCurrentCompanyId(), documentId);\n return this.httpPost(url);\n }\n\n static async getCompanyDocumentsCount(): Promise {\n const url = getCompanyDocumentsCountUrl(getCurrentCompanyId());\n return this.httpGet(url);\n }\n\n static async patchDocumentsPayee(\n documentId: string,\n plootoContactId: string,\n accountingSoftwareContactId: string,\n name: string\n ): Promise {\n const url = new URL(getUpdateDocumentPayeeUrl(getCurrentCompanyId()));\n\n const body = {\n documentId,\n supplier: {\n payeeId: plootoContactId,\n contactId: accountingSoftwareContactId,\n name,\n },\n };\n\n return this.httpPatch(url, body);\n }\n\n static async getCurrencies(): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported()) {\n return [];\n }\n\n if (!accountingSoftware) {\n return SUPPORTED_CURRENCIES.map((code: string) => ({\n id: code,\n name: code,\n code,\n }));\n }\n\n const url = getCurrenciesUrl(getCurrentCompanyId(), accountingSoftware);\n\n return this.httpGet(url);\n }\n\n static async getEditorDocuments(fileId: string): Promise {\n const url = documentDataAPI(getCurrentCompanyId(), fileId);\n return this.httpGet(url);\n }\n\n static async deleteBills(documentBillIds: Array): Promise {\n const url = new URL(deleteBillsUrl(getCurrentCompanyId()));\n\n return AuthFetchService.httpDelete(url.toString(), JSON.stringify({ documentBillIds }));\n }\n\n static async getBills(query?: BillsQuery): Promise {\n const url = getBillsUrl(getCurrentCompanyId(), query);\n\n return this.httpGetRaw(url);\n }\n\n static async getBillsCurrencies(): Promise> {\n const url = getBillsCurrenciesUrl(getCurrentCompanyId());\n\n return this.httpGet>(url);\n }\n\n static async searchBills(request?: BillsRequest): Promise {\n const url = getSearchBillsUrl(getCurrentCompanyId());\n\n return this.httpPostRaw(url, request);\n }\n\n static async getBillsByPaymentId(paymentId: string): Promise> {\n const url = getBillsByPaymentIdUrl(getCurrentCompanyId(), paymentId);\n\n return this.httpGet(url);\n }\n\n static async getDocumentsList(\n page = 1,\n query?: DocumentQuery\n ): Promise>> {\n const url = new URL(documentListPage(getCurrentCompanyId(), page));\n\n return AuthFetchService.httpPost(url.toString(), JSON.stringify(query))\n .then((res) => res.json())\n .then((documentResponse: DocumentsResponse) => {\n if (!documentResponse.isSuccess) {\n throw new DocumentError(documentResponse.message, documentResponse.errorCode);\n }\n\n const { hasNext, data, total } = documentResponse;\n\n return { hasNext, data, total };\n });\n }\n\n static async getSuppliers(name?: string): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n const url = getSuppliersUrl(getCurrentCompanyId(), accountingSoftware, name);\n\n return this.httpGet(url);\n }\n\n private static fileUploadRequest: XMLHttpRequest = null;\n\n static cancelFileUpload(): void {\n if (this.fileUploadRequest) {\n const request = this.fileUploadRequest;\n this.fileUploadRequest = null;\n request.abort();\n }\n }\n\n static async uploadFiles(\n request: DocumentsUploadRequest,\n progressHandler: (uploaded: number, total: number) => void\n ): Promise {\n const url = new URL(`${import.meta.env.FEATURE_DOCUMENTS_BASE_URL}/api/v1/upload`);\n\n if (request) {\n const data = new FormData();\n data.append('companyId', getCurrentCompanyId());\n\n request.files.forEach((file, index) => {\n data.append(`file${index}`, file, file.name);\n });\n\n return new Promise((resolve, reject) => {\n try {\n this.fileUploadRequest = new XMLHttpRequest();\n\n this.fileUploadRequest.onload = (event) => {\n const { status } = this.fileUploadRequest;\n this.fileUploadRequest = null;\n\n resolve({ isSuccess: status === 200 });\n };\n\n this.fileUploadRequest.onerror = () => {\n if (this.fileUploadRequest) {\n this.fileUploadRequest = null;\n\n resolve({ isSuccess: false });\n }\n };\n\n this.fileUploadRequest.open('POST', url.toString(), true);\n this.appendAuthorizationHeader(this.fileUploadRequest);\n\n this.fileUploadRequest.upload.addEventListener(\n 'progress',\n (event: ProgressEvent) => {\n progressHandler(event.loaded, event.total);\n },\n false\n );\n this.fileUploadRequest.send(data);\n } catch (error) {\n reject(error);\n }\n });\n }\n\n return Promise.resolve(null);\n }\n\n private static appendAuthorizationHeader(xhr: XMLHttpRequest) {\n if (xhr) {\n xhr.setRequestHeader('Authorization', getAuthorizationHeaderValue());\n }\n }\n\n static async getDocument(document: Document): Promise {\n return AuthFetchService.httpGet(apiFileImageUrl(getCurrentCompanyId(), document))\n .then((response) => {\n if (!response.ok) {\n throw new DocumentError(`${response.status} ${response.statusText}`, response.status);\n }\n const responseTuple: [Promise, boolean] = [\n response.blob(),\n response.headers.get('Content-Type')?.includes('application/pdf'),\n ];\n return responseTuple;\n })\n .then(async (responseTuple) => {\n const documentData = await responseTuple[0];\n const isPdf = responseTuple[1];\n return { documentData, isPdf };\n });\n }\n\n static createDocumentDownloadLinks(documentIds: Array): Promise> {\n const url = apiFileImageDownloadUrl(getCurrentCompanyId());\n return this.httpPost(url, { documentIds });\n }\n\n static async createDocumentPreviewLink(documentId: string): Promise {\n const url = apiFileImagePreviewCodeUrl(getCurrentCompanyId(), documentId);\n const code = await this.httpPost(url);\n\n const uri = apiFileImageUrl(getCurrentCompanyId(), { id: documentId } as Document);\n return `${uri}?code=${code}`;\n }\n\n /**\n * Update document data in whole or partially for a specific document.\n * @param id Document ID to modify.\n * @param document The data to update.\n * @returns ```void```\n * @throws If HTTP response code ```< 200``` or ```> 299```.\n */\n static async patchDocument(\n id: string,\n document: Partial\n ): Promise {\n const url = new URL(documentDataAPI(getCurrentCompanyId(), id));\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n if (accountingSoftware) {\n url.searchParams.append('accountingSoftware', accountingSoftware);\n }\n return this.httpPatch(url, document);\n }\n\n /**\n * Update document data in whole or partially for several documents.\n * @param ids Document IDs to modify.\n * @param document The data to update.\n * @returns ```void```\n * @throws If HTTP response code ```< 200``` or ```> 299```.\n */\n static async bulkPatchDocument(\n ids: Array,\n document: Partial\n ): Promise> {\n const url = new URL(documentDataBulkAPI(getCurrentCompanyId()));\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n if (accountingSoftware) {\n url.searchParams.append('accountingSoftware', accountingSoftware);\n }\n ids.forEach((id) => url.searchParams.append('id', id));\n return this.httpPatch(url, document);\n }\n\n static async getDocumentContact(documentID: string): Promise {\n const url = rawContactInfo(getCurrentCompanyId(), documentID);\n return this.httpGet(url);\n }\n\n static async getSignalrCredentials(): Promise<{ accessToken: string; url: string }> {\n const url = new URL(signalrConnection());\n return AuthFetchService.httpGet(url.toString(), {\n 'X-Plooto-UserId': getCurrentUserId(),\n 'X-Plooto-CompanyId': getCurrentCompanyId(),\n }).then((res) => {\n if (!res.ok) {\n throw new DocumentError(\n `can't get SignalR connection data; status \"${res.status}\"`,\n res.status\n );\n }\n return res.json();\n });\n }\n\n static async deleteDocuments(documentIds: Array): Promise {\n const url = new URL(documentDeleteDataBulkAPI(getCurrentCompanyId()));\n documentIds.forEach((id) => url.searchParams.append('id', id));\n return AuthFetchService.httpDelete(url.toString()).then((res) => {\n if (!res.ok) {\n throw new DocumentError(`can't delete document(s); status \"${res.status}\"`, res.status);\n }\n });\n }\n\n static async registerToCompanyEvents(): Promise {\n const url = new URL(signalrRegisterToCompany());\n return AuthFetchService.httpPost(url.toString(), null, {\n 'X-Plooto-CompanyId': getCurrentCompanyId(),\n }).then((res) => {\n if (!res.ok) {\n throw new DocumentError(\n `can't register to SignalR group; status \"${res.status}\"`,\n res.status\n );\n }\n });\n }\n\n static async getAuditTrail(documentId: string): Promise {\n const url = documentAuditTrail(getCurrentCompanyId(), documentId);\n return this.httpGet(url);\n }\n\n static saveCompanyDocumentUploadSettings(\n companyDocumentUploadSettings: CompanyDocumentUploadSettings\n ): Promise {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n const url = new URL(\n getCompanyDocumentUploadSettingsUrl(getCurrentCompanyId(), accountingSoftware)\n );\n\n return AuthFetchService.httpPut(\n url.toString(),\n JSON.stringify(companyDocumentUploadSettings)\n ).then((res) => {\n if (!res.ok) {\n throw res.json();\n }\n });\n }\n\n static async getCompanyDocumentUploadSettings(): Promise {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n const url = getCompanyDocumentUploadSettingsUrl(getCurrentCompanyId(), accountingSoftware);\n\n return this.httpGet(url);\n }\n\n static async getContactDocumentUploadSettings(\n contactId: string\n ): Promise {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n const url = getContactDocumentUploadSettingsUrl(\n getCurrentCompanyId(),\n contactId,\n accountingSoftware\n );\n\n return this.httpGet(url);\n }\n\n static async updateContactDocumentAutoSyncSetting(\n autoSync: boolean,\n contactId: string\n ): Promise {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n const url = getContactDocumentUploadSettingsUrl(\n getCurrentCompanyId(),\n contactId,\n accountingSoftware\n );\n\n return AuthFetchService.httpPatch(\n url.toString(),\n JSON.stringify([\n {\n op: 'replace',\n path: '/autoSync',\n value: autoSync,\n },\n ])\n ).then((res) => {\n if (!res.ok) {\n throw res.json();\n }\n });\n }\n\n static async getExpenseAccounts(\n filterOutExcludedAccounts = true,\n includeAssetAndLiabilityAccounts = true,\n name: string = undefined\n ): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported() || !accountingSoftware) {\n return [];\n }\n\n const url = getExpenseAccountsUrl(\n getCurrentCompanyId(),\n accountingSoftware,\n filterOutExcludedAccounts,\n includeAssetAndLiabilityAccounts,\n name\n );\n\n return this.httpGet(url);\n }\n\n static async getMarkAsPaidAccounts(name?: string): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported() || !accountingSoftware) {\n return [];\n }\n\n const url = getMarkAsPaidAccountsUrl(getCurrentCompanyId(), accountingSoftware, name);\n\n return this.httpGet(url);\n }\n\n static async getAssetAndLiabilityAccounts(\n name?: string\n ): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported() || !accountingSoftware) {\n return [];\n }\n\n const url = getAssetAndLiabilityAccountsUrl(getCurrentCompanyId(), accountingSoftware, name);\n\n return this.httpGet(url);\n }\n\n static async getPaymentAccounts(\n paymentMethodId?: string,\n name?: string\n ): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported() || !accountingSoftware) {\n return [];\n }\n\n const url = getPaymentAccountsUrl(\n getCurrentCompanyId(),\n accountingSoftware,\n paymentMethodId,\n name\n );\n\n return this.httpGet(url);\n }\n\n static async getTaxAccounts(filterOutExcludedAccounts = true): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported() || !accountingSoftware) {\n return [];\n }\n\n const url = getTaxAccountsUrl(\n getCurrentCompanyId(),\n accountingSoftware,\n filterOutExcludedAccounts\n );\n\n return this.httpGet(url);\n }\n\n static async createContact(contact: Contact): Promise {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported() || !accountingSoftware) {\n throw new DocumentError('not connected to accounting software');\n }\n\n const url = createContactUrl(getCurrentCompanyId(), accountingSoftware);\n\n return this.httpPost(url, contact);\n }\n\n static async getCustomers(name?: string): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported() || !accountingSoftware) {\n return [];\n }\n\n const url = getCustomersUrl(getCurrentCompanyId(), accountingSoftware, name);\n\n return this.httpGet(url);\n }\n\n static async getExpenseItems(name?: string): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported() || !accountingSoftware) {\n return [];\n }\n\n const url = getExpenseItemsUrl(getCurrentCompanyId(), accountingSoftware, name);\n\n return this.httpGet(url);\n }\n\n static async getClasses(name?: string): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported()) {\n return [];\n }\n\n if (\n accountingSoftware !== AccountingSoftware.QuickBooksOnline &&\n accountingSoftware !== AccountingSoftware.NetSuite\n ) {\n return [];\n }\n\n const url = getClassesUrl(getCurrentCompanyId(), accountingSoftware, name);\n\n return this.httpGet(url);\n }\n\n static async getDepartments(name?: string): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported()) {\n return [];\n }\n\n if (\n accountingSoftware !== AccountingSoftware.QuickBooksOnline &&\n accountingSoftware !== AccountingSoftware.NetSuite\n ) {\n return [];\n }\n\n const url = getDepartmentsUrl(getCurrentCompanyId(), accountingSoftware, name);\n\n return this.httpGet(url);\n }\n\n static async getLocations(name?: string): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported()) {\n return [];\n }\n\n if (accountingSoftware !== AccountingSoftware.NetSuite) {\n return [];\n }\n\n const url = getLocationsUrl(getCurrentCompanyId(), accountingSoftware, name);\n\n return this.httpGet(url);\n }\n\n static async getPaymentMethods(): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (\n !this.isAccountingSoftwareSupported() ||\n accountingSoftware !== AccountingSoftware.QuickBooksOnline\n ) {\n return [];\n }\n\n const url = getPaymentMethodsUrl(getCurrentCompanyId(), accountingSoftware);\n\n return this.httpGet(url);\n }\n\n static async getTerms(): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (\n !this.isAccountingSoftwareSupported() ||\n accountingSoftware !== AccountingSoftware.QuickBooksOnline\n ) {\n return [];\n }\n\n const url = getTermsUrl(getCurrentCompanyId(), accountingSoftware);\n\n return this.httpGet(url);\n }\n\n static async getAccountingSoftwarePreferences(): Promise {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (!this.isAccountingSoftwareSupported() || !accountingSoftware) {\n return undefined;\n }\n\n const url = getAccountingSoftwarePreferencesUrl(getCurrentCompanyId(), accountingSoftware);\n\n return this.httpGet(url);\n }\n\n static publishDocument(documentIds: Array): Promise {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n const url = documentPublishingUrl(getCurrentCompanyId());\n\n return this.httpPost(url, { documentIds, accountingSoftware });\n }\n\n static async checkPermissions(): Promise {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (accountingSoftware !== AccountingSoftware.Xero) {\n // we need to check only Xero permissions for now\n return true;\n }\n\n const url = getCheckPermissionsUrl(getCurrentCompanyId(), accountingSoftware);\n\n try {\n return await this.httpGet(url);\n } catch {\n return false;\n }\n }\n\n static async getTrackingCategories(): Promise> {\n const accountingSoftware = DocumentService.getCurrentAccountingSoftware();\n\n if (accountingSoftware !== AccountingSoftware.Xero) {\n return [];\n }\n\n const url = getTrackingCategoriesUrl(getCurrentCompanyId(), accountingSoftware);\n\n return this.httpGet(url);\n }\n\n private static async httpGetRaw(url: string): Promise {\n let response: Response;\n\n try {\n response = await AuthFetchService.httpGet(url);\n } catch {\n throw new DocumentError(\n failedToSendRequestMessage,\n ErrorCodes.FailedToSendRequestToDocumentApi\n );\n }\n\n const json = await response.json();\n\n if (!json.isSuccess) {\n throw new DocumentError(json.message, json.errorCode);\n }\n\n return json as T;\n }\n\n /** @deprecated Use `ApiService` instead */\n private static async httpGet(url: string): Promise {\n const json: any = await this.httpGetRaw(url);\n\n return json.data as T;\n }\n\n /** @deprecated Use `ApiService` instead */\n private static async httpPost(url: string, body?: any): Promise {\n const json: any = await this.httpPostRaw(url, body);\n\n return json.data as T;\n }\n\n /** @deprecated Use `ApiService` instead */\n private static async httpPostRaw(url: string, body?: any): Promise {\n let response: Response;\n\n try {\n response = await AuthFetchService.httpPost(url.toString(), JSON.stringify(body), {\n 'Content-Type': 'application/json',\n });\n } catch {\n throw new DocumentError(\n failedToSendRequestMessage,\n ErrorCodes.FailedToSendRequestToDocumentApi\n );\n }\n\n const json = await response.json();\n\n if (!json.isSuccess) {\n throw new DocumentError(json.message, json.errorCode);\n }\n\n return json as T;\n }\n\n /** @deprecated Use `ApiService` instead */\n private static async httpPatch(url: URL, body?: any): Promise {\n let response: Response;\n\n try {\n response = await AuthFetchService.httpPatch(url.toString(), JSON.stringify(body), {\n 'Content-Type': 'application/json',\n });\n } catch {\n throw new DocumentError(\n failedToSendRequestMessage,\n ErrorCodes.FailedToSendRequestToDocumentApi\n );\n }\n\n const json = await response.json();\n\n if (!json.isSuccess) {\n throw new DocumentError(json.message, json.errorCode);\n }\n\n return json.data;\n }\n}\n\nexport {\n BillsQuery,\n DocumentQuery,\n ContactData,\n AuditTrail,\n Contact,\n ContactViewModel,\n DocumentDataDictionary,\n};\n","export default class DocumentError extends Error {\n public status?: number;\n\n public message: string;\n\n constructor(message: string, status?: number) {\n super(message);\n this.status = status;\n }\n}\n"],"names":["apiUrl","companyId","endpoint","query","cleanEndpoint","replace","url","URL","Object","create","globalThis","import_meta_env","APP_URLS_API_URL","API_PREFIX","entries","forEach","key","value","searchParams","set","toString","getAccountingSoftwareName","companyAccountingSoftwareService","softwarePackage","name","AccountingSoftwareBillStatus","CompanyAccountingSoftwareService","companyService","accountingSoftwareService","billsLoadingError","ko","newBills","invoicesLoadingError","newInvoices","syncStatus","syncState","lastSyncedAt","HasUnsupportedBills","HasUnsupportedInvoices","CompanyId","softwareTypeObservable","read","companyMembership","membership","undefined","company","accountingSoftware","deferEvaluation","softwarePackageObservable","id","GetPackage","hasSoftwareConnected","_isNil","resync","syncType","SyncType","Auto","syncBills","syncInvoices","syncBillsAccordingToPermissions","syncInvoicesAccordingToPermissions","HasPermissionTo","PermissionId","PAYMENT_ADD_EDIT","clearSelectedPayments","SyncData","then","UpdateBills","Promise","resolve","UpdateInvoices","state","fireAccountingSoftwareSyncEvent","Date","catch","errorInfo","type","RefreshInvoices","RefreshBills","disconnect","accountingPlatform","ApiService","remove","CompanyEventService","emit","AccountingSoftwareIntegrationEventsServiceEventType","AccountingPlatformDisconnected","resetSyncState","expireSyncState","removeAll","bills","GetBills","supportedBills","filter","checkBill","SUPPORTED_ACCOUNTING_CURRENCIES","includes","currency","length","payableBills","pay","payableBill","error","supportsInvoices","invoices","GetInvoices","supportedInvoices","checkInvoice","payableInvoices","payableInvoice","getAttachments","paymentId","get","getPaymentRequestAttachments","paymentRequestId","getAttachmentsForBillId","billId","SupportedAccountingSoftware","QuickBooksDesktop","getAttachmentsForInvoiceId","invoiceId","mapBillsToPaymentImport","$","dfd","post","body","paymentsData","reject","promise","mapInvoicesToInvoiceImport","getPaymentAccountingSoftwareBills","data","getAccountingSoftwareAvailability","accountingSoftwareName","AccountingPlatformSync","buttonName","requeueFailedCompanyAccountingSoftwareBill","Instance","ReconciliationMethod","getCurrentUserId","userService","UserId","getCurrentCompanyId","apiURL","statics","dynamics","finalUrl","FEATURE_DOCUMENTS_BASE_URL","FEATURE_DOCUMENTS_API_BASE","string","i","push","join","getUpdateDocumentPayeeUrl","documentListPage","page","documentDataAPI","companyID","documentID","getCompanyDocumentsCountUrl","documentDataBulkAPI","documentDeleteDataBulkAPI","apiFileImageUrl","document","apiFileImageDownloadUrl","apiFileImagePreviewCodeUrl","documentId","rawContactInfo","signalrConnection","signalrRegisterToCompany","documentAuditTrail","getCompanyDocumentUploadSettingsUrl","getContactDocumentUploadSettingsUrl","contactId","getExpenseAccountsUrl","filterOutExcludedAccounts","includeAssetAndLiabilityAccounts","append","getMarkAsPaidAccountsUrl","getAssetAndLiabilityAccountsUrl","getPaymentAccountsUrl","paymentMethodId","getTaxAccountsUrl","getExpenseItemsUrl","getCustomersUrl","documentPublishingUrl","getSuppliersUrl","getCheckPermissionsUrl","getCurrenciesUrl","getBillsUrl","keys","getSearchBillsUrl","getBillsCurrenciesUrl","getBillsByPaymentIdUrl","deleteBillsUrl","createContactUrl","getClassesUrl","getDepartmentsUrl","getLocationsUrl","getPaymentMethodsUrl","getTermsUrl","getRotateDocumentUrl","documentFileId","getTrackingCategoriesUrl","getAccountingSoftwarePreferencesUrl","ErrorCodes","failedToSendRequestMessage","DocumentService","getCurrentAccountingSoftware","isAccountingSoftwareSupported","companySoftwareType","parseStringArray","FEATURE_DOCUMENTS_SUPPORTED_ACCOUNTING_SOFTWARE","rotateDocument","httpPost","getCompanyDocumentsCount","httpGet","patchDocumentsPayee","plootoContactId","accountingSoftwareContactId","supplier","payeeId","httpPatch","getCurrencies","SUPPORTED_CURRENCIES","map","code","getEditorDocuments","fileId","deleteBills","documentBillIds","AuthFetchService","httpDelete","JSON","stringify","getBills","httpGetRaw","getBillsCurrencies","searchBills","request","httpPostRaw","getBillsByPaymentId","getDocumentsList","res","json","documentResponse","isSuccess","DocumentError","message","errorCode","hasNext","total","getSuppliers","fileUploadRequest","cancelFileUpload","abort","uploadFiles","progressHandler","FormData","files","file","index","XMLHttpRequest","onload","event","status","onerror","open","appendAuthorizationHeader","upload","addEventListener","loaded","send","xhr","setRequestHeader","getAuthorizationHeaderValue","getDocument","response","ok","statusText","blob","headers","responseTuple","documentData","isPdf","createDocumentDownloadLinks","documentIds","createDocumentPreviewLink","patchDocument","bulkPatchDocument","ids","getDocumentContact","getSignalrCredentials","deleteDocuments","registerToCompanyEvents","getAuditTrail","saveCompanyDocumentUploadSettings","companyDocumentUploadSettings","httpPut","getCompanyDocumentUploadSettings","getContactDocumentUploadSettings","updateContactDocumentAutoSyncSetting","autoSync","op","path","getExpenseAccounts","getMarkAsPaidAccounts","getAssetAndLiabilityAccounts","getPaymentAccounts","getTaxAccounts","createContact","contact","getCustomers","getExpenseItems","getClasses","AccountingSoftware","QuickBooksOnline","NetSuite","getDepartments","getLocations","getPaymentMethods","getTerms","getAccountingSoftwarePreferences","publishDocument","checkPermissions","Xero","getTrackingCategories","FailedToSendRequestToDocumentApi","Error","constructor"],"sourceRoot":""}