Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions POS/src/stores/posCart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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,
Expand Down Expand Up @@ -1376,6 +1377,12 @@ export const usePOSCartStore = defineStore("posCart", () => {
return
}

// Skip offer processing if POS Profile has ignore_pricing_rule enabled
const shiftStore = usePOSShiftStore()
if (shiftStore.currentProfile?.ignore_pricing_rule) {
return
}

// Ensure offers are fetched before processing
// This is critical for mobile view where InvoiceCart may not be mounted yet
// IMPORTANT: This must happen BEFORE hash check, because if offers weren't
Expand Down
8 changes: 8 additions & 0 deletions POS/src/stores/posOffers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { computed, ref } from "vue"
import { call } from "@/utils/apiWrapper"
import { isOffline } from "@/utils/offline"
import { offlineWorker } from "@/utils/offline/workerClient"
import { usePOSShiftStore } from "@/stores/posShift"

const defaultSnapshot = () => ({
subtotal: 0,
Expand Down Expand Up @@ -283,6 +284,13 @@ export const usePOSOffersStore = defineStore("posOffers", () => {
* @returns {Promise<boolean>} True if offers are available (fetched or cached)
*/
async function ensureOffersFetched(posProfile) {
// Skip fetching offers if POS Profile has ignore_pricing_rule enabled
const shiftStore = usePOSShiftStore()
if (shiftStore.currentProfile?.ignore_pricing_rule) {
hasFetched.value = true
return false
}

// If already fetched, return immediately
if (hasFetched.value) {
return true
Expand Down
1 change: 1 addition & 0 deletions pos_next/api/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def get_initial_data():
"print_format": pos_profile.get("print_format"),
"auto_print": pos_profile.get("print_receipt_on_order_complete", 0),
"country": pos_profile.get("country"),
"ignore_pricing_rule": pos_profile.ignore_pricing_rule or 0,
}

result["pos_settings"] = _get_pos_settings(pos_profile)
Expand Down
4 changes: 4 additions & 0 deletions pos_next/api/invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2634,6 +2634,10 @@ def apply_offers(invoice_data, selected_offers=None):

profile = frappe.get_cached_doc("POS Profile", invoice.get("pos_profile"))

# Respect POS Profile's ignore_pricing_rule setting
if profile.ignore_pricing_rule:
return {"items": items}

# Batch fetch all item details in a single query (reduces N queries to 1)
item_codes = list({item.get("item_code") for item in items if item.get("item_code")})
item_details_map = {}
Expand Down
5 changes: 5 additions & 0 deletions pos_next/api/offers.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ def get_offers(pos_profile: str) -> List[Dict]:
"""
try:
profile = frappe.get_doc("POS Profile", pos_profile)

# Respect POS Profile's ignore_pricing_rule setting
if profile.ignore_pricing_rule:
return []

date = nowdate()

offers = []
Expand Down
Loading