mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 21:49:18 +00:00
moved directory structure
This commit is contained in:
1
stock/page/__init__.py
Normal file
1
stock/page/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
0
stock/page/stock_ageing/__init__.py
Normal file
0
stock/page/stock_ageing/__init__.py
Normal file
168
stock/page/stock_ageing/stock_ageing.js
Normal file
168
stock/page/stock_ageing/stock_ageing.js
Normal file
@@ -0,0 +1,168 @@
|
||||
// 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.pages['stock-ageing'].onload = function(wrapper) {
|
||||
wn.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: 'Stock Ageing',
|
||||
single_column: true
|
||||
});
|
||||
|
||||
new erpnext.StockAgeing(wrapper);
|
||||
|
||||
}
|
||||
|
||||
wn.require("app/js/stock_grid_report.js");
|
||||
|
||||
erpnext.StockAgeing = erpnext.StockGridReport.extend({
|
||||
init: function(wrapper) {
|
||||
this._super({
|
||||
title: "Stock Ageing",
|
||||
page: wrapper,
|
||||
parent: $(wrapper).find('.layout-main'),
|
||||
appframe: wrapper.appframe,
|
||||
doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Item Group"],
|
||||
})
|
||||
},
|
||||
setup_columns: function() {
|
||||
this.columns = [
|
||||
{id: "name", name: "Item", field: "name", width: 300,
|
||||
formatter: this.link_formatter},
|
||||
{id: "average_age", name: "Average Age", field: "average_age",
|
||||
formatter: this.currency_formatter},
|
||||
{id: "earliest", name: "Earliest", field: "earliest",
|
||||
formatter: this.currency_formatter},
|
||||
{id: "latest", name: "Latest", field: "latest",
|
||||
formatter: this.currency_formatter}
|
||||
];
|
||||
},
|
||||
filters: [
|
||||
{fieldtype:"Select", label: "Warehouse", link:"Warehouse",
|
||||
default_value: "Select Warehouse..."},
|
||||
{fieldtype:"Select", label: "Plot By",
|
||||
options: ["Average Age", "Earliest", "Latest"]},
|
||||
{fieldtype:"Date", label: "To Date"},
|
||||
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
|
||||
{fieldtype:"Button", label: "Reset Filters"}
|
||||
],
|
||||
setup_filters: function() {
|
||||
var me = this;
|
||||
this._super();
|
||||
|
||||
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() {
|
||||
this._super();
|
||||
this.filter_inputs.to_date.val(dateutil.obj_to_user(new Date()));
|
||||
},
|
||||
prepare_data: function() {
|
||||
var me = this;
|
||||
|
||||
if(!this.data) {
|
||||
me.data = wn.report_dump.data["Item"];
|
||||
me.item_by_name = me.make_name_map(me.data);
|
||||
}
|
||||
|
||||
$.each(this.data, function(i, d) {
|
||||
me.reset_item_values(d);
|
||||
});
|
||||
|
||||
this.prepare_balances();
|
||||
},
|
||||
prepare_balances: function() {
|
||||
var me = this;
|
||||
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];
|
||||
var posting_date = dateutil.str_to_obj(sl.posting_date);
|
||||
|
||||
if(me.is_default("warehouse") ? true : me.warehouse == sl.warehouse) {
|
||||
var wh = me.get_item_warehouse(sl.warehouse, sl.item_code);
|
||||
|
||||
// call diff to build fifo stack in item_warehouse
|
||||
var diff = me.get_value_diff(wh, sl, true);
|
||||
|
||||
if(posting_date > to_date)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$.each(me.data, function(i, item) {
|
||||
var full_fifo_stack = [];
|
||||
if(me.is_default("warehouse")) {
|
||||
$.each(me.item_warehouse[item.name] || {}, function(i, wh) {
|
||||
full_fifo_stack = full_fifo_stack.concat(wh.fifo_stack || [])
|
||||
});
|
||||
} else {
|
||||
full_fifo_stack = me.get_item_warehouse(me.warehouse, item.name) || [];
|
||||
}
|
||||
|
||||
var age_qty = total_qty = 0.0;
|
||||
var min_age = max_age = null;
|
||||
|
||||
$.each(full_fifo_stack, function(i, batch) {
|
||||
var batch_age = dateutil.get_diff(me.to_date, batch[2]);
|
||||
age_qty += batch_age * batch[1];
|
||||
total_qty += batch[1];
|
||||
max_age = Math.max(max_age, batch_age);
|
||||
if(min_age===null) min_age=batch_age; else min_age = Math.min(min_age, batch_age)
|
||||
});
|
||||
|
||||
item.average_age = total_qty.toFixed(2)==0.0 ? 0 : (age_qty / total_qty).toFixed(2);
|
||||
item.earliest = max_age || 0.0;
|
||||
item.latest = min_age || 0.0;
|
||||
});
|
||||
|
||||
this.data = this.data.sort(function(a, b) {
|
||||
var sort_by = me.plot_by.replace(" ", "_").toLowerCase();
|
||||
return b[sort_by] - a[sort_by];
|
||||
});
|
||||
},
|
||||
get_plot_data: function() {
|
||||
var data = [];
|
||||
var me = this;
|
||||
|
||||
data.push({
|
||||
label: me.plot_by,
|
||||
data: $.map(me.data, function(item, idx) {
|
||||
return [[idx+1, item[me.plot_by.replace(" ", "_").toLowerCase() ]]]
|
||||
}),
|
||||
bars: {show: true},
|
||||
});
|
||||
|
||||
return data.length ? data : false;
|
||||
},
|
||||
get_plot_options: function() {
|
||||
var me = this;
|
||||
return {
|
||||
grid: { hoverable: true, clickable: true },
|
||||
xaxis: {
|
||||
ticks: $.map(me.data, function(item, idx) { return [[idx+1, item.name]] }),
|
||||
max: 20
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
28
stock/page/stock_ageing/stock_ageing.txt
Normal file
28
stock/page/stock_ageing/stock_ageing.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
# Page, stock-ageing
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
u'creation': '2012-09-21 18:21:31',
|
||||
u'docstatus': 0,
|
||||
u'modified': '2012-09-21 18:21:31',
|
||||
u'modified_by': u'Administrator',
|
||||
u'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
u'doctype': u'Page',
|
||||
'module': u'Stock',
|
||||
u'name': u'__common__',
|
||||
'page_name': u'stock-ageing',
|
||||
'standard': u'Yes',
|
||||
'title': u'Stock Ageing'
|
||||
},
|
||||
|
||||
# Page, stock-ageing
|
||||
{
|
||||
u'doctype': u'Page',
|
||||
u'name': u'stock-ageing'
|
||||
}
|
||||
]
|
||||
0
stock/page/stock_analytics/__init__.py
Normal file
0
stock/page/stock_analytics/__init__.py
Normal file
205
stock/page/stock_analytics/stock_analytics.js
Normal file
205
stock/page/stock_analytics/stock_analytics.js
Normal file
@@ -0,0 +1,205 @@
|
||||
// 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.pages['stock-analytics'].onload = function(wrapper) {
|
||||
wn.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: 'Stock Analytics',
|
||||
single_column: true
|
||||
});
|
||||
|
||||
new erpnext.StockAnalytics(wrapper);
|
||||
}
|
||||
|
||||
wn.require("app/js/stock_grid_report.js");
|
||||
|
||||
erpnext.StockAnalytics = erpnext.StockGridReport.extend({
|
||||
init: function(wrapper) {
|
||||
this._super({
|
||||
title: "Stock Analytics",
|
||||
page: wrapper,
|
||||
parent: $(wrapper).find('.layout-main'),
|
||||
appframe: wrapper.appframe,
|
||||
doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Fiscal Year"],
|
||||
tree_grid: {
|
||||
show: true,
|
||||
parent_field: "parent_item_group",
|
||||
formatter: function(item) {
|
||||
return repl('<a href="#stock-ledger/item=%(enc_value)s">%(value)s</a>', {
|
||||
value: item.name,
|
||||
enc_value: encodeURIComponent(item.name)
|
||||
});
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
setup_columns: function() {
|
||||
var std_columns = [
|
||||
{id: "check", name: "Plot", field: "check", width: 30,
|
||||
formatter: this.check_formatter},
|
||||
{id: "name", name: "Item", field: "name", width: 300,
|
||||
formatter: this.tree_formatter},
|
||||
{id: "opening", name: "Opening", field: "opening", hidden: true,
|
||||
formatter: this.currency_formatter}
|
||||
];
|
||||
|
||||
this.make_date_range_columns();
|
||||
this.columns = std_columns.concat(this.columns);
|
||||
},
|
||||
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: "Warehouse", link:"Warehouse",
|
||||
default_value: "Select Warehouse..."},
|
||||
{fieldtype:"Select", label: "Fiscal Year", link:"Fiscal Year",
|
||||
default_value: "Select Fiscal Year..."},
|
||||
{fieldtype:"Date", label: "From Date"},
|
||||
{fieldtype:"Label", label: "To"},
|
||||
{fieldtype:"Date", label: "To Date"},
|
||||
{fieldtype:"Select", label: "Range",
|
||||
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
|
||||
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
|
||||
{fieldtype:"Button", label: "Reset Filters"}
|
||||
],
|
||||
setup_filters: function() {
|
||||
var me = this;
|
||||
this._super();
|
||||
|
||||
this.filter_inputs.fiscal_year.change(function() {
|
||||
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() {
|
||||
me.filter_inputs.refresh.click();
|
||||
});
|
||||
|
||||
this.show_zero_check()
|
||||
this.setup_plot_check();
|
||||
},
|
||||
init_filter_values: function() {
|
||||
this._super();
|
||||
this.filter_inputs.range.val('Weekly');
|
||||
},
|
||||
prepare_data: function() {
|
||||
var me = this;
|
||||
|
||||
if(!this.data) {
|
||||
var items = this.prepare_tree("Item", "Item Group");
|
||||
|
||||
me.parent_map = {};
|
||||
me.item_by_name = {};
|
||||
me.data = [];
|
||||
|
||||
$.each(items, function(i, v) {
|
||||
var d = copy_dict(v);
|
||||
|
||||
me.data.push(d);
|
||||
me.item_by_name[d.name] = d;
|
||||
if(d.parent_item_group) {
|
||||
me.parent_map[d.name] = d.parent_item_group;
|
||||
}
|
||||
me.reset_item_values(d);
|
||||
});
|
||||
this.set_indent();
|
||||
this.data[0].checked = true;
|
||||
} else {
|
||||
// otherwise, only reset values
|
||||
$.each(this.data, function(i, d) {
|
||||
me.reset_item_values(d);
|
||||
});
|
||||
}
|
||||
|
||||
this.prepare_balances();
|
||||
this.update_groups();
|
||||
|
||||
},
|
||||
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) {
|
||||
item[me.column_map[sl.posting_date].field] += diff;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
update_groups: function() {
|
||||
var me = this;
|
||||
|
||||
$.each(this.data, function(i, item) {
|
||||
// update groups
|
||||
if(!item.is_group) {
|
||||
var balance = item.opening;
|
||||
$.each(me.columns, function(i, col) {
|
||||
if(col.formatter==me.currency_formatter && !col.hidden) {
|
||||
item[col.field] = balance + item[col.field];
|
||||
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] =
|
||||
flt(parent_group[col.field])
|
||||
+ flt(item[col.field]);
|
||||
}
|
||||
});
|
||||
parent = me.parent_map[parent];
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
get_plot_points: function(item, col, idx) {
|
||||
return [[dateutil.user_to_obj(col.name).getTime(), item[col.field]]]
|
||||
}
|
||||
});
|
||||
28
stock/page/stock_analytics/stock_analytics.txt
Normal file
28
stock/page/stock_analytics/stock_analytics.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
# Page, stock-analytics
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
u'creation': '2012-09-20 12:13:45',
|
||||
u'docstatus': 0,
|
||||
u'modified': '2012-09-20 12:13:45',
|
||||
u'modified_by': u'Administrator',
|
||||
u'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
u'doctype': u'Page',
|
||||
'module': u'Stock',
|
||||
u'name': u'__common__',
|
||||
'page_name': u'stock-analytics',
|
||||
'standard': u'Yes',
|
||||
'title': u'Stock Analytics'
|
||||
},
|
||||
|
||||
# Page, stock-analytics
|
||||
{
|
||||
u'doctype': u'Page',
|
||||
u'name': u'stock-analytics'
|
||||
}
|
||||
]
|
||||
1
stock/page/stock_home/__init__.py
Normal file
1
stock/page/stock_home/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
127
stock/page/stock_home/stock_home.html
Normal file
127
stock/page/stock_home/stock_home.html
Normal file
@@ -0,0 +1,127 @@
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="appframe-area"></div>
|
||||
<div class="layout-main-section">
|
||||
<div style="width: 48%; float: left;">
|
||||
<h4><a href="#!List/Stock Entry">Stock Entry</a></h4>
|
||||
<p class="help">Transfer stock from one warehouse to another</p>
|
||||
<br>
|
||||
<h4><a href="#!List/Delivery Note">Delivery Note</a></h4>
|
||||
<p class="help">Delivery (shipment) to customers</p>
|
||||
<br>
|
||||
<h4><a href="#!List/Purchase Receipt">Purchase Receipt</a></h4>
|
||||
<p class="help">Goods received from Suppliers</p>
|
||||
</div>
|
||||
<div style="width: 48%; float: right;">
|
||||
<h4><a href="#!List/Item">Item</a></h4>
|
||||
<p class="help">Item Master</p>
|
||||
<br>
|
||||
<h4><a href="#!List/Serial No">Serial No</a></h4>
|
||||
<p class="help">Single unit of an Item</p>
|
||||
<br>
|
||||
<h4><a href="#!List/Batch">Batch</a></h4>
|
||||
<p class="help">Batch of units of an Item</p>
|
||||
<br>
|
||||
<h4><a href="#!List/Warehouse">Warehouse</a></h4>
|
||||
<p class="help">Warehouse is where items are stored</p>
|
||||
<br>
|
||||
<h4><a href="#stock-ledger" data-role="Analytics">Stock Ledger</a>
|
||||
<span style="background-color: #fed; font-weight: normal; font-size: 80%">beta</span>
|
||||
</h4>
|
||||
<p class="help">Log of stock movements</p>
|
||||
<br>
|
||||
<h4><a href="#stock-analytics" data-role="Analytics">Stock Analytics</a>
|
||||
<span style="background-color: #fed; font-weight: normal; font-size: 80%">beta</span>
|
||||
</h4>
|
||||
<p class="help">Visual representation of stock trends</p>
|
||||
<br>
|
||||
<h4><a href="#stock-ageing" data-role="Analytics">Stock Ageing</a>
|
||||
<span style="background-color: #fed; font-weight: normal; font-size: 80%">beta</span>
|
||||
</h4>
|
||||
<p class="help">Analysis of slow moving stock</p>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
<hr>
|
||||
<h3>Reports</h3>
|
||||
<div class="reports-list"></div>
|
||||
</div>
|
||||
<div class="layout-side-section">
|
||||
<div class="psidebar">
|
||||
<div class="section">
|
||||
<div class="section-head">Tools</div>
|
||||
<div class="section-body">
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Update stock by uploading a spreadsheet (csv) file"
|
||||
href="#!List/Stock Reconciliation">Stock Reconciliation</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Details of item installations"
|
||||
href="#!List/Installation Note">Installation Note</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Details packages against a delivery"
|
||||
href="#!List/Packing Slip">Packing Slip</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Multiple prices lists for items"
|
||||
href="#!List/Price List">Price List</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Readings of incoming quality inspections"
|
||||
href="#!List/Quality Inspection">Quality Inspection</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "List of expense heads (Account) that will be distributed across incoming purchases (costs that you find out some time after you receive goods, like Custom Duty, but are a part of item valuation)"
|
||||
href="#!List/Landed Cost Master">Landed Cost Master</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Distribute costs on Purchase Receipts and add them to item value"
|
||||
href="#!Form/Landed Cost Wizard/Landed Cost Wizard">Landed Cost Wizard</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Change Unit of Measure (UOM) of an item"
|
||||
href="#!Form/Stock UOM Replace Utility/Stock UOM Replace Utility">UOM Replace Utility</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Helper for managing return of goods (sales or purchase)"
|
||||
href="#!Form/Sales and Purchase Return Tool/Sales and Purchase Return Tool">Sales or Purchase Returns</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="section-head">Setup</div>
|
||||
<div class="section-body">
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Tree of item classification"
|
||||
href="#!Sales Browser/Item Group">Item Group</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Unit of Measure (UOM) master"
|
||||
href="#!List/UOM">Unit of Measure (UOM)</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "List of Item Brands (optional)"
|
||||
href="#!List/Brand">Brand</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Types of warehouses"
|
||||
href="#!List/Warehouse Type">Warehouse Type</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
20
stock/page/stock_home/stock_home.js
Normal file
20
stock/page/stock_home/stock_home.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// 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/>.
|
||||
|
||||
pscript['onload_stock-home'] = function(wrapper) {
|
||||
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'), 'Stock');
|
||||
erpnext.module_page.setup_page('Stock', wrapper);
|
||||
}
|
||||
28
stock/page/stock_home/stock_home.txt
Normal file
28
stock/page/stock_home/stock_home.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
# Page, stock-home
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-02-21 13:23:22',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-02-21 13:23:22',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': u'Stock',
|
||||
'name': '__common__',
|
||||
'page_name': u'stock-home',
|
||||
'standard': u'Yes',
|
||||
'title': u'Stock Home'
|
||||
},
|
||||
|
||||
# Page, stock-home
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': u'stock-home'
|
||||
}
|
||||
]
|
||||
1
stock/page/stock_ledger/__init__.py
Normal file
1
stock/page/stock_ledger/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
225
stock/page/stock_ledger/stock_ledger.js
Normal file
225
stock/page/stock_ledger/stock_ledger.js
Normal file
@@ -0,0 +1,225 @@
|
||||
// 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.pages['stock-ledger'].onload = function(wrapper) {
|
||||
wn.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: 'Stock Ledger',
|
||||
single_column: true
|
||||
});
|
||||
|
||||
new erpnext.StockLedger(wrapper);
|
||||
}
|
||||
|
||||
wn.require("app/js/stock_grid_report.js");
|
||||
|
||||
erpnext.StockLedger = erpnext.StockGridReport.extend({
|
||||
init: function(wrapper) {
|
||||
this._super({
|
||||
title: "Stock Ledger",
|
||||
page: wrapper,
|
||||
parent: $(wrapper).find('.layout-main'),
|
||||
appframe: wrapper.appframe,
|
||||
doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry"]
|
||||
})
|
||||
},
|
||||
|
||||
setup_columns: function() {
|
||||
this.hide_balance = (this.is_default("item_code") || this.voucher_no) ? true : false;
|
||||
this.columns = [
|
||||
{id: "posting_datetime", name: "Posting Date", field: "posting_datetime", width: 120,
|
||||
formatter: this.date_formatter},
|
||||
{id: "item_code", name: "Item Code", field: "item_code", width: 160,
|
||||
link_formatter: {
|
||||
filter_input: "item_code",
|
||||
open_btn: true,
|
||||
}},
|
||||
{id: "warehouse", name: "Warehouse", field: "warehouse", width: 100,
|
||||
link_formatter: {filter_input: "warehouse"}},
|
||||
{id: "qty", name: "Qty", field: "qty", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
{id: "balance", name: "Balance Qty", field: "balance", width: 100,
|
||||
formatter: this.currency_formatter,
|
||||
hidden: this.hide_balance},
|
||||
{id: "balance_value", name: "Balance Value", field: "balance_value", width: 100,
|
||||
formatter: this.currency_formatter, hidden: this.hide_balance},
|
||||
{id: "voucher_type", name: "Voucher Type", field: "voucher_type", width: 120},
|
||||
{id: "voucher_no", name: "Voucher No", field: "voucher_no", width: 160,
|
||||
link_formatter: {
|
||||
filter_input: "voucher_no",
|
||||
open_btn: true,
|
||||
doctype: "dataContext.voucher_type"
|
||||
}},
|
||||
{id: "description", name: "Description", field: "description", width: 200,
|
||||
formatter: this.text_formatter},
|
||||
];
|
||||
|
||||
},
|
||||
filters: [
|
||||
{fieldtype:"Select", label: "Warehouse", link:"Warehouse", default_value: "Select Warehouse...",
|
||||
filter: function(val, item, opts) {
|
||||
return item.warehouse == val || val == opts.default_value;
|
||||
}},
|
||||
{fieldtype:"Select", label: "Item Code", link:"Item", default_value: "Select Item...",
|
||||
filter: function(val, item, opts) {
|
||||
return item.item_code == val || val == opts.default_value;
|
||||
}},
|
||||
{fieldtype:"Data", label: "Voucher No",
|
||||
filter: function(val, item, opts) {
|
||||
if(!val) return true;
|
||||
return (item.voucher_no && item.voucher_no.indexOf(val)!=-1);
|
||||
}},
|
||||
{fieldtype:"Date", label: "From Date", filter: function(val, item) {
|
||||
return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date);
|
||||
}},
|
||||
{fieldtype:"Label", label: "To"},
|
||||
{fieldtype:"Date", label: "To Date", filter: function(val, item) {
|
||||
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
|
||||
}},
|
||||
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
|
||||
{fieldtype:"Button", label: "Reset Filters"}
|
||||
],
|
||||
init_filter_values: function() {
|
||||
this._super();
|
||||
this.filter_inputs.warehouse.get(0).selectedIndex = 0;
|
||||
},
|
||||
prepare_data: function() {
|
||||
var me = this;
|
||||
if(!this.item_by_name)
|
||||
this.item_by_name = this.make_name_map(wn.report_dump.data["Item"]);
|
||||
var data = wn.report_dump.data["Stock Ledger Entry"];
|
||||
var out = [];
|
||||
|
||||
var opening = {
|
||||
item_code: "On " + dateutil.str_to_user(this.from_date), qty: 0.0, balance: 0.0,
|
||||
id:"_opening", _show: true, _style: "font-weight: bold", balance_value: 0.0
|
||||
}
|
||||
var total_in = {
|
||||
item_code: "Total In", qty: 0.0, balance: 0.0, balance_value: 0.0,
|
||||
id:"_total_in", _show: true, _style: "font-weight: bold"
|
||||
}
|
||||
var total_out = {
|
||||
item_code: "Total Out", qty: 0.0, balance: 0.0, balance_value: 0.0,
|
||||
id:"_total_out", _show: true, _style: "font-weight: bold"
|
||||
}
|
||||
|
||||
// clear balance
|
||||
$.each(wn.report_dump.data["Item"], function(i, item) {
|
||||
item.balance = item.balance_value = 0.0;
|
||||
});
|
||||
|
||||
// initialize warehouse-item map
|
||||
this.item_warehouse = {};
|
||||
|
||||
//
|
||||
for(var i=0, j=data.length; i<j; i++) {
|
||||
var sl = data[i];
|
||||
var item = me.item_by_name[sl.item_code]
|
||||
var wh = me.get_item_warehouse(sl.warehouse, sl.item_code);
|
||||
sl.description = item.description;
|
||||
sl.posting_datetime = sl.posting_date + " " + sl.posting_time;
|
||||
var posting_datetime = dateutil.str_to_obj(sl.posting_datetime);
|
||||
|
||||
var is_fifo = item.valuation_method ? item.valuation_method=="FIFO"
|
||||
: sys_defaults.valuation_method=="FIFO";
|
||||
var value_diff = me.get_value_diff(wh, sl, is_fifo);
|
||||
|
||||
// opening, transactions, closing, total in, total out
|
||||
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)
|
||||
&& me.apply_filter(sl, "warehouse") && me.apply_filter(sl, "voucher_no")) {
|
||||
if(posting_datetime < dateutil.str_to_obj(me.from_date)) {
|
||||
opening.balance += sl.qty;
|
||||
opening.balance_value += value_diff;
|
||||
} else if(before_end) {
|
||||
if(sl.qty > 0) {
|
||||
total_in.qty += sl.qty;
|
||||
total_in.balance_value += value_diff;
|
||||
} else {
|
||||
total_out.qty += (-1 * sl.qty);
|
||||
total_out.balance_value += value_diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!before_end) break;
|
||||
|
||||
// apply filters
|
||||
if(me.apply_filters(sl)) {
|
||||
out.push(sl);
|
||||
}
|
||||
|
||||
// update balance
|
||||
if((!me.is_default("warehouse") ? me.apply_filter(sl, "warehouse") : true)) {
|
||||
sl.balance = me.item_by_name[sl.item_code].balance + sl.qty;
|
||||
me.item_by_name[sl.item_code].balance = sl.balance;
|
||||
|
||||
sl.balance_value = me.item_by_name[sl.item_code].balance_value + value_diff;
|
||||
me.item_by_name[sl.item_code].balance_value = sl.balance_value;
|
||||
}
|
||||
}
|
||||
|
||||
if(me.item_code != me.item_code_default && !me.voucher_no) {
|
||||
var closing = {
|
||||
item_code: "On " + dateutil.str_to_user(this.to_date),
|
||||
balance: (out ? out[out.length-1].balance : 0), qty: 0,
|
||||
balance_value: (out ? out[out.length-1].balance_value : 0),
|
||||
id:"_closing", _show: true, _style: "font-weight: bold"
|
||||
};
|
||||
total_out.balance_value = -total_out.balance_value;
|
||||
var out = [opening].concat(out).concat([total_in, total_out, closing]);
|
||||
}
|
||||
|
||||
this.data = out;
|
||||
},
|
||||
get_plot_data: function() {
|
||||
var data = [];
|
||||
var me = this;
|
||||
if(me.hide_balance) return false;
|
||||
data.push({
|
||||
label: me.item_code,
|
||||
data: [[dateutil.str_to_obj(me.from_date).getTime(), me.data[0].balance]]
|
||||
.concat($.map(me.data, function(col, idx) {
|
||||
if (col.posting_datetime) {
|
||||
return [[dateutil.str_to_obj(col.posting_datetime).getTime(), col.balance - col.qty],
|
||||
[dateutil.str_to_obj(col.posting_datetime).getTime(), col.balance]]
|
||||
}
|
||||
return null;
|
||||
})).concat([
|
||||
// closing
|
||||
[dateutil.str_to_obj(me.to_date).getTime(), me.data[me.data.length - 1].balance]
|
||||
]),
|
||||
points: {show: true},
|
||||
lines: {show: true, fill: true},
|
||||
});
|
||||
return data;
|
||||
},
|
||||
get_plot_options: function() {
|
||||
return {
|
||||
grid: { hoverable: true, clickable: true },
|
||||
xaxis: { mode: "time",
|
||||
min: dateutil.str_to_obj(this.from_date).getTime(),
|
||||
max: dateutil.str_to_obj(this.to_date).getTime(),
|
||||
},
|
||||
}
|
||||
},
|
||||
get_tooltip_text: function(label, x, y) {
|
||||
var d = new Date(x);
|
||||
var date = dateutil.obj_to_user(d) + " " + d.getHours() + ":" + d.getMinutes();
|
||||
var value = fmt_money(y);
|
||||
return value.bold() + " on " + date;
|
||||
}
|
||||
});
|
||||
28
stock/page/stock_ledger/stock_ledger.txt
Normal file
28
stock/page/stock_ledger/stock_ledger.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
# Page, stock-ledger
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
u'creation': '2012-09-18 14:55:15',
|
||||
u'docstatus': 0,
|
||||
u'modified': '2012-09-18 14:55:15',
|
||||
u'modified_by': u'Administrator',
|
||||
u'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
u'doctype': u'Page',
|
||||
'module': u'Stock',
|
||||
u'name': u'__common__',
|
||||
'page_name': u'stock-ledger',
|
||||
'standard': u'Yes',
|
||||
'title': u'Stock Ledger'
|
||||
},
|
||||
|
||||
# Page, stock-ledger
|
||||
{
|
||||
u'doctype': u'Page',
|
||||
u'name': u'stock-ledger'
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user