Discount total and quantity total calculating wrong for item which has multiple batches

Hi all,
On the POS page, after adding the item which has multiple batches, the total quantity and discount calculations are getting wrong. It is taking only the last item which we have entered in the batch qty.

Example:-

If we have 2 batch items, batch-1 and batch-2. After selecting 1st batch with 2 quantity.
it is displaying correctly. When I am adding the 2nd batch with 3 quantities, then it is displaying only the 3 quantity in the total quantity field in POS page. It is not adding both 1st and 2nd batch.

update_qty_total() {
var total_item_qty = 0;
$.each(this.frm.doc[“items”] || [], function (i, d) {
if (d.qty > 0) {
total_item_qty += d.qty;
}
});
this.$qty_total.find(‘.quantity-total’).text(total_item_qty);
this.frm.set_value(“pos_total_qty”,total_item_qty);
}

This is the code from point_of_sale.js file. It is happening only for the items which have multiple batches.

Please help me with this. Thanks

I’m sure you’d have considered this, but the best option could be do do separate POS invoices for each batch. :slight_smile:

I noticed that if you searching by batch the POS screen does not resolve to the item or (I’ve forgotten which) even if it resolves to the item, it does not show the price right (maybe because it is searching for a price entry related to the batch rather than resolve the batch to an item code and then search for a price for the item code.

If this is important to you (and it would be important if you/your client are/is in retail industry where traceability and expiry dates are important, I’d be happy to collaborate with you to enhance the way POS handles multiple batches. I know that different invoices for different batches is impractical and will confuse/annoy the customer.

BTW: Please check if enabling items to be added multiple times into transactions has a different result than this. Reason I say this different batches definitely require in a regular sales Invoice (with Update Stock Checked) on ERPNext to have a separate line item for each batch. And not enabling items to be added multiple times into transactions will not let ERPNext make this transaction.

Hope this helps.

Thanks

Jay