Conversation
The cart passes its payments and change legs as live Vue arrays. dbBridge.addPendingInvoice and addPendingPurchase wrote them to IndexedDB (or sent them over IPC) as-is, and structured clone throws DataCloneError on a Proxy, so a cash sale made offline failed with "Failed to save invoice offline". Run both records through sanitizeForIdb first, which idbService already used for everything else. It moves to its own module so dbBridge can use it without pulling in Dexie.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Stores offline invoices and purchases as plain data, so a sale completed offline is actually saved instead of failing with "Failed to save invoice offline".
Why
cartStore.getInvoiceData()passespaymentsandpos_change_legsas live Vue arrays (reactive proxies).dbBridge.addPendingInvoicewrites the record straight to IndexedDB (or sends it over Electron IPC), and both copy with the structured clone algorithm, which throwsDataCloneErroron a Proxy. The payment dialog then reports "Failed to save invoice offline", and the offline sale is lost.addPendingPurchasehas the same problem.idbServicealready runs everything else throughsanitizeForIdb; these two paths skipped it.To reproduce: open a shift on a POS Profile with offline mode on, go offline (DevTools → Network → Offline), and complete a cash sale.
Changes
frontend/src/services/dbBridge.ts: runsaddPendingInvoiceandaddPendingPurchaserecords throughsanitizeForIdbbefore they're stored, for both IndexedDB and Electron.sanitizeForIdbmoved unchanged fromidbService.tsto a newfrontend/src/services/idbSanitize.ts, sodbBridgecan use it without importing Dexie.idbService.tsimports and re-exports it.frontend/tests/dbBridge.spec.ts(3 tests): reactive arrays are stored as structured-clone-safe plain data, for invoices in browser and Electron mode and for purchases. All three fail without the fix.