Merge pull request #14130 from rohitwaghchaure/fixed_financial_report
Added finance book in Asset Depreciation Ledger report, fixed asset issue
This commit is contained in:
commit
7d6cad2c67
@ -79,6 +79,19 @@ def is_perpetual_inventory_enabled(company):
|
||||
|
||||
return frappe.local.enable_perpetual_inventory[company]
|
||||
|
||||
def get_default_finance_book(company=None):
|
||||
if not company:
|
||||
company = get_default_company()
|
||||
|
||||
if not hasattr(frappe.local, 'default_finance_book'):
|
||||
frappe.local.default_finance_book = {}
|
||||
|
||||
if not company in frappe.local.default_finance_book:
|
||||
frappe.local.default_finance_book[company] = frappe.db.get_value("Company",
|
||||
company, "default_finance_book")
|
||||
|
||||
return frappe.local.default_finance_book[company]
|
||||
|
||||
def get_party_account_type(party_type):
|
||||
if not hasattr(frappe.local, 'party_account_types'):
|
||||
frappe.local.party_account_types = {}
|
||||
|
@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
from frappe import _, scrub
|
||||
from frappe.utils import getdate, nowdate, flt, cint
|
||||
|
||||
@ -333,11 +333,11 @@ class ReceivablePayableReport(object):
|
||||
values.append(self.filters.company)
|
||||
|
||||
if self.filters.finance_book:
|
||||
conditions.append("finance_book in (%s, '')")
|
||||
conditions.append("ifnull(finance_book,'') in (%s, '')")
|
||||
values.append(self.filters.finance_book)
|
||||
else:
|
||||
conditions.append("ifnull(finance_book,'')=%s")
|
||||
values.append('')
|
||||
conditions.append("ifnull(finance_book,'') in (%s, '')")
|
||||
values.append(erpnext.get_default_finance_book(self.filters.company))
|
||||
|
||||
if self.filters.get(party_type_field):
|
||||
conditions.append("party=%s")
|
||||
|
@ -31,6 +31,12 @@ frappe.query_reports["Asset Depreciation Ledger"] = {
|
||||
"fieldtype": "Link",
|
||||
"options": "Asset"
|
||||
},
|
||||
{
|
||||
"fieldname":"finance_book",
|
||||
"label": __("Finance Book"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Finance Book"
|
||||
},
|
||||
{
|
||||
"fieldname":"asset_category",
|
||||
"label": __("Asset Category"),
|
||||
|
@ -2,7 +2,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
from frappe import _
|
||||
|
||||
def execute(filters=None):
|
||||
@ -13,7 +13,7 @@ def get_data(filters):
|
||||
data = frappe.db.sql("""
|
||||
select
|
||||
a.name as asset, a.asset_category, a.status,
|
||||
a.depreciation_method, a.purchase_date, a.gross_purchase_amount,
|
||||
ds.depreciation_method, a.purchase_date, a.gross_purchase_amount,
|
||||
ds.schedule_date as depreciation_date, ds.depreciation_amount,
|
||||
ds.accumulated_depreciation_amount,
|
||||
(a.gross_purchase_amount - ds.accumulated_depreciation_amount) as amount_after_depreciation,
|
||||
@ -42,6 +42,12 @@ def get_filter_conditions(filters):
|
||||
if filters.get("asset_category"):
|
||||
conditions += " and a.asset_category = %(asset_category)s"
|
||||
|
||||
if filters.get("finance_book"):
|
||||
conditions += " and ifnull(ds.finance_book, '') in (%(finance_book)s, '') "
|
||||
else:
|
||||
filters['finance_book'] = erpnext.get_default_finance_book(filters.get("company"))
|
||||
conditions += " and ifnull(ds.finance_book, '') in (%(finance_book)s, '') "
|
||||
|
||||
return conditions
|
||||
|
||||
def get_columns():
|
||||
|
@ -7,7 +7,7 @@ import re
|
||||
from past.builtins import cmp
|
||||
import functools
|
||||
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
from frappe import _
|
||||
@ -379,7 +379,8 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
|
||||
additional_conditions.append("finance_book in ('%s', '')" %
|
||||
frappe.db.escape(filters.get("finance_book")))
|
||||
else:
|
||||
additional_conditions.append("ifnull(finance_book, '') = ''")
|
||||
additional_conditions.append("finance_book in ('%s', '')" %
|
||||
frappe.db.escape(erpnext.get_default_finance_book(filters.get("company"))))
|
||||
|
||||
|
||||
return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""
|
||||
|
@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
from erpnext import get_company_currency, get_default_company
|
||||
from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency
|
||||
from frappe.utils import getdate, cstr, flt, fmt_money
|
||||
@ -168,9 +168,10 @@ def get_conditions(filters):
|
||||
conditions.append("project=%(project)s")
|
||||
|
||||
if filters.get("finance_book"):
|
||||
conditions.append("finance_book in (%(finance_book)s, '')")
|
||||
conditions.append("ifnull(finance_book, '') in (%(finance_book)s, '')")
|
||||
else:
|
||||
conditions.append("ifnull(finance_book, '')=''")
|
||||
filters['finance_book'] = erpnext.get_default_finance_book(filters.get("company"))
|
||||
conditions.append("ifnull(finance_book, '') in (%(finance_book)s, '')")
|
||||
|
||||
from frappe.desk.reportview import build_match_conditions
|
||||
match_conditions = build_match_conditions("GL Entry")
|
||||
|
@ -140,6 +140,8 @@ class Asset(AccountsController):
|
||||
|
||||
if d.depreciation_method in ("Straight Line", "Manual"):
|
||||
days = date_diff(schedule_date, from_date)
|
||||
if n == 0: days += 1
|
||||
|
||||
depreciation_amount = days * rate_per_day
|
||||
from_date = schedule_date
|
||||
else:
|
||||
|
@ -172,6 +172,38 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "default_finance_book",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Default Finance Book",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Finance Book",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
@ -2529,7 +2561,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2018-05-14 06:02:22.105952",
|
||||
"modified": "2018-05-17 21:59:33.594245",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
|
Loading…
x
Reference in New Issue
Block a user