fix: print item kit name on receipts for Kit Only print - #4635
fix: print item kit name on receipts for Kit Only print#4635richardmilles wants to merge 3 commits into
Conversation
Cast kit price/print options as ints (bool coercion broke PRINT_KIT), honor an explicit print override in kit mode, force the linked kit item printable, and display item_kits.name on the receipt line. Fixes opensourcepos#4154
📝 WalkthroughWalkthroughItem-kit sales now pass explicit print options, apply integer kit options, and rename the linked cart line to the kit name for kit-only printing. ChangesItem Kit Printing
Estimated code review effort: 2 (Simple) | ~15 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/Controllers/Sales.php`:
- Around line 575-582: Ensure each item kit gets a distinct cart header identity
after Sale_lib::add_item(), rather than locating lines by item_id alone. Update
the kit-header creation and subsequent loop so only the newly added kit line
receives the item-kit name and PRINT_KIT print option, preserving separate
headers when linked items or multiple kits share the same item_id.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3edc4c42-ea60-4afc-a1f6-0fafc0049d67
📒 Files selected for processing (2)
app/Controllers/Sales.phpapp/Libraries/Sale_lib.php
| foreach ($cart as $line => $cart_item) { | ||
| if ((string)$cart_item['item_id'] === (string)$kit_item_id) { | ||
| $cart[$line]['name'] = $item_kit_info->name; | ||
| if ((int)$kit_print_option === PRINT_KIT) { | ||
| $cart[$line]['print_option'] = PRINT_YES; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Use a unique cart-line identity for the kit header.
Sale_lib::add_item() merges non-serialized lines by item_id and item_location. If the sale already contains $kit_item_id, this loop renames that ordinary line to the item-kit name and, for PRINT_KIT, forces it printable. A later kit with the same linked item can also overwrite the earlier kit name.
Create or retain a distinct header line for each item kit. Update only that line after add_item(). Do not select receipt lines by item_id alone.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@app/Controllers/Sales.php` around lines 575 - 582, Ensure each item kit gets
a distinct cart header identity after Sale_lib::add_item(), rather than locating
lines by item_id alone. Update the kit-header creation and subsequent loop so
only the newly added kit line receives the item-kit name and PRINT_KIT print
option, preserving separate headers when linked items or multiple kits share the
same item_id.
Kit price/print options were typed as bool, so PRINT_KIT was coerced and kit-mode print overrides were ignored. This passes ints, honors an explicit print override for the linked kit item, and displays item_kits.name on the receipt line.
Fixes #4154
Summary by CodeRabbit