Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7747732
feat(pricing): implement cheapest item discount functionality
MostafaKadry Jan 12, 2026
2fbb497
refactor(pricing): update discount application logic
MostafaKadry Jan 13, 2026
1321bf1
- Updated the discount application logic to ensure rates are calculat…
MostafaKadry Jan 13, 2026
d0e4df8
remove unwanted changes
MostafaKadry Jan 13, 2026
ac7eed1
remove unwanted changes
MostafaKadry Jan 13, 2026
c675c9b
fix(pricing): enhance pricing rule logic and error handling
MostafaKadry Jan 14, 2026
44658bd
perf(pricing-rule): optimize min/max price discount application
MostafaKadry Jan 22, 2026
fa37e63
feat(pricing): add support for Min/Max discount quantity limit
MostafaKadry Jan 25, 2026
dd51ec3
Merge branch 'develop' into apply_discount_to_min_price_items
MostafaKadry Jan 25, 2026
661a95e
FIX Critical Issues
MostafaKadry Jan 27, 2026
973e737
Merge branch 'develop' into apply_discount_to_min_price_items
MostafaKadry Jan 27, 2026
f75fc59
FIX Medium Issues and Minor Issues
MostafaKadry Jan 27, 2026
d206c5f
- Modified return behavior to skip standard pricing rule application …
MostafaKadry Jan 27, 2026
7e524a3
feat(cart): enhance offer validation and application process
MostafaKadry Jan 27, 2026
b2698e6
refactor(pricing): go with moky patching
MostafaKadry Jan 28, 2026
c49b877
refactor(pricing): streamline discount calculation and item update
MostafaKadry Jan 28, 2026
ed76513
Merge branch 'develop' into apply_discount_to_min_price_items and use…
MostafaKadry Mar 8, 2026
9f26b87
Refactor: Remove specific pricing rule fields from whitelisted list
MostafaKadry Mar 8, 2026
be4142a
Merge branch 'develop' into apply_discount_to_min_price_items
MostafaKadry Apr 9, 2026
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
114 changes: 114 additions & 0 deletions pos_next/fixtures/custom_field.json
Original file line number Diff line number Diff line change
Expand Up @@ -511,5 +511,119 @@
"translatable": 0,
"unique": 0,
"width": null
},
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"default": "",
"depends_on": "eval:doc.price_or_product_discount == 'Price'",
"description": "Apply discount on Min (cheapest) or Max (most expensive) item from items that have this pricing rule",
"docstatus": 0,
"doctype": "Custom Field",
"dt": "Pricing Rule",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "apply_discount_on_price",
"fieldtype": "Select",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "rate_or_discount",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Apply Discount On",
"length": 0,
"link_filters": null,
"mandatory_depends_on": null,
"modified": "2025-01-01 00:00:00.000000",
"module": "POS Next",
"name": "Pricing Rule-apply_discount_on_price",
"no_copy": 0,
"non_negative": 0,
"options": "\nMin\nMax",
"permlevel": 0,
"placeholder": null,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"show_dashboard": 0,
"sort_options": 0,
"translatable": 0,
"unique": 0,
"width": null
},
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"default": "0.0",
"depends_on": "eval:doc.apply_discount_on_price == 'Min' || doc.apply_discount_on_price == 'Max'",
"description": "Quantity limit for applying discount on Min/Max priced item. Leave 0 for no limit.",
"docstatus": 0,
"doctype": "Custom Field",
"dt": "Pricing Rule",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "min_or_max_discount_qty_limit",
"fieldtype": "Float",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "apply_discount_on_price",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Min/Max Discount Qty Limit",
"length": 0,
"link_filters": null,
"mandatory_depends_on": null,
"modified": "2025-01-01 00:00:00.000000",
"module": "POS Next",
"name": "Pricing Rule-min_or_max_discount_qty_limit",
"no_copy": 0,
"non_negative": 1,
"options": null,
"permlevel": 0,
"placeholder": null,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"show_dashboard": 0,
"sort_options": 0,
"translatable": 0,
"unique": 0,
"width": null
}
]
28 changes: 24 additions & 4 deletions pos_next/hooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pos_next.utils import get_build_version

import frappe
app_name = "pos_next"
app_title = "POS Next"
app_publisher = "BrainWise"
Expand Down Expand Up @@ -100,7 +100,9 @@
"POS Profile-posa_cash_mode_of_payment",
"POS Profile-posa_allow_delete",
"POS Profile-posa_block_sale_beyond_available_qty",
"Mode of Payment-is_wallet_payment"
"Mode of Payment-is_wallet_payment",
"Pricing Rule-apply_discount_on_price",
"Pricing Rule-min_or_max_discount_qty_limit"
]
]
]
Expand Down Expand Up @@ -207,7 +209,8 @@
"Sales Invoice": {
"validate": [
"pos_next.api.sales_invoice_hooks.validate",
"pos_next.api.wallet.validate_wallet_payment"
"pos_next.api.wallet.validate_wallet_payment",
"pos_next.overrides.pricing_rule.apply_min_max_price_discounts"
],
"before_cancel": "pos_next.api.sales_invoice_hooks.before_cancel",
"on_submit": [
Expand All @@ -219,6 +222,18 @@
},
"POS Profile": {
"on_update": "pos_next.realtime_events.emit_pos_profile_updated_event"
},
"Sales Order": {
"validate": "pos_next.overrides.pricing_rule.apply_min_max_price_discounts"
},
"Quotation": {
"validate": "pos_next.overrides.pricing_rule.apply_min_max_price_discounts"
},
"Delivery Note": {
"validate": "pos_next.overrides.pricing_rule.apply_min_max_price_discounts"
},
"POS Invoice": {
"validate": "pos_next.overrides.pricing_rule.apply_min_max_price_discounts"
}
}

Expand All @@ -237,7 +252,12 @@
"pos_next.tasks.branding_monitor.reset_tampering_counter",
],
}

try:
from erpnext.accounts.doctype.pricing_rule import pricing_rule as pricing_rule_module
from pos_next.overrides.pricing_rule import apply_price_discount_rule
pricing_rule_module.apply_price_discount_rule = apply_price_discount_rule
except Exception as e:
frappe.log_error(frappe.get_traceback(), "Error in pricing rule module")
# Testing
# -------

Expand Down
Loading
Loading