mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 20:29:09 +00:00
refactor: cleanup args structure akin to some typing (#44226)
* refactor: cleanup args structure akin to some typing this clarification is a human precondition to being able to fix https://github.com/frappe/erpnext/issues/44219 * chore: excempt previous commit from git blame * fix: adapt signature
This commit is contained in:
@@ -38,3 +38,6 @@ ec74a5e56617bbd76ac402451468fd4668af543d
|
|||||||
|
|
||||||
# ruff formatting
|
# ruff formatting
|
||||||
a308792ee7fda18a681e9181f4fd00b36385bc23
|
a308792ee7fda18a681e9181f4fd00b36385bc23
|
||||||
|
|
||||||
|
# noisy typing refactoring of get_item_details
|
||||||
|
7b7211ac79c248a79ba8a999ff34e734d874c0ae
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ class POSInvoice(SalesInvoice):
|
|||||||
|
|
||||||
def set_pos_fields(self, for_validate=False):
|
def set_pos_fields(self, for_validate=False):
|
||||||
"""Set retail related fields from POS Profiles"""
|
"""Set retail related fields from POS Profiles"""
|
||||||
from erpnext.stock.get_item_details import get_pos_profile, get_pos_profile_item_details
|
from erpnext.stock.get_item_details import get_pos_profile, get_pos_profile_item_details_
|
||||||
|
|
||||||
if not self.pos_profile:
|
if not self.pos_profile:
|
||||||
pos_profile = get_pos_profile(self.company) or {}
|
pos_profile = get_pos_profile(self.company) or {}
|
||||||
@@ -602,8 +602,8 @@ class POSInvoice(SalesInvoice):
|
|||||||
# set pos values in items
|
# set pos values in items
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if item.get("item_code"):
|
if item.get("item_code"):
|
||||||
profile_details = get_pos_profile_item_details(
|
profile_details = get_pos_profile_item_details_(
|
||||||
profile.get("company"), frappe._dict(item.as_dict()), profile
|
frappe._dict(item.as_dict()), profile.get("company"), profile
|
||||||
)
|
)
|
||||||
for fname, val in profile_details.items():
|
for fname, val in profile_details.items():
|
||||||
if (not for_validate) or (for_validate and not item.get(fname)):
|
if (not for_validate) or (for_validate and not item.get(fname)):
|
||||||
|
|||||||
@@ -766,7 +766,7 @@ class SalesInvoice(SellingController):
|
|||||||
"Company", self.company, "default_cash_account"
|
"Company", self.company, "default_cash_account"
|
||||||
)
|
)
|
||||||
|
|
||||||
from erpnext.stock.get_item_details import get_pos_profile, get_pos_profile_item_details
|
from erpnext.stock.get_item_details import get_pos_profile, get_pos_profile_item_details_
|
||||||
|
|
||||||
if not self.pos_profile and not self.flags.ignore_pos_profile:
|
if not self.pos_profile and not self.flags.ignore_pos_profile:
|
||||||
pos_profile = get_pos_profile(self.company) or {}
|
pos_profile = get_pos_profile(self.company) or {}
|
||||||
@@ -834,8 +834,8 @@ class SalesInvoice(SellingController):
|
|||||||
# set pos values in items
|
# set pos values in items
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if item.get("item_code"):
|
if item.get("item_code"):
|
||||||
profile_details = get_pos_profile_item_details(
|
profile_details = get_pos_profile_item_details_(
|
||||||
pos, frappe._dict(item.as_dict()), pos, update_data=True
|
frappe._dict(item.as_dict()), pos, pos, update_data=True
|
||||||
)
|
)
|
||||||
for fname, val in profile_details.items():
|
for fname, val in profile_details.items():
|
||||||
if (not for_validate) or (for_validate and not item.get(fname)):
|
if (not for_validate) or (for_validate and not item.get(fname)):
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ from erpnext.stock.doctype.item.item import get_item_defaults
|
|||||||
from erpnext.stock.get_item_details import (
|
from erpnext.stock.get_item_details import (
|
||||||
get_default_cost_center,
|
get_default_cost_center,
|
||||||
get_default_expense_account,
|
get_default_expense_account,
|
||||||
get_item_warehouse,
|
get_item_warehouse_,
|
||||||
)
|
)
|
||||||
from erpnext.stock.stock_ledger import get_previous_sle
|
from erpnext.stock.stock_ledger import get_previous_sle
|
||||||
from erpnext.stock.utils import get_incoming_rate
|
from erpnext.stock.utils import get_incoming_rate
|
||||||
@@ -785,11 +785,11 @@ def get_target_asset_details(asset=None, company=None):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_consumed_stock_item_details(args):
|
def get_consumed_stock_item_details(args_):
|
||||||
if isinstance(args, str):
|
if isinstance(args_, str):
|
||||||
args = json.loads(args)
|
args_ = json.loads(args_)
|
||||||
|
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args_)
|
||||||
out = frappe._dict()
|
out = frappe._dict()
|
||||||
|
|
||||||
item = frappe._dict()
|
item = frappe._dict()
|
||||||
@@ -803,7 +803,7 @@ def get_consumed_stock_item_details(args):
|
|||||||
out.stock_qty = flt(args.stock_qty) or 1
|
out.stock_qty = flt(args.stock_qty) or 1
|
||||||
out.stock_uom = item.stock_uom
|
out.stock_uom = item.stock_uom
|
||||||
|
|
||||||
out.warehouse = get_item_warehouse(item, args, overwrite_warehouse=True) if item else None
|
out.warehouse = get_item_warehouse_(args, item, overwrite_warehouse=True) if item else None
|
||||||
|
|
||||||
# Cost Center
|
# Cost Center
|
||||||
item_defaults = get_item_defaults(item.name, args.company)
|
item_defaults = get_item_defaults(item.name, args.company)
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ from erpnext.stock.get_item_details import (
|
|||||||
get_conversion_factor,
|
get_conversion_factor,
|
||||||
get_item_details,
|
get_item_details,
|
||||||
get_item_tax_map,
|
get_item_tax_map,
|
||||||
get_item_warehouse,
|
get_item_warehouse_,
|
||||||
)
|
)
|
||||||
from erpnext.utilities.regional import temporary_flag
|
from erpnext.utilities.regional import temporary_flag
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from erpnext.utilities.transaction_base import TransactionBase
|
||||||
@@ -3218,7 +3218,7 @@ def set_order_defaults(parent_doctype, parent_doctype_name, child_doctype, child
|
|||||||
child_item.update({date_fieldname: trans_item.get(date_fieldname) or p_doc.get(date_fieldname)})
|
child_item.update({date_fieldname: trans_item.get(date_fieldname) or p_doc.get(date_fieldname)})
|
||||||
child_item.stock_uom = item.stock_uom
|
child_item.stock_uom = item.stock_uom
|
||||||
child_item.uom = trans_item.get("uom") or item.stock_uom
|
child_item.uom = trans_item.get("uom") or item.stock_uom
|
||||||
child_item.warehouse = get_item_warehouse(item, p_doc, overwrite_warehouse=True)
|
child_item.warehouse = get_item_warehouse_(p_doc, item, overwrite_warehouse=True)
|
||||||
conversion_factor = flt(get_conversion_factor(item.item_code, child_item.uom).get("conversion_factor"))
|
conversion_factor = flt(get_conversion_factor(item.item_code, child_item.uom).get("conversion_factor"))
|
||||||
child_item.conversion_factor = flt(trans_item.get("conversion_factor")) or conversion_factor
|
child_item.conversion_factor = flt(trans_item.get("conversion_factor")) or conversion_factor
|
||||||
|
|
||||||
@@ -3227,7 +3227,7 @@ def set_order_defaults(parent_doctype, parent_doctype_name, child_doctype, child
|
|||||||
child_item.base_rate = 1
|
child_item.base_rate = 1
|
||||||
child_item.base_amount = 1
|
child_item.base_amount = 1
|
||||||
if child_doctype == "Sales Order Item":
|
if child_doctype == "Sales Order Item":
|
||||||
child_item.warehouse = get_item_warehouse(item, p_doc, overwrite_warehouse=True)
|
child_item.warehouse = get_item_warehouse_(p_doc, item, overwrite_warehouse=True)
|
||||||
if not child_item.warehouse:
|
if not child_item.warehouse:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
|
|||||||
@@ -125,3 +125,27 @@ def taxes_and_totals_get_itemised_taxable_amount(items):
|
|||||||
itemised_taxable_amount[item_code] += item.net_amount
|
itemised_taxable_amount[item_code] += item.net_amount
|
||||||
|
|
||||||
return itemised_taxable_amount
|
return itemised_taxable_amount
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated(
|
||||||
|
"erpnext.stock.get_pos_profile_item_details",
|
||||||
|
"2024-11-19",
|
||||||
|
"v16",
|
||||||
|
"Use erpnext.stock.get_pos_profile_item_details_ with a flipped signature",
|
||||||
|
)
|
||||||
|
def get_pos_profile_item_details(company, ctx, pos_profile=None, update_data=False):
|
||||||
|
from erpnext.stock.get_item_details import get_pos_profile_item_details_
|
||||||
|
|
||||||
|
return get_pos_profile_item_details_(ctx, company, pos_profile=pos_profile, update_data=update_data)
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated(
|
||||||
|
"erpnext.stock.get_item_warehouse",
|
||||||
|
"2024-11-19",
|
||||||
|
"v16",
|
||||||
|
"Use erpnext.stock.get_item_warehouse_ with a flipped signature",
|
||||||
|
)
|
||||||
|
def get_item_warehouse(item, ctx, overwrite_warehouse, defaults=None):
|
||||||
|
from erpnext.stock.get_item_details import get_item_warehouse_
|
||||||
|
|
||||||
|
return get_item_warehouse_(ctx, item, overwrite_warehouse, defaults=defaults)
|
||||||
|
|||||||
@@ -860,7 +860,7 @@ def make_material_request(source_name, target_doc=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
target.rate = flt(
|
target.rate = flt(
|
||||||
get_price_list_rate(args=args, item_doc=frappe.get_cached_doc("Item", target.item_code)).get(
|
get_price_list_rate(args, item_doc=frappe.get_cached_doc("Item", target.item_code)).get(
|
||||||
"price_list_rate"
|
"price_list_rate"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from frappe.tests import IntegrationTestCase, UnitTestCase
|
|||||||
from frappe.tests.utils import make_test_records_for_doctype
|
from frappe.tests.utils import make_test_records_for_doctype
|
||||||
|
|
||||||
from erpnext.stock.doctype.item_price.item_price import ItemPriceDuplicateItem
|
from erpnext.stock.doctype.item_price.item_price import ItemPriceDuplicateItem
|
||||||
from erpnext.stock.get_item_details import get_price_list_rate_for, process_args
|
from erpnext.stock.get_item_details import get_price_list_rate_for
|
||||||
|
|
||||||
|
|
||||||
class UnitTestItemPrice(UnitTestCase):
|
class UnitTestItemPrice(UnitTestCase):
|
||||||
@@ -88,7 +88,7 @@ class TestItemPrice(IntegrationTestCase):
|
|||||||
"qty": 10,
|
"qty": 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
price = get_price_list_rate_for(process_args(args), doc.item_code)
|
price = get_price_list_rate_for(args, doc.item_code)
|
||||||
self.assertEqual(price, 20.0)
|
self.assertEqual(price, 20.0)
|
||||||
|
|
||||||
def test_price_with_no_qty(self):
|
def test_price_with_no_qty(self):
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user