Merge pull request #14969 from netchampfaris/financial-statement-reports

Financial Reports fixes
This commit is contained in:
Faris Ansari 2018-07-21 12:28:31 +05:30 committed by GitHub
commit 789ad180ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 23 deletions

View File

@ -11,6 +11,8 @@ def execute(filters=None):
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
filters.periodicity, company=filters.company)
currency = filters.presentation_currency or frappe.db.get_value("Company", filters.company, "default_currency")
asset = get_data(filters.company, "Asset", "Debit", period_list,
only_current_fiscal_year=False, filters=filters,
accumulated_values=filters.accumulated_values)
@ -24,7 +26,7 @@ def execute(filters=None):
accumulated_values=filters.accumulated_values)
provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
period_list, filters.company)
period_list, filters.company, currency)
message, opening_balance = check_opening_balance(asset, liability, equity)
@ -37,7 +39,7 @@ def execute(filters=None):
"account_name": "'" + _("Unclosed Fiscal Years Profit / Loss (Credit)") + "'",
"account": "'" + _("Unclosed Fiscal Years Profit / Loss (Credit)") + "'",
"warn_if_negative": True,
"currency": frappe.db.get_value("Company", filters.company, "default_currency")
"currency": currency
}
for period in period_list:
unclosed[period.key] = opening_balance
@ -58,12 +60,12 @@ def execute(filters=None):
return columns, data, message, chart
def get_provisional_profit_loss(asset, liability, equity, period_list, company, consolidated=False):
def get_provisional_profit_loss(asset, liability, equity, period_list, company, currency=None, consolidated=False):
provisional_profit_loss = {}
total_row = {}
if asset and (liability or equity):
total = total_row_total=0
currency = frappe.db.get_value("Company", company, "default_currency")
currency = currency or frappe.db.get_value("Company", company, "default_currency")
total_row = {
"account_name": "'" + _("Total (Credit)") + "'",
"account": "'" + _("Total (Credit)") + "'",

View File

@ -80,6 +80,7 @@ frappe.query_reports["General Ledger"] = {
"label": __("Party"),
"fieldtype": "MultiSelect",
get_data: function() {
if (!frappe.query_report.filters) return;
var party_type = frappe.query_report.get_filter_value('party_type');
var parties = frappe.query_report.get_filter_value('party');
if(!party_type) return;

View File

@ -59,20 +59,21 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"fieldtype": "Check"
}
],
"formatter": function(row, cell, value, columnDef, dataContext, default_formatter) {
if (columnDef.df.fieldname=="account") {
value = dataContext.account_name;
"formatter": function(value, row, column, data, default_formatter) {
if (column.fieldname=="account") {
value = data.account_name;
columnDef.df.link_onclick =
"frappe.query_reports['Profitability Analysis'].open_profit_and_loss_statement(" + JSON.stringify(dataContext) + ")";
columnDef.df.is_tree = true;
column.link_onclick =
"frappe.query_reports['Profitability Analysis'].open_profit_and_loss_statement(" + JSON.stringify(data) + ")";
column.is_tree = true;
}
value = default_formatter(row, cell, value, columnDef, dataContext);
value = default_formatter(value, row, column, data);
if (!dataContext.parent_account && dataContext.based_on != 'project') {
if (!data.parent_account && data.based_on != 'project') {
value = $(`<span>${value}</span>`);
var $value = $(value).css("font-weight", "bold");
if (dataContext.warn_if_negative && dataContext[columnDef.df.fieldname] < 0) {
if (data.warn_if_negative && data[column.fieldname] < 0) {
$value.addClass("text-danger");
}

View File

@ -2,20 +2,22 @@ frappe.provide("erpnext.financial_statements");
erpnext.financial_statements = {
"filters": get_filters(),
"formatter": function(row, cell, value, columnDef, dataContext, default_formatter) {
if (columnDef.df.fieldname=="account") {
value = dataContext.account_name;
"formatter": function(value, row, column, data, default_formatter) {
if (column.fieldname=="account") {
value = data.account_name;
columnDef.df.link_onclick =
"erpnext.financial_statements.open_general_ledger(" + JSON.stringify(dataContext) + ")";
columnDef.df.is_tree = true;
column.link_onclick =
"erpnext.financial_statements.open_general_ledger(" + JSON.stringify(data) + ")";
column.is_tree = true;
}
value = default_formatter(row, cell, value, columnDef, dataContext);
value = default_formatter(value, row, column, data);
if (!data.parent_account) {
value = $(`<span>${value}</span>`);
if (!dataContext.parent_account) {
var $value = $(value).css("font-weight", "bold");
if (dataContext.warn_if_negative && dataContext[columnDef.df.fieldname] < 0) {
if (data.warn_if_negative && data[column.fieldname] < 0) {
$value.addClass("text-danger");
}

View File

@ -271,7 +271,7 @@ def set_salary_components(docs):
def set_tax_withholding_category(docs, company):
accounts = []
tds_account = frappe.db.get_value("Account", filter={"account_type": "Payable",
tds_account = frappe.db.get_value("Account", filters={"account_type": "Payable",
"account_name": "TDS", "company": company})
if company and tds_account: