Merge pull request #1737 from nabinhait/v4-hotfix

Grid report translations and closing balance in trial balance
This commit is contained in:
Anand Doshi 2014-06-03 14:40:26 +05:30
commit 9198444a3b
8 changed files with 118 additions and 104 deletions

View File

@ -17,8 +17,9 @@ frappe.pages['financial-analytics'].onload = function(wrapper) {
erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
filters: [
{
fieldtype:"Select", label: __("PL or BS"),
options:["Profit and Loss", "Balance Sheet"],
fieldtype:"Select", label: __("PL or BS"), fieldname: "pl_or_bs",
options:[{"label": __("Profit and Loss"), "value": "Profit and Loss"},
{"label": __("Balance Sheet"), "value": "Balance Sheet"}],
filter: function(val, item, opts, me) {
if(item._show) return true;
@ -31,19 +32,21 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
}
},
{
fieldtype:"Select", label: __("Company"),
link:"Company", default_value: "Select Company...",
fieldtype:"Select", label: __("Company"), fieldname: "company",
link:"Company", default_value: __("Select Company..."),
filter: function(val, item, opts) {
return item.company == val || val == opts.default_value || item._show;
}
},
{fieldtype:"Select", label: __("Fiscal Year"), link:"Fiscal Year",
default_value: "Select Fiscal Year..."},
{fieldtype:"Date", label: __("From Date")},
{fieldtype:"Select", label: __("Fiscal Year"), link:"Fiscal Year", fieldname: "fiscal_year",
default_value: __("Select Fiscal Year...")},
{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
{fieldtype:"Label", label: __("To")},
{fieldtype:"Date", label: __("To Date")},
{fieldtype:"Select", label: __("Range"),
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
{fieldtype:"Select", label: __("Range"), fieldname: "range",
options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"},
{label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"},
{label: __("Yearly"), value: "Yearly"}]},
{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"}
],

View File

@ -3,7 +3,7 @@
frappe.require("assets/erpnext/js/account_tree_grid.js");
frappe.pages['trial-balance'].onload = function(wrapper) {
frappe.pages['trial-balance'].onload = function(wrapper) {
frappe.ui.make_app_page({
parent: wrapper,
title: __('Trial Balance'),
@ -13,26 +13,26 @@ frappe.pages['trial-balance'].onload = function(wrapper) {
init: function(wrapper, title) {
var me = this;
this._super(wrapper, title);
// period closing entry checkbox
this.wrapper.bind("make", function() {
$('<div style="margin: 10px 0px; "\
class="with_period_closing_entry"><input type="checkbox" checked="checked">' +
class="with_period_closing_entry"><input type="checkbox" checked="checked">' +
__("With period closing entry") + '</div>')
.appendTo(me.wrapper)
.find("input").click(function() { me.refresh(); });
});
},
prepare_balances: function() {
// store value of with closing entry
this.with_period_closing_entry = this.wrapper
.find(".with_period_closing_entry input:checked").length;
this._super();
},
update_balances: function(account, posting_date, v) {
// for period closing voucher,
// for period closing voucher,
// only consider them when adding "With Closing Entry is checked"
if(v.voucher_type === "Period Closing Voucher") {
if(this.with_period_closing_entry) {
@ -44,8 +44,8 @@ frappe.pages['trial-balance'].onload = function(wrapper) {
},
})
erpnext.trial_balance = new TrialBalance(wrapper, 'Trial Balance');
wrapper.appframe.add_module_icon("Accounts")
}
}

View File

@ -86,21 +86,24 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
this.columns = std_columns.concat(this.columns);
},
filters: [
{fieldtype:"Select", label: __("Tree Type"), options:["Supplier Type", "Supplier",
"Item Group", "Item"],
{fieldtype:"Select", label: __("Tree Type"), fieldname: "tree_type",
options:["Supplier Type", "Supplier", "Item Group", "Item"],
filter: function(val, item, opts, me) {
return me.apply_zero_filter(val, item, opts, me);
}},
{fieldtype:"Select", label: __("Based On"), options:["Purchase Invoice",
"Purchase Order", "Purchase Receipt"]},
{fieldtype:"Select", label: __("Value or Qty"), options:["Value", "Quantity"]},
{fieldtype:"Select", label: __("Company"), link:"Company",
default_value: "Select Company..."},
{fieldtype:"Date", label: __("From Date")},
{fieldtype:"Select", label: __("Based On"), fieldname: "based_on",
options:["Purchase Invoice", "Purchase Order", "Purchase Receipt"]},
{fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty",
options:["Value", "Quantity"]},
{fieldtype:"Select", label: __("Company"), link:"Company", fieldname: "company",
default_value: __("Select Company...")},
{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
{fieldtype:"Label", label: __("To")},
{fieldtype:"Date", label: __("To Date")},
{fieldtype:"Select", label: __("Range"),
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
{fieldtype:"Select", label: __("Range"), fieldname: "range",
options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"},
{label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"},
{label: __("Yearly"), value: "Yearly"}]},
{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"}
],
@ -126,7 +129,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
// Set parent supplier type for tree view
$.each(frappe.report_dump.data["Supplier Type"], function(i, v) {
v['parent_supplier_type'] = "All Supplier Types"
v['parent_supplier_type'] = __("All Supplier Types")
})
frappe.report_dump.data["Supplier Type"] = [{
@ -136,7 +139,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
frappe.report_dump.data["Supplier"].push({
name: __("Not Set"),
parent_supplier_type: "All Supplier Types",
parent_supplier_type: __("All Supplier Types"),
id: "Not Set",
});
@ -219,7 +222,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
$.each(this.data, function(i, item) {
var parent = me.parent_map[item.name];
while(parent) {
parent_group = me.item_by_name[parent];
var parent_group = me.item_by_name[parent];
$.each(me.columns, function(c, col) {
if (col.formatter == me.currency_formatter) {

View File

@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
@ -23,8 +23,8 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
appframe: wrapper.appframe,
doctypes: ["Company", "Fiscal Year", "Account", "GL Entry", "Cost Center"],
tree_grid: {
show: true,
parent_field: "parent_account",
show: true,
parent_field: "parent_account",
formatter: function(item) {
return repl("<a \
onclick='frappe.cur_grid_report.show_general_ledger(\"%(value)s\")'>\
@ -37,7 +37,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
},
setup_columns: function() {
this.columns = [
{id: "name", name: __("Account"), field: "name", width: 300, cssClass: "cell-title",
{id: "name", name: __("Account"), field: "name", width: 300, cssClass: "cell-title",
formatter: this.tree_formatter},
{id: "opening_dr", name: __("Opening (Dr)"), field: "opening_dr", width: 100,
formatter: this.currency_formatter},
@ -55,18 +55,19 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
},
filters: [
{fieldtype: "Select", label: __("Company"), link:"Company", default_value: "Select Company...",
{fieldtype: "Select", label: __("Company"), link:"Company", fieldname: "company",
default_value: __("Select Company..."),
filter: function(val, item, opts, me) {
if (item.company == val || val == opts.default_value) {
return me.apply_zero_filter(val, item, opts, me);
}
return false;
}},
{fieldtype: "Select", label: __("Fiscal Year"), link:"Fiscal Year",
default_value: "Select Fiscal Year..."},
{fieldtype: "Date", label: __("From Date")},
{fieldtype: "Select", label: "Fiscal Year", link:"Fiscal Year", fieldname: "fiscal_year",
default_value: __("Select Fiscal Year...")},
{fieldtype: "Date", label: __("From Date"), fieldname: "from_date"},
{fieldtype: "Label", label: __("To")},
{fieldtype: "Date", label: __("To Date")},
{fieldtype: "Date", label: __("To Date"), fieldname: "to_date"},
{fieldtype: "Button", label: __("Refresh"), icon:"icon-refresh icon-white",
cssClass:"btn-info"},
{fieldtype: "Button", label: __("Reset Filters"), icon: "icon-filter"},
@ -83,7 +84,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
me.filter_inputs.to_date.val(dateutil.str_to_user(v.year_end_date));
}
});
me.set_route();
me.refresh();
});
me.show_zero_check()
if(me.ignore_closing_entry) me.ignore_closing_entry();
@ -105,21 +106,21 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
me.parent_map[d.name] = d.parent_account;
}
});
me.primary_data = [].concat(me.data);
}
me.data = [].concat(me.primary_data);
$.each(me.data, function(i, d) {
me.init_account(d);
});
this.set_indent();
this.prepare_balances();
},
init_account: function(d) {
this.reset_item_values(d);
this.reset_item_values(d);
},
prepare_balances: function() {
@ -132,7 +133,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
if (!this.fiscal_year) return;
$.each(this.data, function(i, v) {
v.opening_dr = v.opening_cr = v.debit
v.opening_dr = v.opening_cr = v.debit
= v.credit = v.closing_dr = v.closing_cr = 0;
});
@ -145,15 +146,16 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
this.update_groups();
},
update_balances: function(account, posting_date, v) {
var bal = flt(account.opening_dr) - flt(account.opening_cr) + flt(v.debit) - flt(v.credit);
// opening
if (posting_date < this.opening_date || v.is_opening === "Yes") {
if (account.report_type === "Profit and Loss" &&
if (account.report_type === "Profit and Loss" &&
posting_date <= dateutil.str_to_obj(this.fiscal_year[1])) {
// balance of previous fiscal_year should
// balance of previous fiscal_year should
// not be part of opening of pl account balance
} else {
this.set_debit_or_credit(account, "opening", bal);
var opening_bal = flt(account.opening_dr) - flt(account.opening_cr) +
flt(v.debit) - flt(v.credit);
this.set_debit_or_credit(account, "opening", opening_bal);
}
} else if (this.opening_date <= posting_date && posting_date <= this.closing_date) {
// in between
@ -161,7 +163,9 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
account.credit += flt(v.credit);
}
// closing
this.set_debit_or_credit(account, "closing", bal);
var closing_bal = flt(account.opening_dr) - flt(account.opening_cr) +
flt(account.debit) - flt(account.credit);
this.set_debit_or_credit(account, "closing", closing_bal);
},
set_debit_or_credit: function(account, field, balance) {
if(balance > 0) {
@ -184,25 +188,25 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
$.each(me.columns, function(c, col) {
if (col.formatter == me.currency_formatter) {
if(col.field=="opening_dr") {
var bal = flt(parent_account.opening_dr) -
flt(parent_account.opening_cr) +
var bal = flt(parent_account.opening_dr) -
flt(parent_account.opening_cr) +
flt(account.opening_dr) - flt(account.opening_cr);
me.set_debit_or_credit(parent_account, "opening", bal);
} else if(col.field=="closing_dr") {
var bal = flt(parent_account.closing_dr) -
flt(parent_account.closing_cr) +
var bal = flt(parent_account.closing_dr) -
flt(parent_account.closing_cr) +
flt(account.closing_dr) - flt(account.closing_cr);
me.set_debit_or_credit(parent_account, "closing", bal);
} else if(in_list(["debit", "credit"], col.field)) {
parent_account[col.field] = flt(parent_account[col.field]) +
parent_account[col.field] = flt(parent_account[col.field]) +
flt(account[col.field]);
}
}
});
parent = me.parent_map[parent];
}
}
}
});
});
},
set_fiscal_year: function() {
@ -214,7 +218,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
this.fiscal_year = null;
var me = this;
$.each(frappe.report_dump.data["Fiscal Year"], function(i, v) {
if (me.opening_date >= dateutil.str_to_obj(v.year_start_date) &&
if (me.opening_date >= dateutil.str_to_obj(v.year_start_date) &&
me.closing_date <= dateutil.str_to_obj(v.year_end_date)) {
me.fiscal_year = v;
}
@ -225,7 +229,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
return;
}
},
show_general_ledger: function(account) {
frappe.route_options = {
account: account,
@ -235,4 +239,4 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
};
frappe.set_route("query-report", "General Ledger");
}
});
});

View File

@ -10,11 +10,11 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
page: wrapper,
parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe,
doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand",
doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand",
"Fiscal Year", "Serial No"],
tree_grid: {
show: true,
parent_field: "parent_item_group",
show: true,
parent_field: "parent_item_group",
formatter: function(item) {
if(!item.is_group) {
return repl("<a \
@ -25,13 +25,13 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
} else {
return item.name;
}
}
},
}
if(opts) $.extend(args, opts);
this._super(args);
},
setup_columns: function() {
@ -50,20 +50,21 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
this.columns = std_columns.concat(this.columns);
},
filters: [
{fieldtype:"Select", label: __("Value or Qty"), options:["Value", "Quantity"],
{fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty",
options:["Value", "Quantity"],
filter: function(val, item, opts, me) {
return me.apply_zero_filter(val, item, opts, me);
}},
{fieldtype:"Select", label: __("Brand"), link:"Brand",
default_value: "Select Brand...", filter: function(val, item, opts) {
{fieldtype:"Select", label: __("Brand"), link:"Brand", fieldname: "brand",
default_value: __("Select Brand..."), filter: function(val, item, opts) {
return val == opts.default_value || item.brand == val || item._show;
}, link_formatter: {filter_input: "brand"}},
{fieldtype:"Select", label: __("Warehouse"), link:"Warehouse",
default_value: "Select Warehouse..."},
{fieldtype:"Date", label: __("From Date")},
{fieldtype:"Select", label: __("Warehouse"), link:"Warehouse", fieldname: "warehouse",
default_value: __("Select Warehouse...")},
{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
{fieldtype:"Label", label: __("To")},
{fieldtype:"Date", label: __("To Date")},
{fieldtype:"Select", label: __("Range"),
{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
{fieldtype:"Select", label: __("Range"), fieldname: "range",
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"}
@ -71,7 +72,7 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
setup_filters: function() {
var me = this;
this._super();
this.trigger_refresh_on_change(["value_or_qty", "brand", "warehouse", "range"]);
this.show_zero_check();
@ -83,7 +84,7 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
},
prepare_data: function() {
var me = this;
if(!this.data) {
var items = this.prepare_tree("Item", "Item Group");
@ -109,10 +110,10 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
me.reset_item_values(d);
});
}
this.prepare_balances();
this.update_groups();
},
prepare_balances: function() {
var me = this;
@ -127,16 +128,16 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
var sl = data[i];
sl.posting_datetime = sl.posting_date + " " + sl.posting_time;
var posting_datetime = dateutil.str_to_obj(sl.posting_datetime);
if(me.is_default("warehouse") ? true : me.warehouse == sl.warehouse) {
var item = me.item_by_name[sl.item_code];
if(me.value_or_qty!="Quantity") {
var wh = me.get_item_warehouse(sl.warehouse, sl.item_code);
var valuation_method = item.valuation_method ?
var valuation_method = item.valuation_method ?
item.valuation_method : sys_defaults.valuation_method;
var is_fifo = valuation_method == "FIFO";
var diff = me.get_value_diff(wh, sl, is_fifo);
} else {
var diff = sl.qty;
@ -165,13 +166,13 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
balance = item[col.field];
}
});
var parent = me.parent_map[item.name];
while(parent) {
parent_group = me.item_by_name[parent];
$.each(me.columns, function(c, col) {
if (col.formatter == me.currency_formatter) {
parent_group[col.field] =
parent_group[col.field] =
flt(parent_group[col.field])
+ flt(item[col.field]);
}
@ -192,4 +193,4 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
};
frappe.set_route("query-report", "Stock Ledger");
}
});
});

View File

@ -95,14 +95,17 @@ erpnext.SalesAnalytics = frappe.views.TreeGridReport.extend({
}},
{fieldtype:"Select", fieldname: "based_on", label: __("Based On"), options:["Sales Invoice",
"Sales Order", "Delivery Note"]},
{fieldtype:"Select", fieldname: "value_or_qty", label: __("Value or Qty"), options:["Value", "Quantity"]},
{fieldtype:"Select", fieldname: "value_or_qty", label: __("Value or Qty"),
options:[{label: __("Value"), value: "Value"}, {label: __("Quantity"), value: "Quantity"}]},
{fieldtype:"Select", fieldname: "company", label: __("Company"), link:"Company",
default_value: "Select Company..."},
default_value: __("Select Company...")},
{fieldtype:"Date", fieldname: "from_date", label: __("From Date")},
{fieldtype:"Label", fieldname: "to", label: __("To")},
{fieldtype:"Date", fieldname: "to_date", label: __("To Date")},
{fieldtype:"Select", fieldname: "range", label: __("Range"),
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Select", label: __("Range"), fieldname: "range",
options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"},
{label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"},
{label: __("Yearly"), value: "Yearly"}]},
{fieldtype:"Button", fieldname: "refresh", label: __("Refresh"), icon:"icon-refresh"},
{fieldtype:"Button", fieldname: "reset_filters", label: __("Reset Filters"), icon:"icon-filter"}
],

View File

@ -57,21 +57,21 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
},
filters: [
{fieldtype:"Select", label: __("Brand"), link:"Brand",
default_value: "Select Brand...", filter: function(val, item, opts) {
{fieldtype:"Select", label: __("Brand"), link:"Brand", fieldname: "brand",
default_value: __("Select Brand..."), filter: function(val, item, opts) {
return val == opts.default_value || item.brand == val || item._show;
}, link_formatter: {filter_input: "brand"}},
{fieldtype:"Select", label: __("Warehouse"), link:"Warehouse",
default_value: "Select Warehouse...", filter: function(val, item, opts, me) {
{fieldtype:"Select", label: __("Warehouse"), link:"Warehouse", fieldname: "warehouse",
default_value: __("Select Warehouse..."), filter: function(val, item, opts, me) {
return me.apply_zero_filter(val, item, opts, me);
}},
{fieldtype:"Select", label: __("Project"), link:"Project",
default_value: "Select Project...", filter: function(val, item, opts, me) {
{fieldtype:"Select", label: __("Project"), link:"Project", fieldname: "project",
default_value: __("Select Project..."), filter: function(val, item, opts, me) {
return me.apply_zero_filter(val, item, opts, me);
}, link_formatter: {filter_input: "project"}},
{fieldtype:"Date", label: __("From Date")},
{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
{fieldtype:"Label", label: __("To")},
{fieldtype:"Date", label: __("To Date")},
{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"}
],

View File

@ -237,7 +237,7 @@
],
"icon": "icon-ticket",
"idx": 1,
"modified": "2014-05-21 06:15:26.988620",
"modified": "2014-06-03 10:49:47.781578",
"modified_by": "Administrator",
"module": "Support",
"name": "Support Ticket",
@ -286,6 +286,6 @@
"write": 1
}
],
"search_fields": "status,customer,allocated_to,subject,raised_by",
"search_fields": "status,customer,subject,raised_by",
"title_field": "subject"
}