mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 07:29:22 +00:00
Merge pull request #51712 from frappe/version-14-hotfix
chore: release v14
This commit is contained in:
@@ -728,7 +728,16 @@ class SellingController(StockController):
|
|||||||
|
|
||||||
|
|
||||||
def set_default_income_account_for_item(obj):
|
def set_default_income_account_for_item(obj):
|
||||||
for d in obj.get("items"):
|
"""Set income account as default for items in the transaction.
|
||||||
if d.item_code:
|
|
||||||
if getattr(d, "income_account", None):
|
Updates the item default income account for each item in the transaction
|
||||||
set_item_default(d.item_code, obj.company, "income_account", d.income_account)
|
if it differs from the company's default income account.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
obj: Transaction document containing items table with income_account field
|
||||||
|
"""
|
||||||
|
company_default = frappe.get_cached_value("Company", obj.company, "default_income_account")
|
||||||
|
for d in obj.get("items", default=[]):
|
||||||
|
income_account = getattr(d, "income_account", None)
|
||||||
|
if d.item_code and income_account and income_account != company_default:
|
||||||
|
set_item_default(d.item_code, obj.company, "income_account", income_account)
|
||||||
|
|||||||
@@ -1507,6 +1507,23 @@ class TestDeliveryNote(FrappeTestCase):
|
|||||||
|
|
||||||
self.assertEqual(stock_value_difference, 100.0 * 5)
|
self.assertEqual(stock_value_difference, 100.0 * 5)
|
||||||
|
|
||||||
|
def test_negative_stock_with_higher_precision(self):
|
||||||
|
original_flt_precision = frappe.db.get_default("float_precision")
|
||||||
|
frappe.db.set_single_value("System Settings", "float_precision", 7)
|
||||||
|
|
||||||
|
item_code = make_item(
|
||||||
|
"Test Negative Stock High Precision Item", properties={"is_stock_item": 1, "valuation_rate": 1}
|
||||||
|
).name
|
||||||
|
dn = create_delivery_note(
|
||||||
|
item_code=item_code,
|
||||||
|
qty=0.0000010,
|
||||||
|
do_not_submit=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertRaises(frappe.ValidationError, dn.submit)
|
||||||
|
|
||||||
|
frappe.db.set_single_value("System Settings", "float_precision", original_flt_precision)
|
||||||
|
|
||||||
|
|
||||||
def create_delivery_note(**args):
|
def create_delivery_note(**args):
|
||||||
dn = frappe.new_doc("Delivery Note")
|
dn = frappe.new_doc("Delivery Note")
|
||||||
|
|||||||
@@ -715,7 +715,11 @@ class update_entries_after:
|
|||||||
diff = self.wh_data.qty_after_transaction + flt(sle.actual_qty)
|
diff = self.wh_data.qty_after_transaction + flt(sle.actual_qty)
|
||||||
diff = flt(diff, self.flt_precision) # respect system precision
|
diff = flt(diff, self.flt_precision) # respect system precision
|
||||||
|
|
||||||
if diff < 0 and abs(diff) > 0.0001:
|
diff_threshold = 0.0001
|
||||||
|
if self.flt_precision > 4:
|
||||||
|
diff_threshold = 10 ** (-1 * self.flt_precision)
|
||||||
|
|
||||||
|
if diff < 0 and abs(diff) > diff_threshold:
|
||||||
# negative stock!
|
# negative stock!
|
||||||
exc = sle.copy().update({"diff": diff})
|
exc = sle.copy().update({"diff": diff})
|
||||||
self.exceptions.setdefault(sle.warehouse, []).append(exc)
|
self.exceptions.setdefault(sle.warehouse, []).append(exc)
|
||||||
|
|||||||
Reference in New Issue
Block a user