mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
fix: company wise deferred accounting fields in item (#37023)
* fix: company wise deferred accounting fields in item (#37023)
* fix: move deferred accounts in accounting section
* fix: move deferred check boxes in item accounting
* fix: show company wise acc in filters
* fix: fetch item deferred account from child table
* fix: tests using deferred acc
* refactor: use cached value
* fix: cached value call
* feat: patch to migrate deferred acc
* fix: hardcode education module doctypes in patch
* chore: resolve conflicts
---------
Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
(cherry picked from commit 099468e3cf)
# Conflicts:
# erpnext/patches.txt
# erpnext/patches/v14_0/delete_education_doctypes.py
# erpnext/stock/doctype/item/item.json
* chore: resolve conflicts
* chore: resolve conflicts
---------
Co-authored-by: Gursheen Kaur Anand <40693548+GursheenK@users.noreply.github.com>
Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
This commit is contained in:
@@ -46,6 +46,17 @@ def execute():
|
||||
for doctype in doctypes:
|
||||
frappe.delete_doc("DocType", doctype, ignore_missing=True)
|
||||
|
||||
titles = [
|
||||
"Fees",
|
||||
"Student Admission",
|
||||
"Grant Application",
|
||||
"Chapter",
|
||||
"Certification Application",
|
||||
]
|
||||
items = frappe.get_all("Portal Menu Item", filters=[["title", "in", titles]], pluck="name")
|
||||
for item in items:
|
||||
frappe.delete_doc("Portal Menu Item", item, ignore_missing=True, force=True)
|
||||
|
||||
frappe.delete_doc("Module Def", "Education", ignore_missing=True, force=True)
|
||||
|
||||
click.secho(
|
||||
|
||||
@@ -41,7 +41,7 @@ def execute():
|
||||
for card in cards:
|
||||
frappe.delete_doc("Number Card", card, ignore_missing=True, force=True)
|
||||
|
||||
titles = ["Lab Test", "Prescription", "Patient Appointment"]
|
||||
titles = ["Lab Test", "Prescription", "Patient Appointment", "Patient"]
|
||||
items = frappe.get_all("Portal Menu Item", filters=[["title", "in", titles]], pluck="name")
|
||||
for item in items:
|
||||
frappe.delete_doc("Portal Menu Item", item, ignore_missing=True, force=True)
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
try:
|
||||
item_dict = get_deferred_accounts()
|
||||
add_to_item_defaults(item_dict)
|
||||
except Exception:
|
||||
frappe.db.rollback()
|
||||
frappe.log_error("Failed to migrate deferred accounts in Item Defaults.")
|
||||
|
||||
|
||||
def get_deferred_accounts():
|
||||
item = frappe.qb.DocType("Item")
|
||||
return (
|
||||
frappe.qb.from_(item)
|
||||
.select(item.name, item.deferred_expense_account, item.deferred_revenue_account)
|
||||
.where((item.enable_deferred_expense == 1) | (item.enable_deferred_revenue == 1))
|
||||
.run(as_dict=True)
|
||||
)
|
||||
|
||||
|
||||
def add_to_item_defaults(item_dict):
|
||||
for item in item_dict:
|
||||
add_company_wise_item_default(item, "deferred_expense_account")
|
||||
add_company_wise_item_default(item, "deferred_revenue_account")
|
||||
|
||||
|
||||
def add_company_wise_item_default(item, account_type):
|
||||
company = frappe.get_cached_value("Account", item[account_type], "company")
|
||||
if company and item[account_type]:
|
||||
item_defaults = frappe.get_cached_value("Item", item["name"], "item_defaults")
|
||||
for item_row in item_defaults:
|
||||
if item_row.company == company:
|
||||
frappe.set_value("Item Default", item_row.name, account_type, item[account_type])
|
||||
break
|
||||
else:
|
||||
item_defaults.append({"company": company, account_type: item[account_type]})
|
||||
frappe.set_value("Item", item["name"], "item_defaults", item_defaults)
|
||||
Reference in New Issue
Block a user