fix: validation error has not throw for the batch (#38494) * fix: validation error has not throw for the batch * chore: fix test cases (cherry picked from commit 5e9016ffab34df9609a75a7cbbaabbb37e7159d6) Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
parent
7b363db582
commit
c797c533ed
@ -2635,6 +2635,7 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
"voucher_type": "Sales Invoice",
|
"voucher_type": "Sales Invoice",
|
||||||
"voucher_no": si.name,
|
"voucher_no": si.name,
|
||||||
"allow_zero_valuation": d.get("allow_zero_valuation"),
|
"allow_zero_valuation": d.get("allow_zero_valuation"),
|
||||||
|
"voucher_detail_no": d.name,
|
||||||
},
|
},
|
||||||
raise_error_if_no_rate=False,
|
raise_error_if_no_rate=False,
|
||||||
)
|
)
|
||||||
|
@ -118,6 +118,7 @@ class BuyingController(SubcontractingController):
|
|||||||
"company": self.company,
|
"company": self.company,
|
||||||
"voucher_type": self.doctype,
|
"voucher_type": self.doctype,
|
||||||
"voucher_no": self.name,
|
"voucher_no": self.name,
|
||||||
|
"voucher_detail_no": row.name,
|
||||||
},
|
},
|
||||||
raise_error_if_no_rate=False,
|
raise_error_if_no_rate=False,
|
||||||
)
|
)
|
||||||
@ -373,6 +374,7 @@ class BuyingController(SubcontractingController):
|
|||||||
"voucher_type": self.doctype,
|
"voucher_type": self.doctype,
|
||||||
"voucher_no": self.name,
|
"voucher_no": self.name,
|
||||||
"allow_zero_valuation": d.get("allow_zero_valuation"),
|
"allow_zero_valuation": d.get("allow_zero_valuation"),
|
||||||
|
"voucher_detail_no": d.name,
|
||||||
},
|
},
|
||||||
raise_error_if_no_rate=False,
|
raise_error_if_no_rate=False,
|
||||||
)
|
)
|
||||||
|
@ -444,6 +444,7 @@ class SellingController(StockController):
|
|||||||
"company": self.company,
|
"company": self.company,
|
||||||
"voucher_type": self.doctype,
|
"voucher_type": self.doctype,
|
||||||
"voucher_no": self.name,
|
"voucher_no": self.name,
|
||||||
|
"voucher_detail_no": d.name,
|
||||||
"allow_zero_valuation": d.get("allow_zero_valuation"),
|
"allow_zero_valuation": d.get("allow_zero_valuation"),
|
||||||
},
|
},
|
||||||
raise_error_if_no_rate=False,
|
raise_error_if_no_rate=False,
|
||||||
|
@ -880,6 +880,7 @@ class SubcontractingController(StockController):
|
|||||||
"posting_date": self.posting_date,
|
"posting_date": self.posting_date,
|
||||||
"posting_time": self.posting_time,
|
"posting_time": self.posting_time,
|
||||||
"qty": -1 * item.consumed_qty,
|
"qty": -1 * item.consumed_qty,
|
||||||
|
"voucher_detail_no": item.name,
|
||||||
"serial_and_batch_bundle": item.serial_and_batch_bundle,
|
"serial_and_batch_bundle": item.serial_and_batch_bundle,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -247,6 +247,7 @@ class SerialandBatchBundle(Document):
|
|||||||
"serial_nos": [row.serial_no for row in self.entries if row.serial_no],
|
"serial_nos": [row.serial_no for row in self.entries if row.serial_no],
|
||||||
"batch_nos": {row.batch_no: row for row in self.entries if row.batch_no},
|
"batch_nos": {row.batch_no: row for row in self.entries if row.batch_no},
|
||||||
"voucher_type": self.voucher_type,
|
"voucher_type": self.voucher_type,
|
||||||
|
"voucher_detail_no": self.voucher_detail_no,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -877,6 +877,7 @@ class StockEntry(StockController):
|
|||||||
"company": self.company,
|
"company": self.company,
|
||||||
"allow_zero_valuation": item.allow_zero_valuation_rate,
|
"allow_zero_valuation": item.allow_zero_valuation_rate,
|
||||||
"serial_and_batch_bundle": item.serial_and_batch_bundle,
|
"serial_and_batch_bundle": item.serial_and_batch_bundle,
|
||||||
|
"voucher_detail_no": item.name,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -940,6 +940,42 @@ class TestStockEntry(FrappeTestCase):
|
|||||||
stock_entry.insert()
|
stock_entry.insert()
|
||||||
self.assertTrue("_Test Variant Item-S" in [d.item_code for d in stock_entry.items])
|
self.assertTrue("_Test Variant Item-S" in [d.item_code for d in stock_entry.items])
|
||||||
|
|
||||||
|
def test_nagative_stock_for_batch(self):
|
||||||
|
item = make_item(
|
||||||
|
"_Test Batch Negative Item",
|
||||||
|
{
|
||||||
|
"has_batch_no": 1,
|
||||||
|
"create_new_batch": 1,
|
||||||
|
"batch_number_series": "B-BATCH-.##",
|
||||||
|
"is_stock_item": 1,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
make_stock_entry(item_code=item.name, target="_Test Warehouse - _TC", qty=50, basic_rate=100)
|
||||||
|
|
||||||
|
ste = frappe.new_doc("Stock Entry")
|
||||||
|
ste.purpose = "Material Issue"
|
||||||
|
ste.company = "_Test Company"
|
||||||
|
for qty in [50, 20, 30]:
|
||||||
|
ste.append(
|
||||||
|
"items",
|
||||||
|
{
|
||||||
|
"item_code": item.name,
|
||||||
|
"s_warehouse": "_Test Warehouse - _TC",
|
||||||
|
"qty": qty,
|
||||||
|
"uom": item.stock_uom,
|
||||||
|
"stock_uom": item.stock_uom,
|
||||||
|
"conversion_factor": 1,
|
||||||
|
"transfer_qty": qty,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
ste.set_stock_entry_type()
|
||||||
|
ste.insert()
|
||||||
|
make_stock_entry(item_code=item.name, target="_Test Warehouse - _TC", qty=50, basic_rate=100)
|
||||||
|
|
||||||
|
self.assertRaises(frappe.ValidationError, ste.submit)
|
||||||
|
|
||||||
def test_same_serial_nos_in_repack_or_manufacture_entries(self):
|
def test_same_serial_nos_in_repack_or_manufacture_entries(self):
|
||||||
s1 = make_serialized_item(target_warehouse="_Test Warehouse - _TC")
|
s1 = make_serialized_item(target_warehouse="_Test Warehouse - _TC")
|
||||||
serial_nos = get_serial_nos_from_bundle(s1.get("items")[0].serial_and_batch_bundle)
|
serial_nos = get_serial_nos_from_bundle(s1.get("items")[0].serial_and_batch_bundle)
|
||||||
|
@ -485,9 +485,9 @@ class TestStockLedgerEntry(FrappeTestCase, StockTestMixin):
|
|||||||
dns = create_delivery_note_entries_for_batchwise_item_valuation_test(dn_entry_list)
|
dns = create_delivery_note_entries_for_batchwise_item_valuation_test(dn_entry_list)
|
||||||
sle_details = fetch_sle_details_for_doc_list(dns, ["stock_value_difference"])
|
sle_details = fetch_sle_details_for_doc_list(dns, ["stock_value_difference"])
|
||||||
svd_list = [-1 * d["stock_value_difference"] for d in sle_details]
|
svd_list = [-1 * d["stock_value_difference"] for d in sle_details]
|
||||||
expected_incoming_rates = expected_abs_svd = sorted([75.0, 125.0, 75.0, 125.0])
|
expected_incoming_rates = expected_abs_svd = [75.0, 125.0, 75.0, 125.0]
|
||||||
|
|
||||||
self.assertEqual(expected_abs_svd, sorted(svd_list), "Incorrect 'Stock Value Difference' values")
|
self.assertEqual(expected_abs_svd, svd_list, "Incorrect 'Stock Value Difference' values")
|
||||||
for dn, incoming_rate in zip(dns, expected_incoming_rates):
|
for dn, incoming_rate in zip(dns, expected_incoming_rates):
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
dn.items[0].incoming_rate in expected_abs_svd,
|
dn.items[0].incoming_rate in expected_abs_svd,
|
||||||
|
@ -406,7 +406,7 @@ class SerialNoValuation(DeprecatedSerialNoValuation):
|
|||||||
.orderby(bundle.posting_date, bundle.posting_time, bundle.creation)
|
.orderby(bundle.posting_date, bundle.posting_time, bundle.creation)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Important to exclude the current voucher
|
# Important to exclude the current voucher to calculate correct the stock value difference
|
||||||
if self.sle.voucher_no:
|
if self.sle.voucher_no:
|
||||||
query = query.where(bundle.voucher_no != self.sle.voucher_no)
|
query = query.where(bundle.voucher_no != self.sle.voucher_no)
|
||||||
|
|
||||||
@ -539,8 +539,10 @@ class BatchNoValuation(DeprecatedBatchNoValuation):
|
|||||||
.groupby(child.batch_no)
|
.groupby(child.batch_no)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Important to exclude the current voucher
|
# Important to exclude the current voucher detail no / voucher no to calculate the correct stock value difference
|
||||||
if self.sle.voucher_no:
|
if self.sle.voucher_detail_no:
|
||||||
|
query = query.where(parent.voucher_detail_no != self.sle.voucher_detail_no)
|
||||||
|
elif self.sle.voucher_no:
|
||||||
query = query.where(parent.voucher_no != self.sle.voucher_no)
|
query = query.where(parent.voucher_no != self.sle.voucher_no)
|
||||||
|
|
||||||
if timestamp_condition:
|
if timestamp_condition:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user