mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-24 05:32:46 +01:00
fix: batch qty calculation
(cherry picked from commit f07a71a882)
Co-authored-by: Rohit Waghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -835,7 +835,8 @@ class TestPOSInvoice(unittest.TestCase):
|
|||||||
{
|
{
|
||||||
"item_code": item.name,
|
"item_code": item.name,
|
||||||
"warehouse": pos_inv2.items[0].warehouse,
|
"warehouse": pos_inv2.items[0].warehouse,
|
||||||
"voucher_type": "Delivery Note",
|
"voucher_type": "POS Invoice",
|
||||||
|
"voucher_no": pos_inv2.name,
|
||||||
"qty": 2,
|
"qty": 2,
|
||||||
"avg_rate": 300,
|
"avg_rate": 300,
|
||||||
"batches": frappe._dict({"TestBatch 01": 2}),
|
"batches": frappe._dict({"TestBatch 01": 2}),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from frappe.model.naming import make_autoname
|
|||||||
from frappe.query_builder.functions import CombineDatetime, Sum, Timestamp
|
from frappe.query_builder.functions import CombineDatetime, Sum, Timestamp
|
||||||
from frappe.utils import add_days, cint, cstr, flt, get_link_to_form, now, nowtime, today
|
from frappe.utils import add_days, cint, cstr, flt, get_link_to_form, now, nowtime, today
|
||||||
from pypika import Order
|
from pypika import Order
|
||||||
|
from pypika.terms import ExistsCriterion
|
||||||
|
|
||||||
from erpnext.stock.deprecated_serial_batch import (
|
from erpnext.stock.deprecated_serial_batch import (
|
||||||
DeprecatedBatchNoValuation,
|
DeprecatedBatchNoValuation,
|
||||||
@@ -650,6 +651,7 @@ class BatchNoValuation(DeprecatedBatchNoValuation):
|
|||||||
|
|
||||||
parent = frappe.qb.DocType("Serial and Batch Bundle")
|
parent = frappe.qb.DocType("Serial and Batch Bundle")
|
||||||
child = frappe.qb.DocType("Serial and Batch Entry")
|
child = frappe.qb.DocType("Serial and Batch Entry")
|
||||||
|
sle = frappe.qb.DocType("Stock Ledger Entry")
|
||||||
|
|
||||||
timestamp_condition = ""
|
timestamp_condition = ""
|
||||||
if self.sle.posting_date:
|
if self.sle.posting_date:
|
||||||
@@ -682,6 +684,14 @@ class BatchNoValuation(DeprecatedBatchNoValuation):
|
|||||||
& (parent.docstatus == 1)
|
& (parent.docstatus == 1)
|
||||||
& (parent.is_cancelled == 0)
|
& (parent.is_cancelled == 0)
|
||||||
& (parent.type_of_transaction.isin(["Inward", "Outward"]))
|
& (parent.type_of_transaction.isin(["Inward", "Outward"]))
|
||||||
|
& (
|
||||||
|
ExistsCriterion(
|
||||||
|
frappe.qb.from_(sle)
|
||||||
|
.select(sle.name)
|
||||||
|
.where((parent.name == sle.serial_and_batch_bundle) & (sle.is_cancelled == 0))
|
||||||
|
)
|
||||||
|
| (parent.voucher_type == "POS Invoice")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.groupby(child.batch_no)
|
.groupby(child.batch_no)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user