feat: show applied Promotional Scheme as a Link on Sales Invoice item#322
Open
engahmed1190 wants to merge 11 commits into
Open
feat: show applied Promotional Scheme as a Link on Sales Invoice item#322engahmed1190 wants to merge 11 commits into
engahmed1190 wants to merge 11 commits into
Conversation
Show the Promotional Scheme / Pricing Rule name on each Sales Invoice item line (POS Next clears item.pricing_rules at save, so no rule name survives today). Per-item read-only field, formatted as '<Scheme Title> (<RULE-ID>)'. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Field becomes a read-only Link (Promotional Scheme) instead of Small Text; drop the text-label helper (Link renders the scheme natively). Resolve each applied Pricing Rule to its parent promotional_scheme in one query. Promotional Scheme has no title column in this ERPNext version (name is the title). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Item Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Avoid two consecutive identical 'if doctype == "Sales Invoice":' blocks by nesting the scheme-stamp logic with the existing one-time-offer block under a single guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merge the two Pricing Rule lookups (scheme resolution + one-time flag) into one get_all over applied_rule_names_seen; derive both the per-line scheme Link and the invoice-level one-time stamp from it. Drop the now-redundant getattr guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 & why
POS Next computes promotional offers itself and, in
update_invoice, clearsitem.pricing_rulesbefore save (to stop ERPNext zeroing the discount on the 2nd save). As a result a saved POS Sales Invoice keeps no record of which Pricing Rule / Promotional Scheme produced a line's discount — staff can't tell from the invoice which promotion applied.This adds a read-only, clickable Link on each Sales Invoice item line pointing to the Promotional Scheme that discounted it.
How
pos_applied_promotional_scheme(Link → Promotional Scheme, read-only, visible, printable when populated) on Sales Invoice Item, viacustom/sales_invoice_item.json(synced bybench migrate).update_invoice: capture each line's applied Pricing Rule names beforeitem.pricing_rulesis cleared, then after the loop resolve each rule to its parentpromotional_schemeand stamp the Link. The resolution is folded into the existing one-time-offer block under a singleif doctype == "Sales Invoice":guard, using onePricing Rulequery that feeds both the scheme Link and thepos_applied_one_time_rulesstamp.Notes / constraints
Promotional Schemehas notitlecolumn in this ERPNext version (itsnameis the title), so the Link renders the scheme name directly.Testing
test_applied_promotional_scheme_stampedtopos_next/test_promotions.py: drives a real scheme through the fullapply_offers → update_invoice → submit_invoicepipeline and asserts the discounted line links to the scheme, the undiscounted line is blank, andpricing_rulesstays cleared.bench --site nexus.local run-tests --module pos_next.test_promotions).Design docs
docs/superpowers/specs/2026-06-17-applied-pricing-rule-name-on-invoice-item-design.mddocs/superpowers/plans/2026-06-17-applied-pricing-rule-name-on-invoice-item.md🤖 Generated with Claude Code