diff --git a/package.json b/package.json index 45e3371..df8e7bd 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ "@electron-toolkit/utils": "^4.0.0", "electron-log": "^5.3.2", "electron-store": "^8.2.0", - "electron-updater": "^6.3.9", - "winax": "^3.6.1" + "electron-updater": "^6.3.9" }, "devDependencies": { "@ant-design/v5-patch-for-react-19": "^1.0.3", @@ -72,5 +71,8 @@ "redux-thunk": "^3.1.0", "typescript": "^5.8.2", "vite": "^6.2.1" + }, + "optionalDependencies": { + "winax": "^3.1.4" } } diff --git a/src/main/quickbooks-desktop/quickbooks-desktop.ts b/src/main/quickbooks-desktop/quickbooks-desktop.ts index 3eb864f..6353254 100644 --- a/src/main/quickbooks-desktop/quickbooks-desktop.ts +++ b/src/main/quickbooks-desktop/quickbooks-desktop.ts @@ -1,4 +1,3 @@ -import * as Winax from "winax"; import log from "electron-log/main"; import { Request, Response } from "express"; @@ -7,11 +6,25 @@ import errorTypeCheck from "../../util/errorTypeCheck"; import _ from "lodash"; import store from "../store/store"; +let Winax: any; // Declare Winax as any to avoid TypeScript errors on non-Windows platforms + +if (process.platform === "win32") { + Winax = require("winax"); +} + export async function handleQuickBookRequest( req: Request, res: Response, ): Promise { - //TODO: Add OS sysstem checking. This can only happen on windows machines. + if (process.platform !== "win32") { + res + .status(500) + .json({ + error: "QuickBooks Desktop integration is only available on Windows", + }); + return; + } + const QbFilePath: string = `C:\\Users\\PatrickFic\\Development\\FRODO COLLISION.QBW`; // || // (store.get("settings.qbFilePath") as string) F @@ -81,6 +94,10 @@ export async function handleQuickBookRequest( //This set of functions works. export function TestQB(): void { + if (process.platform !== "win32") { + log.warn("TestQB is only available on Windows"); + return; + } let requestProcessor, ticket; try { requestProcessor = new Winax.Object("QBXMLRP.RequestProcessor.1");