Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta 2012-12-25 18:23:37 +05:30
commit 4ce83836b3
11 changed files with 333 additions and 144 deletions

View File

@ -1,4 +1,8 @@
erpnext.updates = [ erpnext.updates = [
["25th December 2012", [
"Stock Balance Report: Inflow, outflow and balance of stock within a defined period",
"Stock Reports: Added Brand filter on some of the reports"
]],
["21st December 2012", [ ["21st December 2012", [
"Manufacturing: For Material Transfer against Production Order, \ "Manufacturing: For Material Transfer against Production Order, \
fetch quantity pending to be transferred for each item.", fetch quantity pending to be transferred for each item.",

View File

@ -2,28 +2,25 @@
{ {
"owner": "Administrator", "owner": "Administrator",
"docstatus": 0, "docstatus": 0,
"creation": "2012-03-27 14:36:19", "creation": "2012-07-03 13:30:03",
"modified_by": "Administrator", "modified_by": "Administrator",
"modified": "2012-03-27 14:36:19" "modified": "2012-12-25 13:20:51"
}, },
{ {
"section_style": "Simple",
"module": "Setup",
"server_code_error": " ",
"allow_trash": 1,
"doctype": "DocType",
"autoname": "field:brand", "autoname": "field:brand",
"document_type": "Master",
"name": "__common__", "name": "__common__",
"colour": "White:FFF", "doctype": "DocType",
"show_in_menu": 0, "module": "Setup",
"version": 5 "in_dialog": 1,
"document_type": "Master"
}, },
{ {
"read_only": 0,
"name": "__common__", "name": "__common__",
"parent": "Brand", "parent": "Brand",
"doctype": "DocField", "doctype": "DocField",
"parenttype": "DocType", "parenttype": "DocType",
"permlevel": 0,
"parentfield": "fields" "parentfield": "fields"
}, },
{ {
@ -32,77 +29,13 @@
"read": 1, "read": 1,
"doctype": "DocPerm", "doctype": "DocPerm",
"parenttype": "DocType", "parenttype": "DocType",
"permlevel": 0,
"parentfield": "permissions" "parentfield": "permissions"
}, },
{ {
"name": "Brand", "name": "Brand",
"doctype": "DocType" "doctype": "DocType"
}, },
{
"create": 1,
"doctype": "DocPerm",
"write": 1,
"role": "System Manager",
"cancel": 1,
"permlevel": 0
},
{
"create": 1,
"doctype": "DocPerm",
"write": 1,
"role": "Material Master Manager",
"cancel": 1,
"permlevel": 0
},
{
"amend": 0,
"create": 0,
"doctype": "DocPerm",
"submit": 0,
"write": 0,
"role": "Material Manager",
"cancel": 0,
"permlevel": 1
},
{
"amend": 0,
"create": 0,
"doctype": "DocPerm",
"submit": 0,
"write": 0,
"role": "Material Manager",
"cancel": 0,
"permlevel": 0
},
{
"amend": 0,
"create": 0,
"doctype": "DocPerm",
"submit": 0,
"write": 0,
"role": "Material User",
"cancel": 0,
"permlevel": 1
},
{
"amend": 0,
"create": 0,
"doctype": "DocPerm",
"submit": 0,
"write": 0,
"role": "Material User",
"cancel": 0,
"permlevel": 0
},
{
"oldfieldtype": "Small Text",
"doctype": "DocField",
"label": "Trash Reason",
"oldfieldname": "trash_reason",
"fieldname": "trash_reason",
"fieldtype": "Small Text",
"permlevel": 1
},
{ {
"oldfieldtype": "Data", "oldfieldtype": "Data",
"doctype": "DocField", "doctype": "DocField",
@ -110,8 +43,7 @@
"oldfieldname": "brand", "oldfieldname": "brand",
"fieldname": "brand", "fieldname": "brand",
"fieldtype": "Data", "fieldtype": "Data",
"reqd": 1, "reqd": 1
"permlevel": 0
}, },
{ {
"oldfieldtype": "Text", "oldfieldtype": "Text",
@ -120,7 +52,22 @@
"oldfieldname": "description", "oldfieldname": "description",
"width": "300px", "width": "300px",
"fieldname": "description", "fieldname": "description",
"fieldtype": "Text", "fieldtype": "Text"
"permlevel": 0 },
{
"create": 1,
"doctype": "DocPerm",
"write": 1,
"role": "Material Master Manager",
"cancel": 1
},
{
"amend": 0,
"create": 0,
"doctype": "DocPerm",
"submit": 0,
"write": 0,
"role": "Material User",
"cancel": 0
} }
] ]

View File

@ -66,6 +66,7 @@ data_map = {
"order_by": "name", "order_by": "name",
"links": { "links": {
"parent_item_group": ["Item Group", "name"], "parent_item_group": ["Item Group", "name"],
"brand": ["Brand", "name"]
} }
}, },
"Item Group": { "Item Group": {
@ -73,6 +74,11 @@ data_map = {
"conditions": ["docstatus < 2"], "conditions": ["docstatus < 2"],
"order_by": "lft" "order_by": "lft"
}, },
"Brand": {
"columns": ["name"],
"conditions": ["docstatus < 2"],
"order_by": "name"
},
"Warehouse": { "Warehouse": {
"columns": ["name"], "columns": ["name"],
"conditions": ["docstatus < 2"], "conditions": ["docstatus < 2"],
@ -89,6 +95,11 @@ data_map = {
}, },
"force_index": "posting_sort_index" "force_index": "posting_sort_index"
}, },
"Stock Entry": {
"columns": ["name", "purpose"],
"conditions": ["docstatus=1"],
"order_by": "posting_date, posting_time, name",
},
# Sales # Sales
"Customer": { "Customer": {

View File

@ -38,7 +38,7 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
page: wrapper, page: wrapper,
parent: $(wrapper).find('.layout-main'), parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe, appframe: wrapper.appframe,
doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Item Group"], doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Item Group", "Brand"],
}) })
}, },
setup_columns: function() { setup_columns: function() {
@ -48,6 +48,7 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
open_btn: true, open_btn: true,
doctype: '"Item"' doctype: '"Item"'
}}, }},
{id: "brand", name: "Brand", field: "brand", width: 100},
{id: "average_age", name: "Average Age", field: "average_age", {id: "average_age", name: "Average Age", field: "average_age",
formatter: this.currency_formatter}, formatter: this.currency_formatter},
{id: "earliest", name: "Earliest", field: "earliest", {id: "earliest", name: "Earliest", field: "earliest",
@ -59,6 +60,10 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
filters: [ filters: [
{fieldtype:"Select", label: "Warehouse", link:"Warehouse", {fieldtype:"Select", label: "Warehouse", link:"Warehouse",
default_value: "Select Warehouse..."}, default_value: "Select Warehouse..."},
{fieldtype:"Select", label: "Brand", link:"Brand",
default_value: "Select Brand...", filter: function(val, item, opts) {
return val == opts.default_value || item.brand == val;
}},
{fieldtype:"Select", label: "Plot By", {fieldtype:"Select", label: "Plot By",
options: ["Average Age", "Earliest", "Latest"]}, options: ["Average Age", "Earliest", "Latest"]},
{fieldtype:"Date", label: "To Date"}, {fieldtype:"Date", label: "To Date"},
@ -68,13 +73,7 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
setup_filters: function() { setup_filters: function() {
var me = this; var me = this;
this._super(); this._super();
this.trigger_refresh_on_change(["warehouse", "plot_by", "brand"]);
this.filter_inputs.warehouse.change(function() {
me.filter_inputs.refresh.click();
});
this.filter_inputs.plot_by.change(function() {
me.filter_inputs.refresh.click();
});
}, },
init_filter_values: function() { init_filter_values: function() {
this._super(); this._super();
@ -84,15 +83,22 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
var me = this; var me = this;
if(!this.data) { if(!this.data) {
me.data = wn.report_dump.data["Item"]; me._data = wn.report_dump.data["Item"];
me.item_by_name = me.make_name_map(me.data); me.item_by_name = me.make_name_map(me._data);
} }
this.data = [].concat(this._data);
$.each(this.data, function(i, d) { $.each(this.data, function(i, d) {
me.reset_item_values(d); me.reset_item_values(d);
}); });
this.prepare_balances(); this.prepare_balances();
// filter out brand
this.data = $.map(this.data, function(d) {
return me.apply_filter(d, "brand") ? d : null;
});
}, },
prepare_balances: function() { prepare_balances: function() {
var me = this; var me = this;
@ -123,7 +129,7 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
full_fifo_stack = full_fifo_stack.concat(wh.fifo_stack || []) full_fifo_stack = full_fifo_stack.concat(wh.fifo_stack || [])
}); });
} else { } else {
full_fifo_stack = me.get_item_warehouse(me.warehouse, item.name) || []; full_fifo_stack = me.get_item_warehouse(me.warehouse, item.name).fifo_stack || [];
} }
var age_qty = total_qty = 0.0; var age_qty = total_qty = 0.0;

View File

@ -14,7 +14,11 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.pages['stock-analytics'].onload = function(wrapper) { wn.require("app/js/stock_grid_report.js");
// done so that it doesn't throw error when inherited in stock-balance report
if(wn.pages["stock-analytics"]) {
wn.pages['stock-analytics'].onload = function(wrapper) {
wn.ui.make_app_page({ wn.ui.make_app_page({
parent: wrapper, parent: wrapper,
title: 'Stock Analytics', title: 'Stock Analytics',
@ -26,29 +30,39 @@ wn.pages['stock-analytics'].onload = function(wrapper) {
wrapper.appframe.add_home_breadcrumb() wrapper.appframe.add_home_breadcrumb()
wrapper.appframe.add_module_breadcrumb("Stock") wrapper.appframe.add_module_breadcrumb("Stock")
wrapper.appframe.add_breadcrumb("icon-bar-chart") wrapper.appframe.add_breadcrumb("icon-bar-chart")
}
} }
wn.require("app/js/stock_grid_report.js");
erpnext.StockAnalytics = erpnext.StockGridReport.extend({ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
init: function(wrapper) { init: function(wrapper, opts) {
this._super({ var args = {
title: "Stock Analytics", title: "Stock Analytics",
page: wrapper, page: wrapper,
parent: $(wrapper).find('.layout-main'), parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe, appframe: wrapper.appframe,
doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Fiscal Year"], doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand",
"Fiscal Year"],
tree_grid: { tree_grid: {
show: true, show: true,
parent_field: "parent_item_group", parent_field: "parent_item_group",
formatter: function(item) { formatter: function(item) {
return repl('<a href="#stock-ledger/item=%(enc_value)s">%(value)s</a>', { if(!item.is_group) {
return repl('<a href="#stock-ledger/item_code=%(enc_value)s">%(value)s</a>',
{
value: item.name, value: item.name,
enc_value: encodeURIComponent(item.name) enc_value: encodeURIComponent(item.name)
}); });
} else {
return item.name;
}
} }
}, },
}) }
if(opts) $.extend(args, opts);
this._super(args);
}, },
setup_columns: function() { setup_columns: function() {
var std_columns = [ var std_columns = [
@ -56,6 +70,7 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
formatter: this.check_formatter}, formatter: this.check_formatter},
{id: "name", name: "Item", field: "name", width: 300, {id: "name", name: "Item", field: "name", width: 300,
formatter: this.tree_formatter}, formatter: this.tree_formatter},
{id: "brand", name: "Brand", field: "brand", width: 200},
{id: "opening", name: "Opening", field: "opening", hidden: true, {id: "opening", name: "Opening", field: "opening", hidden: true,
formatter: this.currency_formatter} formatter: this.currency_formatter}
]; ];
@ -69,10 +84,12 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
filter: function(val, item, opts, me) { filter: function(val, item, opts, me) {
return me.apply_zero_filter(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) {
return val == opts.default_value || item.brand == val || item._show;
}},
{fieldtype:"Select", label: "Warehouse", link:"Warehouse", {fieldtype:"Select", label: "Warehouse", link:"Warehouse",
default_value: "Select Warehouse..."}, default_value: "Select Warehouse..."},
{fieldtype:"Select", label: "Fiscal Year", link:"Fiscal Year",
default_value: "Select Fiscal Year..."},
{fieldtype:"Date", label: "From Date"}, {fieldtype:"Date", label: "From Date"},
{fieldtype:"Label", label: "To"}, {fieldtype:"Label", label: "To"},
{fieldtype:"Date", label: "To Date"}, {fieldtype:"Date", label: "To Date"},
@ -85,27 +102,14 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
var me = this; var me = this;
this._super(); this._super();
this.filter_inputs.fiscal_year.change(function() { this.trigger_refresh_on_change(["value_or_qty", "brand", "warehouse", "range"]);
var fy = $(this).val();
$.each(wn.report_dump.data["Fiscal Year"], function(i, v) {
if (v.name==fy) {
me.filter_inputs.from_date.val(dateutil.str_to_user(v.year_start_date));
me.filter_inputs.to_date.val(dateutil.str_to_user(v.year_end_date));
}
});
me.set_route();
});
this.filter_inputs.value_or_qty.change(function() { this.show_zero_check();
me.filter_inputs.refresh.click();
});
this.show_zero_check()
this.setup_plot_check(); this.setup_plot_check();
}, },
init_filter_values: function() { init_filter_values: function() {
this._super(); this._super();
this.filter_inputs.range.val('Monthly'); this.filter_inputs.range && this.filter_inputs.range.val('Monthly');
}, },
prepare_data: function() { prepare_data: function() {
var me = this; var me = this;
@ -179,7 +183,7 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
$.each(this.data, function(i, item) { $.each(this.data, function(i, item) {
// update groups // update groups
if(!item.is_group) { if(!item.is_group && me.apply_filter(item, "brand")) {
var balance = item.opening; var balance = item.opening;
$.each(me.columns, function(i, col) { $.each(me.columns, function(i, col) {
if(col.formatter==me.currency_formatter && !col.hidden) { if(col.formatter==me.currency_formatter && !col.hidden) {

View File

View File

@ -0,0 +1,162 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// 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/>.
wn.require("../app/stock/page/stock_analytics/stock_analytics.js");
wn.pages['stock-balance'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'Stock Balance',
single_column: true
});
new erpnext.StockBalance(wrapper);
wrapper.appframe.add_home_breadcrumb()
wrapper.appframe.add_module_breadcrumb("Stock")
wrapper.appframe.add_breadcrumb("icon-bar-chart")
}
erpnext.StockBalance = erpnext.StockAnalytics.extend({
init: function(wrapper) {
this._super(wrapper, {
title: "Stock Balance",
doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand",
"Stock Entry"],
});
},
setup_columns: function() {
this.columns = [
{id: "name", name: "Item", field: "name", width: 300,
formatter: this.tree_formatter},
{id: "brand", name: "Brand", field: "brand", width: 100},
{id: "opening", name: "Opening", field: "opening",
formatter: this.currency_formatter},
{id: "inflow", name: "In", field: "inflow",
formatter: this.currency_formatter},
{id: "outflow", name: "Out", field: "outflow",
formatter: this.currency_formatter},
{id: "closing", name: "Closing", field: "closing",
formatter: this.currency_formatter},
];
},
filters: [
{fieldtype:"Select", label: "Value or Qty", options:["Value (Weighted Average)",
"Value (FIFO)", "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) {
return val == opts.default_value || item.brand == val || item._show;
}},
{fieldtype:"Select", label: "Warehouse", link:"Warehouse",
default_value: "Select Warehouse..."},
{fieldtype:"Date", label: "From Date"},
{fieldtype:"Label", label: "To"},
{fieldtype:"Date", label: "To Date"},
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"}
],
setup_plot_check: function() {
return;
},
prepare_data: function() {
this.stock_entry_map = this.make_name_map(wn.report_dump.data["Stock Entry"], "name");
this._super();
},
prepare_balances: function() {
var me = this;
var from_date = dateutil.str_to_obj(this.from_date);
var to_date = dateutil.str_to_obj(this.to_date);
var data = wn.report_dump.data["Stock Ledger Entry"];
this.item_warehouse = {};
for(var i=0, j=data.length; i<j; i++) {
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 is_fifo = this.value_or_qty== "Value (FIFO)";
var diff = me.get_value_diff(wh, sl, is_fifo);
} else {
var diff = sl.qty;
}
if(posting_datetime < from_date) {
item.opening += diff;
} else if(posting_datetime <= to_date) {
var ignore_inflow_outflow = this.is_default("warehouse")
&& item.voucher_type=="Stock Entry"
&& this.stock_entry_map[item.voucher_no].purpose=="Material Transfer";
if(!ignore_inflow_outflow) {
if(diff < 0) {
item.outflow += Math.abs(diff);
} else {
item.inflow += diff;
}
}
item.closing += diff;
} else {
break;
}
}
}
},
update_groups: function() {
var me = this;
$.each(this.data, function(i, item) {
// update groups
if(!item.is_group && me.apply_filter(item, "brand")) {
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] =
flt(parent_group[col.field])
+ flt(item[col.field]);
}
});
// show parent if filtered by brand
if(item.brand == me.brand)
parent_group._show = true;
parent = me.parent_map[parent];
}
}
});
},
get_plot_data: function() {
return;
}
});

View File

@ -0,0 +1,21 @@
[
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-12-25 13:02:32",
"modified_by": "Administrator",
"modified": "2012-12-25 13:02:32"
},
{
"name": "__common__",
"title": "Stock Balance",
"doctype": "Page",
"module": "Stock",
"standard": "Yes",
"page_name": "stock-balance"
},
{
"name": "stock-balance",
"doctype": "Page"
}
]

View File

@ -29,6 +29,11 @@
</h5> </h5>
<p class="help">Log of stock movements</p> <p class="help">Log of stock movements</p>
<br> <br>
<h5><a href="#stock-balance" data-role="Analytics, Material Manager">
Stock Balance</a>
</h5>
<p class="help">Inflow, outflow and balance of stock</p>
<br>
<h5><a href="#stock-analytics" data-role="Analytics, Material Manager"> <h5><a href="#stock-analytics" data-role="Analytics, Material Manager">
Stock Analytics</a> Stock Analytics</a>
</h5> </h5>

View File

@ -37,7 +37,7 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
page: wrapper, page: wrapper,
parent: $(wrapper).find('.layout-main'), parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe, appframe: wrapper.appframe,
doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry"] doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand"],
}) })
}, },
@ -54,6 +54,7 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
}}, }},
{id: "warehouse", name: "Warehouse", field: "warehouse", width: 100, {id: "warehouse", name: "Warehouse", field: "warehouse", width: 100,
link_formatter: {filter_input: "warehouse"}}, link_formatter: {filter_input: "warehouse"}},
{id: "brand", name: "Brand", field: "brand", width: 100},
{id: "qty", name: "Qty", field: "qty", width: 100, {id: "qty", name: "Qty", field: "qty", width: 100,
formatter: this.currency_formatter}, formatter: this.currency_formatter},
{id: "balance", name: "Balance Qty", field: "balance", width: 100, {id: "balance", name: "Balance Qty", field: "balance", width: 100,
@ -74,14 +75,18 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
}, },
filters: [ filters: [
{fieldtype:"Select", label: "Warehouse", link:"Warehouse", default_value: "Select Warehouse...", {fieldtype:"Select", label: "Warehouse", link:"Warehouse",
filter: function(val, item, opts) { default_value: "Select Warehouse...", filter: function(val, item, opts) {
return item.warehouse == val || val == opts.default_value; return item.warehouse == val || val == opts.default_value;
}}, }},
{fieldtype:"Select", label: "Item Code", link:"Item", default_value: "Select Item...", {fieldtype:"Select", label: "Item Code", link:"Item", default_value: "Select Item...",
filter: function(val, item, opts) { filter: function(val, item, opts) {
return item.item_code == val || val == opts.default_value; return item.item_code == val || val == opts.default_value;
}}, }},
{fieldtype:"Select", label: "Brand", link:"Brand",
default_value: "Select Brand...", filter: function(val, item, opts) {
return val == opts.default_value || item.brand == val || item._show;
}},
{fieldtype:"Data", label: "Voucher No", {fieldtype:"Data", label: "Voucher No",
filter: function(val, item, opts) { filter: function(val, item, opts) {
if(!val) return true; if(!val) return true;
@ -97,6 +102,28 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"}, {fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"} {fieldtype:"Button", label: "Reset Filters"}
], ],
setup_filters: function() {
var me = this;
this._super();
this.wrapper.bind("apply_filters_from_route", function() { me.toggle_enable_brand(); });
this.filter_inputs.item_code.change(function() { me.toggle_enable_brand(); });
this.trigger_refresh_on_change(["item_code", "warehouse", "brand"]);
},
toggle_enable_brand: function() {
if(this.filter_inputs.item_code.val() ==
this.filter_inputs.item_code.get(0).opts.default_value) {
this.filter_inputs.brand.removeAttr("disabled");
} else {
this.filter_inputs.brand
.val(this.filter_inputs.brand.get(0).opts.default_value)
.attr("disabled", "disabled");
}
},
init_filter_values: function() { init_filter_values: function() {
this._super(); this._super();
this.filter_inputs.warehouse.get(0).selectedIndex = 0; this.filter_inputs.warehouse.get(0).selectedIndex = 0;
@ -136,6 +163,7 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
var wh = me.get_item_warehouse(sl.warehouse, sl.item_code); var wh = me.get_item_warehouse(sl.warehouse, sl.item_code);
sl.description = item.description; sl.description = item.description;
sl.posting_datetime = sl.posting_date + " " + sl.posting_time; sl.posting_datetime = sl.posting_date + " " + sl.posting_time;
sl.brand = item.brand;
var posting_datetime = dateutil.str_to_obj(sl.posting_datetime); var posting_datetime = dateutil.str_to_obj(sl.posting_datetime);
var is_fifo = item.valuation_method ? item.valuation_method=="FIFO" var is_fifo = item.valuation_method ? item.valuation_method=="FIFO"
@ -145,7 +173,8 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
// opening, transactions, closing, total in, total out // opening, transactions, closing, total in, total out
var before_end = posting_datetime <= dateutil.str_to_obj(me.to_date + " 23:59:59"); var before_end = posting_datetime <= dateutil.str_to_obj(me.to_date + " 23:59:59");
if((!me.is_default("item_code") ? me.apply_filter(sl, "item_code") : true) if((!me.is_default("item_code") ? me.apply_filter(sl, "item_code") : true)
&& me.apply_filter(sl, "warehouse") && me.apply_filter(sl, "voucher_no")) { && me.apply_filter(sl, "warehouse") && me.apply_filter(sl, "voucher_no")
&& me.apply_filter(sl, "brand")) {
if(posting_datetime < dateutil.str_to_obj(me.from_date)) { if(posting_datetime < dateutil.str_to_obj(me.from_date)) {
opening.balance += sl.qty; opening.balance += sl.qty;
opening.balance_value += value_diff; opening.balance_value += value_diff;