usePOSCartStore (posCart.js)

POSNext · state-management, cart-management, stock-validation, offline-support, job-queue, pos

Pinia store managing POS cart state, operations, and async task queuing for sales transactions with stock validation and offline support.

import { useInvoice } from "@/composables/useInvoice";
import { usePOSOffersStore } from "@/stores/posOffers";
import { usePOSSettingsStore } from "@/stores/posSettings";
import { usePOSShiftStore } from "@/stores/posShift";
import { parseError } from "@/utils/errorHandler";
import { shouldValidateItemStock, checkStockAvailability } from "@/utils/stockValidator";
import { offlineState } from "@/utils/offline/offlineState";
import { useToast } from "@/composables/useToast";
import { defineStore } from "pinia";
import { computed, nextTick, ref, toRaw, watch } from "vue";

/**
 * Creates an async task queue that ensures only one operation runs at a time.
 * Subsequent calls while processing will be queued and the latest one executed.
 */
function createAsyncQueue() {
	let isProcessing = false

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key