Skip to content

fix(cart): preserve separate cart lines per batch for batch-tracked items#281

Open
souravs72 wants to merge 1 commit into
BrainWise-DEV:developfrom
souravs72:fix/issue-266-multiple-batch-lines
Open

fix(cart): preserve separate cart lines per batch for batch-tracked items#281
souravs72 wants to merge 1 commit into
BrainWise-DEV:developfrom
souravs72:fix/issue-266-multiple-batch-lines

Conversation

@souravs72

@souravs72 souravs72 commented May 30, 2026

Copy link
Copy Markdown

Summary

Root cause

If you added a batch-tracked item, picked Batch 1, then added it again and picked Batch 2, the cart would just update the existing line's quantity instead of creating a second one. By the time the invoice was submitted, whichever batch you picked last was the only one recorded. The first batch was completely lost.
The root cause was straightforward: useInvoice.addItem was matching existing cart rows by item_code + uom only - it never looked at batch_no.

Reproduce

  1. Open POS with a batch-tracked item that has stock across at least two batches.
  2. Add the item → select Batch A → confirm.
  3. Add it again → select Batch B → confirm.
  4. Submit the invoice.

Before: One cart line, one invoice row. Last batch wins, first batch gone.
*After: Two separate cart lines, two invoice rows, both batches preserved.

Cart merge matched item_code + UOM only, so a second batch overwrote the
first line and only one batch reached the Sales Invoice. Match lines by
batch_no, add ERPNext-aligned auto-allocation for multi-batch qty, and
scope cart update/remove to the correct batch line.

Fixes BrainWise-DEV#266
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:Batch Item unable to add more than one batch

1 participant