Skip to content

Commit

Permalink
fix: asset depreciation ledger (backport #37991) (#37992)
Browse files Browse the repository at this point in the history
* fix: asset depreciation ledger (#37991)

* fix: include opening acc depr while calculating asset depr ledger report

* chore: include opening acc depr properly in acc depr amt

* chore: add cost_center in asset depr ledger report

* fix: handle finance books properly in asset depr ledger report

* chore: rename 'include default book entries' to 'include default FB entries'

(cherry picked from commit 9a171db)

# Conflicts:
#	erpnext/accounts/report/balance_sheet/balance_sheet.js
#	erpnext/accounts/report/cash_flow/cash_flow.js
#	erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
#	erpnext/accounts/report/trial_balance/trial_balance.js
#	erpnext/translations/pl.csv
#	erpnext/translations/tr.csv

* chore: fix conflict in balance_sheet.js

* chore: fix conflict in cash_flow.js

* chore: fix conflict in consolidated_financial_statement.js

* chore: fix conflict in trial_balance.js

* chore: fix conflict in tr.csv

* chore: fix conflict in pl.csv

---------

Co-authored-by: Anand Baburajan <anandbaburajan@gmail.com>
  • Loading branch information
mergify[bot] and anandbaburajan authored Nov 8, 2023
1 parent c5a6b17 commit 043dc1b
Show file tree
Hide file tree
Showing 76 changed files with 131 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,29 @@ frappe.query_reports["Asset Depreciation Ledger"] = {
"fieldtype": "Link",
"options": "Asset"
},
{
"fieldname":"asset_category",
"label": __("Asset Category"),
"fieldtype": "Link",
"options": "Asset Category"
},
{
"fieldname":"cost_center",
"label": __("Cost Center"),
"fieldtype": "Link",
"options": "Cost Center"
},
{
"fieldname":"finance_book",
"label": __("Finance Book"),
"fieldtype": "Link",
"options": "Finance Book"
},
{
"fieldname":"asset_category",
"label": __("Asset Category"),
"fieldtype": "Link",
"options": "Asset Category"
}
"fieldname": "include_default_book_assets",
"label": __("Include Default FB Assets"),
"fieldtype": "Check",
"default": 1
},
]
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"add_total_row": 1,
"add_total_row": 0,
"columns": [],
"creation": "2016-04-08 14:49:58.133098",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 2,
"idx": 6,
"is_standard": "Yes",
"letterhead": null,
"modified": "2023-07-26 21:05:33.554778",
"modified": "2023-11-08 20:17:05.774211",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Asset Depreciation Ledger",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import frappe
from frappe import _
from frappe.utils import flt
from frappe.utils import cstr, flt


def execute(filters=None):
Expand Down Expand Up @@ -32,7 +32,6 @@ def get_data(filters):
filters_data.append(["against_voucher", "=", filters.get("asset")])

if filters.get("asset_category"):

assets = frappe.db.sql_list(
"""select name from tabAsset
where asset_category = %s and docstatus=1""",
Expand All @@ -41,12 +40,27 @@ def get_data(filters):

filters_data.append(["against_voucher", "in", assets])

if filters.get("finance_book"):
filters_data.append(["finance_book", "in", ["", filters.get("finance_book")]])
company_fb = frappe.get_cached_value("Company", filters.get("company"), "default_finance_book")

if filters.get("include_default_book_assets") and company_fb:
if filters.get("finance_book") and cstr(filters.get("finance_book")) != cstr(company_fb):
frappe.throw(_("To use a different finance book, please uncheck 'Include Default FB Assets'"))
else:
finance_book = company_fb
elif filters.get("finance_book"):
finance_book = filters.get("finance_book")
else:
finance_book = None

if finance_book:
or_filters_data = [["finance_book", "in", ["", finance_book]], ["finance_book", "is", "not set"]]
else:
or_filters_data = [["finance_book", "in", [""]], ["finance_book", "is", "not set"]]

gl_entries = frappe.get_all(
"GL Entry",
filters=filters_data,
or_filters=or_filters_data,
fields=["against_voucher", "debit_in_account_currency as debit", "voucher_no", "posting_date"],
order_by="against_voucher, posting_date",
)
Expand All @@ -61,7 +75,9 @@ def get_data(filters):
asset_data = assets_details.get(d.against_voucher)
if asset_data:
if not asset_data.get("accumulated_depreciation_amount"):
asset_data.accumulated_depreciation_amount = d.debit
asset_data.accumulated_depreciation_amount = d.debit + asset_data.get(
"opening_accumulated_depreciation"
)
else:
asset_data.accumulated_depreciation_amount += d.debit

Expand All @@ -70,7 +86,7 @@ def get_data(filters):
{
"depreciation_amount": d.debit,
"depreciation_date": d.posting_date,
"amount_after_depreciation": (
"value_after_depreciation": (
flt(row.gross_purchase_amount) - flt(row.accumulated_depreciation_amount)
),
"depreciation_entry": d.voucher_no,
Expand All @@ -88,10 +104,12 @@ def get_assets_details(assets):
fields = [
"name as asset",
"gross_purchase_amount",
"opening_accumulated_depreciation",
"asset_category",
"status",
"depreciation_method",
"purchase_date",
"cost_center",
]

for d in frappe.get_all("Asset", fields=fields, filters={"name": ("in", assets)}):
Expand Down Expand Up @@ -121,6 +139,12 @@ def get_columns():
"fieldtype": "Currency",
"width": 120,
},
{
"label": _("Opening Accumulated Depreciation"),
"fieldname": "opening_accumulated_depreciation",
"fieldtype": "Currency",
"width": 140,
},
{
"label": _("Depreciation Amount"),
"fieldname": "depreciation_amount",
Expand All @@ -134,8 +158,8 @@ def get_columns():
"width": 210,
},
{
"label": _("Amount After Depreciation"),
"fieldname": "amount_after_depreciation",
"label": _("Value After Depreciation"),
"fieldname": "value_after_depreciation",
"fieldtype": "Currency",
"width": 180,
},
Expand All @@ -153,12 +177,13 @@ def get_columns():
"options": "Asset Category",
"width": 120,
},
{"label": _("Current Status"), "fieldname": "status", "fieldtype": "Data", "width": 120},
{
"label": _("Depreciation Method"),
"fieldname": "depreciation_method",
"fieldtype": "Data",
"width": 130,
"label": _("Cost Center"),
"fieldtype": "Link",
"fieldname": "cost_center",
"options": "Cost Center",
"width": 100,
},
{"label": _("Current Status"), "fieldname": "status", "fieldtype": "Data", "width": 120},
{"label": _("Purchase Date"), "fieldname": "purchase_date", "fieldtype": "Date", "width": 120},
]
2 changes: 1 addition & 1 deletion erpnext/accounts/report/balance_sheet/balance_sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {

frappe.query_reports["Balance Sheet"]["filters"].push({
"fieldname": "include_default_book_entries",
"label": __("Include Default Book Entries"),
"label": __("Include Default FB Entries"),
"fieldtype": "Check",
"default": 1
});
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/report/cash_flow/cash_flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Cash Flow"]["filters"].push(
{
"fieldname": "include_default_book_entries",
"label": __("Include Default Book Entries"),
"label": __("Include Default FB Entries"),
"fieldtype": "Check",
"default": 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
},
{
"fieldname": "include_default_book_entries",
"label": __("Include Default Book Entries"),
"label": __("Include Default FB Entries"),
"fieldtype": "Check",
"default": 1
},
Expand Down
4 changes: 1 addition & 3 deletions erpnext/accounts/report/financial_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,7 @@ def apply_additional_conditions(doctype, query, from_date, ignore_closing_entrie
company_fb = frappe.get_cached_value("Company", filters.company, "default_finance_book")

if filters.finance_book and company_fb and cstr(filters.finance_book) != cstr(company_fb):
frappe.throw(
_("To use a different finance book, please uncheck 'Include Default Book Entries'")
)
frappe.throw(_("To use a different finance book, please uncheck 'Include Default FB Entries'"))

query = query.where(
(gl_entry.finance_book.isin([cstr(filters.finance_book), cstr(company_fb), ""]))
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/report/general_ledger/general_ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ frappe.query_reports["General Ledger"] = {
},
{
"fieldname": "include_default_book_entries",
"label": __("Include Default Book Entries"),
"label": __("Include Default FB Entries"),
"fieldtype": "Check",
"default": 1
},
Expand Down
4 changes: 1 addition & 3 deletions erpnext/accounts/report/general_ledger/general_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ def get_conditions(filters):
if filters.get("company_fb") and cstr(filters.get("finance_book")) != cstr(
filters.get("company_fb")
):
frappe.throw(
_("To use a different finance book, please uncheck 'Include Default Book Entries'")
)
frappe.throw(_("To use a different finance book, please uncheck 'Include Default FB Entries'"))
else:
conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)")
else:
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/report/trial_balance/trial_balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
},
{
"fieldname": "include_default_book_entries",
"label": __("Include Default Book Entries"),
"label": __("Include Default FB Entries"),
"fieldtype": "Check",
"default": 1
},
Expand Down
4 changes: 1 addition & 3 deletions erpnext/accounts/report/trial_balance/trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,7 @@ def get_opening_balance(
company_fb = frappe.get_cached_value("Company", filters.company, "default_finance_book")

if filters.finance_book and company_fb and cstr(filters.finance_book) != cstr(company_fb):
frappe.throw(
_("To use a different finance book, please uncheck 'Include Default Book Entries'")
)
frappe.throw(_("To use a different finance book, please uncheck 'Include Default FB Entries'"))

opening_balance = opening_balance.where(
(closing_balance.finance_book.isin([cstr(filters.finance_book), cstr(company_fb), ""]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ frappe.query_reports["Fixed Asset Register"] = {
},
{
"fieldname": "include_default_book_assets",
"label": __("Include Default Book Assets"),
"label": __("Include Default FB Assets"),
"fieldtype": "Check",
"default": 1
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def get_assets_linked_to_fb(filters):
company_fb = frappe.get_cached_value("Company", filters.company, "default_finance_book")

if filters.finance_book and company_fb and cstr(filters.finance_book) != cstr(company_fb):
frappe.throw(_("To use a different finance book, please uncheck 'Include Default Book Assets'"))
frappe.throw(_("To use a different finance book, please uncheck 'Include Default FB Assets'"))

query = query.where(
(afb.finance_book.isin([cstr(filters.finance_book), cstr(company_fb), ""]))
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/af.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,In Waarde,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent",In die geval van &#39;n multi-vlak program sal kliënte outomaties toegewys word aan die betrokke vlak volgens hul besteding,
Inactive,onaktiewe,
Incentives,aansporings,
Include Default Book Entries,Sluit standaardboekinskrywings in,
Include Default FB Entries,Sluit standaardboekinskrywings in,
Include Exploded Items,Sluit ontplofte items in,
Include POS Transactions,Sluit POS-transaksies in,
Include UOM,Sluit UOM in,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/am.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,እሴት ውስጥ,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent","በባለብዙ ደረጃ መርሃግብር ሁኔታ, ደንበኞች በተጠቀሱት ወጪ መሰረት ለተሰጣቸው ደረጃ ደረጃ በራስ መተላለፍ ይኖራቸዋል",
Inactive,ገባሪ አይደለም,
Incentives,ማበረታቻዎች,
Include Default Book Entries,ነባሪ የመጽሐፍ ግቤቶችን አካትት።,
Include Default FB Entries,ነባሪ የመጽሐፍ ግቤቶችን አካትት።,
Include Exploded Items,የተበተኑ ንጥሎችን አካት,
Include POS Transactions,የ POS ሽግግሮችን አክል,
Include UOM,UOM አካት,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/ar.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,القيمة القادمة,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent",في حالة البرنامج متعدد المستويات ، سيتم تعيين العملاء تلقائيًا إلى الطبقة المعنية وفقًا للإنفاق,
Inactive,غير نشط,
Incentives,الحوافز,
Include Default Book Entries,تضمين إدخالات دفتر افتراضي,
Include Default FB Entries,تضمين إدخالات دفتر افتراضي,
Include Exploded Items,تشمل البنود المستبعدة,
Include POS Transactions,تشمل معاملات نقطه البيع,
Include UOM,تضمين UOM,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/bg.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,В стойност,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent","В случай на многостепенна програма, клиентите ще бъдат автоматично зададени на съответния подреждан по тяхна сметка",
Inactive,неактивен,
Incentives,Стимули,
Include Default Book Entries,Включете записи по подразбиране на книги,
Include Default FB Entries,Включете записи по подразбиране на книги,
Include Exploded Items,Включете експлодираните елементи,
Include POS Transactions,Включете POS транзакции,
Include UOM,Включете UOM,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/bn.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,মান,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent","মাল্টি-টিয়ার প্রোগ্রামের ক্ষেত্রে, গ্রাহকরা তাদের ব্যয় অনুযায়ী সংশ্লিষ্ট টায়ারে স্বয়ংক্রিয়ভাবে নিয়োগ পাবেন",
Inactive,নিষ্ক্রিয়,
Incentives,ইনসেনটিভ,
Include Default Book Entries,ডিফল্ট বুক এন্ট্রি অন্তর্ভুক্ত করুন,
Include Default FB Entries,ডিফল্ট বুক এন্ট্রি অন্তর্ভুক্ত করুন,
Include Exploded Items,বিস্ফোরিত আইটেম অন্তর্ভুক্ত করুন,
Include POS Transactions,পিওএস লেনদেন অন্তর্ভুক্ত করুন,
Include UOM,UOM অন্তর্ভুক্ত করুন,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/bs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,u vrijednost,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent","U slučaju višeslojnog programa, Korisnici će automatski biti dodeljeni za dotičnu grupu po njihovom trošenju",
Inactive,Neaktivan,
Incentives,Poticaji,
Include Default Book Entries,Uključite zadane unose knjiga,
Include Default FB Entries,Uključite zadane unose knjiga,
Include Exploded Items,Uključite eksplodirane predmete,
Include POS Transactions,Uključite POS transakcije,
Include UOM,Uključite UOM,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/ca.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,En valor,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent","En el cas del programa de diversos nivells, els clients seran assignats automàticament al nivell corresponent segons el seu gastat",
Inactive,Inactiu,
Incentives,Incentius,
Include Default Book Entries,Inclou les entrades de llibres predeterminats,
Include Default FB Entries,Inclou les entrades de llibres predeterminats,
Include Exploded Items,Inclou articles explotats,
Include POS Transactions,Inclou transaccions de POS,
Include UOM,Inclou UOM,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/cs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,v Hodnota,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent",V případě víceúrovňového programu budou zákazníci automaticky přiděleni danému vrstvě podle svých vynaložených nákladů,
Inactive,Neaktivní,
Incentives,Pobídky,
Include Default Book Entries,Zahrnout výchozí položky knihy,
Include Default FB Entries,Zahrnout výchozí položky knihy,
Include Exploded Items,Zahrnout výbušné položky,
Include POS Transactions,Zahrnout POS transakce,
Include UOM,Zahrnout UOM,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/da.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,I Value,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent","I tilfælde af multi-tier program, vil kunder automatisk blive tildelt den pågældende tier som per deres brugt",
Inactive,inaktive,
Incentives,Incitamenter,
Include Default Book Entries,Inkluder standardbogsindlæg,
Include Default FB Entries,Inkluder standardbogsindlæg,
Include Exploded Items,Inkluder eksploderede elementer,
Include POS Transactions,Inkluder POS-transaktioner,
Include UOM,Inkluder UOM,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ In Value,Wert bei,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent",Im Falle eines mehrstufigen Programms werden Kunden automatisch der betroffenen Ebene entsprechend ihrer Ausgaben zugewiesen,
Inactive,Inaktiv,
Incentives,Anreize,
Include Default Book Entries,Standardbucheinträge einschließen,
Include Default FB Entries,Standardbucheinträge einschließen,
Include Exploded Items,Unterartikel einbeziehen,
Include POS Transactions,POS-Transaktionen einschließen,
Include UOM,Fügen Sie UOM hinzu,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/el.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,στην Αξία,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent","Στην περίπτωση προγράμματος πολλαπλών βαθμίδων, οι Πελάτες θα αντιστοιχούν αυτόματα στη σχετική βαθμίδα σύμφωνα με το ποσό που δαπανώνται",
Inactive,Αδρανής,
Incentives,Κίνητρα,
Include Default Book Entries,Συμπεριλάβετε τις προεπιλεγμένες καταχωρίσεις βιβλίων,
Include Default FB Entries,Συμπεριλάβετε τις προεπιλεγμένες καταχωρίσεις βιβλίων,
Include Exploded Items,Συμπεριλάβετε εκραγμένα στοιχεία,
Include POS Transactions,Συμπεριλάβετε τις συναλλαγές POS,
Include UOM,Συμπεριλάβετε UOM,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/es.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,En valor,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent","En el caso del programa de varios niveles, los Clientes se asignarán automáticamente al nivel correspondiente según su gasto",
Inactive,Inactivo,
Incentives,Incentivos,
Include Default Book Entries,Incluir entradas de libro predeterminadas,
Include Default FB Entries,Incluir entradas de libro predeterminadas,
Include Exploded Items,Incluir Elementos Estallados,
Include POS Transactions,Incluir transacciones POS,
Include UOM,Incluir UOM,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/et.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,väärtuse,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent",Mitmekordsete programmide korral määratakse Kliendid automaatselt asjaomasele tasemele vastavalt nende kasutatud kuludele,
Inactive,Mitteaktiivne,
Incentives,Soodustused,
Include Default Book Entries,Lisage vaikeraamatu kanded,
Include Default FB Entries,Lisage vaikeraamatu kanded,
Include Exploded Items,Kaasa lõhutud esemed,
Include POS Transactions,Kaasa POS-tehingud,
Include UOM,Lisa UOM,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/translations/fa.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ In Value,با ارزش,
"In the case of multi-tier program, Customers will be auto assigned to the concerned tier as per their spent",در مورد برنامه چند لایه، مشتریان به صورت خودکار به سطر مربوطه اختصاص داده می شوند، همانطور که در هزینه های خود هستند,
Inactive,غیر فعال,
Incentives,انگیزه,
Include Default Book Entries,شامل ورودی های پیش فرض کتاب,
Include Default FB Entries,شامل ورودی های پیش فرض کتاب,
Include Exploded Items,شامل موارد انفجار,
Include POS Transactions,شامل معاملات POS,
Include UOM,شامل UOM,
Expand Down
Loading

0 comments on commit 043dc1b

Please sign in to comment.