[enhancement] stock balance page
This commit is contained in:
parent
cd3c979207
commit
621283c5c5
@ -2,7 +2,7 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.provide("erpnext.accounts");
|
||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||
{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
|
||||
|
||||
|
||||
erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
cur_frm.cscript.tax_table = "Purchase Taxes and Charges";
|
||||
|
||||
{% include "public/js/controllers/accounts.js" %}
|
||||
{% include "erpnext/public/js/controllers/accounts.js" %}
|
||||
|
||||
frappe.ui.form.on("Purchase Taxes and Charges", "add_deduct_tax", function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
|
@ -4,7 +4,7 @@
|
||||
// print heading
|
||||
cur_frm.pformat.print_heading = 'Invoice';
|
||||
|
||||
{% include 'selling/sales_common.js' %};
|
||||
{% include 'erpnext/selling/sales_common.js' %};
|
||||
|
||||
frappe.provide("erpnext.accounts");
|
||||
erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({
|
||||
|
@ -3,5 +3,5 @@
|
||||
|
||||
cur_frm.cscript.tax_table = "Sales Taxes and Charges";
|
||||
|
||||
{% include "public/js/controllers/accounts.js" %}
|
||||
{% include "erpnext/public/js/controllers/accounts.js" %}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
frappe.provide("erpnext.buying");
|
||||
|
||||
cur_frm.cscript.tax_table = "Purchase Taxes and Charges";
|
||||
{% include 'accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js' %}
|
||||
{% include 'erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js' %}
|
||||
|
||||
frappe.require("assets/erpnext/js/controllers/transaction.js");
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
frappe.provide("erpnext.buying");
|
||||
|
||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||
{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
|
||||
|
||||
frappe.ui.form.on("Purchase Order", {
|
||||
onload: function(frm) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||
{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
|
||||
|
||||
frappe.require("assets/erpnext/js/utils.js");
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
// attach required files
|
||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||
{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
|
||||
|
||||
erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function() {
|
||||
|
@ -132,3 +132,22 @@ $(document).on('app_ready', function() {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
erpnext.get_item_dashboard_data = function(data, max_count) {
|
||||
if(!max_count) max_count = 0;
|
||||
data.forEach(function(d) {
|
||||
d.actual_or_pending = d.projected_qty + d.reserved_qty + d.reserved_qty_for_production;
|
||||
d.pending_qty = 0;
|
||||
d.total_reserved = d.reserved_qty + d.reserved_qty_for_production;
|
||||
if(d.actual_or_pending > d.actual_qty) {
|
||||
d.pending_qty = d.actual_or_pending - d.actual_qty;
|
||||
}
|
||||
|
||||
max_count = Math.max(d.actual_or_pending, d.actual_qty,
|
||||
d.total_reserved, max_count);
|
||||
});
|
||||
return {
|
||||
data: data,
|
||||
max_count: max_count
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
{% include 'selling/sales_common.js' %}
|
||||
{% include 'erpnext/selling/sales_common.js' %}
|
||||
|
||||
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
onload: function(doc, dt, dn) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
{% include 'selling/sales_common.js' %}
|
||||
{% include 'erpnext/selling/sales_common.js' %}
|
||||
|
||||
frappe.ui.form.on("Sales Order", {
|
||||
onload: function(frm) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
cur_frm.cscript.tax_table = "Sales Taxes and Charges";
|
||||
{% include 'accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js' %}
|
||||
{% include 'erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js' %}
|
||||
|
||||
frappe.provide("erpnext.selling");
|
||||
frappe.require("assets/erpnext/js/controllers/transaction.js");
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
{% include 'selling/sales_common.js' %};
|
||||
{% include 'erpnext/selling/sales_common.js' %};
|
||||
|
||||
frappe.provide("erpnext.stock");
|
||||
frappe.provide("erpnext.stock.delivery_note");
|
||||
|
@ -84,19 +84,10 @@ frappe.ui.form.on("Item", {
|
||||
|
||||
dashboard_update: function(frm) {
|
||||
if(frm.dashboard_data.stock_data && frm.dashboard_data.stock_data.length) {
|
||||
var max_count = 0;
|
||||
frm.dashboard_data.stock_data.forEach(function(d) {
|
||||
d.actual_or_pending = d.projected_qty - d.reserved_qty;
|
||||
d.pending_qty = 0;
|
||||
if(d.actual_or_pending > d.actual_qty) {
|
||||
d.pending_qty = d.actual_or_pending - d.actual_qty;
|
||||
}
|
||||
|
||||
max_count = Math.max(d.actual_or_pending, d.actual_qty,
|
||||
d.reserved_qty, max_count);
|
||||
})
|
||||
frm.dashboard.add_stats(frappe.render_template('item_dashboard',
|
||||
{data: frm.dashboard_data.stock_data, max_count: max_count}));
|
||||
var context = erpnext.get_item_dashboard_data(frm.dashboard_data.stock_data, 0);
|
||||
frm.dashboard.add_section('<h5 style="margin-top: 0px;">Stock Levels</h5>\
|
||||
<ul class="list-group">' + frappe.render_template('item_dashboard', context), true)
|
||||
+ '</ul>';
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -628,7 +628,8 @@ def get_timeline_data(name):
|
||||
group by posting_date''', name))
|
||||
|
||||
def get_stock_data(name):
|
||||
return frappe.get_all('Bin', fields=['warehouse', 'actual_qty', 'projected_qty', 'reserved_qty'],
|
||||
return frappe.get_all('Bin', fields=['warehouse', 'actual_qty', 'projected_qty',
|
||||
'reserved_qty', 'reserved_qty_for_production'],
|
||||
filters={'item_code': name}, order_by = 'warehouse asc')
|
||||
|
||||
def validate_end_of_life(item_code, end_of_life=None, disabled=None, verbose=1):
|
||||
|
@ -1,39 +1,42 @@
|
||||
<div>
|
||||
<h5 style="margin-top: 0px;">Stock Levels</h5>
|
||||
<ul class="list-group" style="margin: 0px;">
|
||||
{% for(var i=0; i < data.length; i++) { var d = data[i]; %}
|
||||
<li class="list-group-item" style="background-color: inherit;">
|
||||
<div class="row">
|
||||
<div class="col-sm-8 small" style="margin-top: 8px;">{{ d.warehouse }}</div>
|
||||
<div class="col-sm-4 small">
|
||||
<span class="inline-graph">
|
||||
<span class="inline-graph-half" title="{{ __("Reserved Qty") }}">
|
||||
<span class="inline-graph-count">{{ d.reserved_qty }}</span>
|
||||
<span class="inline-graph-bar">
|
||||
<span class="inline-graph-bar-inner"
|
||||
style="width: {{ cint(Math.abs(d.reserved_qty)/max_count * 100) || 5 }}%">
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="inline-graph-half" title="{{ __("Acutal Qty {0} / Waiting Qty {1}", [d.actual_qty, d.pending_qty]) }}">
|
||||
<span class="inline-graph-count">
|
||||
{{ d.actual_qty }} {{ (d.pending_qty > 0) ? ("(" + d.pending_qty+ ")") : "" }}
|
||||
</span>
|
||||
<span class="inline-graph-bar">
|
||||
<span class="inline-graph-bar-inner dark"
|
||||
style="width: {{ cint(d.actual_qty/max_count * 100) }}%">
|
||||
</span>
|
||||
{% if(d.pending_qty > 0) { %}
|
||||
<span class="inline-graph-bar-inner" title="{{ __("Projected Qty") }}"
|
||||
style="width: {{ cint(d.pending_qty/max_count * 100) }}%">
|
||||
</span>
|
||||
{% } %}
|
||||
{% for d in data %}
|
||||
<li class="list-group-item" style="background-color: inherit;">
|
||||
<div class="row">
|
||||
<div class="col-sm-4 small" style="margin-top: 8px;">
|
||||
<a data-type="warehouse" data-name="{{ d.warehouse }}">{{ d.warehouse }}</a>
|
||||
</div>
|
||||
<div class="col-sm-4 small" style="margin-top: 8px;">
|
||||
{% if d.item_code %}
|
||||
<a data-type="item"
|
||||
data-name="{{ d.item_code }}">{{ d.item_code }}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-sm-4 small">
|
||||
<span class="inline-graph">
|
||||
<span class="inline-graph-half" title="{{ __("Reserved Qty") }}">
|
||||
<span class="inline-graph-count">{{ d.total_reserved }}</span>
|
||||
<span class="inline-graph-bar">
|
||||
<span class="inline-graph-bar-inner"
|
||||
style="width: {{ cint(Math.abs(d.total_reserved)/max_count * 100) || 5 }}%">
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<span class="inline-graph-half" title="{{ __("Acutal Qty {0} / Waiting Qty {1}", [d.actual_qty, d.pending_qty]) }}">
|
||||
<span class="inline-graph-count">
|
||||
{{ d.actual_qty }} {{ (d.pending_qty > 0) ? ("(" + d.pending_qty+ ")") : "" }}
|
||||
</span>
|
||||
<span class="inline-graph-bar">
|
||||
<span class="inline-graph-bar-inner dark"
|
||||
style="width: {{ cint(d.actual_qty/max_count * 100) }}%">
|
||||
</span>
|
||||
{% if d.pending_qty > 0 %}
|
||||
<span class="inline-graph-bar-inner" title="{{ __("Projected Qty") }}"
|
||||
style="width: {{ cint(d.pending_qty/max_count * 100) }}%">
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
{% } %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||
{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
|
||||
|
||||
frappe.require("assets/erpnext/js/utils.js");
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||
{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
|
||||
|
||||
frappe.provide("erpnext.stock");
|
||||
|
||||
|
0
erpnext/stock/page/stock_balance/__init__.py
Normal file
0
erpnext/stock/page/stock_balance/__init__.py
Normal file
32
erpnext/stock/page/stock_balance/stock_balance.html
Normal file
32
erpnext/stock/page/stock_balance/stock_balance.html
Normal file
@ -0,0 +1,32 @@
|
||||
<div class="padding">
|
||||
<div class="row" style="margin-bottom: 15px;">
|
||||
<div class="col-sm-8"></div>
|
||||
<div class="col-sm-4">
|
||||
<button class="btn btn-default btn-xs pull-right btn-order"
|
||||
data-value="desc" style="margin-left: 10px;">
|
||||
<span class="octicon octicon-triangle-down"></span></button>
|
||||
<div class="dropdown pull-right" data-value="actual_qty">
|
||||
<a class="text-muted dropdown-toggle small"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||
{{ __("Actual quantity") }}
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="option" data-value="actual_qty">
|
||||
{{ __("Actual quantity") }}</a></li>
|
||||
<li><a class="option" data-value="reserved_qty">
|
||||
{{ __("Reserved for sale") }}</a></li>
|
||||
<li><a class="option" data-value="reserved_qty_for_production">
|
||||
{{ __("Reserved for manufacturing") }}</a></li>
|
||||
<li><a class="option" data-value="projected_qty">
|
||||
{{ __("Projected quantity") }}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="result list-group">
|
||||
|
||||
</div>
|
||||
<div class="more hidden" style="padding-top: 15px;">
|
||||
<a class="btn btn-default btn-xs btn-more">More</a>
|
||||
</div>
|
||||
</div>
|
109
erpnext/stock/page/stock_balance/stock_balance.js
Normal file
109
erpnext/stock/page/stock_balance/stock_balance.js
Normal file
@ -0,0 +1,109 @@
|
||||
{% include 'erpnext/stock/doctype/item/item_dashboard.html' %}
|
||||
|
||||
frappe.pages['stock-balance'].on_page_load = function(wrapper) {
|
||||
var page = frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: 'Stock Balance',
|
||||
single_column: true
|
||||
});
|
||||
|
||||
var warehouse_field = page.add_field({
|
||||
fieldname: 'wareshouse',
|
||||
label: __('Warehouse'),
|
||||
fieldtype:'Link',
|
||||
options:'Warehouse',
|
||||
change: function() {
|
||||
page.start = 0;
|
||||
refresh()
|
||||
}
|
||||
});
|
||||
|
||||
var item_field = page.add_field({
|
||||
fieldname: 'item_code',
|
||||
label: __('Item'),
|
||||
fieldtype:'Link',
|
||||
options:'Item',
|
||||
change: function() {
|
||||
page.start = 0;
|
||||
refresh()
|
||||
}
|
||||
});
|
||||
|
||||
page.start = 0;
|
||||
page.sort_by = 'actual_qty';
|
||||
page.sort_order = 'desc';
|
||||
|
||||
page.content = $(frappe.render_template('stock_balance')).appendTo(page.main);
|
||||
page.result = page.content.find('.result');
|
||||
|
||||
// more
|
||||
page.content.find('.btn-more').on('click', function() {
|
||||
page.start += 20;
|
||||
refresh();
|
||||
});
|
||||
|
||||
// order
|
||||
page.content.find('.btn-order').on('click', function() {
|
||||
var btn = $(this);
|
||||
var order = $(this).attr('data-value')==='desc' ? 'asc' : 'desc';
|
||||
|
||||
btn.attr('data-value', order);
|
||||
page.sort_order = order;
|
||||
btn.find('.octicon')
|
||||
.removeClass('octicon-triangle-' + (order==='asc' ? 'down' : 'up'))
|
||||
.addClass('octicon-triangle-' + (order==='desc' ? 'down' : 'up'));
|
||||
page.start = 0;
|
||||
refresh();
|
||||
});
|
||||
|
||||
// select field
|
||||
page.content.find('.dropdown a.option').on('click', function() {
|
||||
page.sort_by = $(this).attr('data-value');
|
||||
page.content.find('.dropdown .dropdown-toggle').html($(this).html());
|
||||
refresh();
|
||||
});
|
||||
|
||||
var refresh = function() {
|
||||
var item_code = item_field.get_value();
|
||||
var warehouse = warehouse_field.get_value();
|
||||
frappe.call({
|
||||
method: 'erpnext.stock.page.stock_balance.stock_balance.get_data',
|
||||
args: {
|
||||
item_code: item_code,
|
||||
warehouse: warehouse,
|
||||
start: page.start,
|
||||
sort_by: page.sort_by,
|
||||
sort_order: page.sort_order,
|
||||
},
|
||||
callback: function(r) {
|
||||
render(r.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var render = function(data) {
|
||||
if(page.start===0) {
|
||||
page.max_count = 0;
|
||||
page.result.empty();
|
||||
}
|
||||
|
||||
var context = erpnext.get_item_dashboard_data(data, page.max_count);
|
||||
page.max_count = context.max_count;
|
||||
|
||||
// show more button
|
||||
if(data.length===21) {
|
||||
page.content.find('.more').removeClass('hidden');
|
||||
|
||||
// remove the last element
|
||||
data.splice(-1);
|
||||
} else {
|
||||
page.content.find('.more').addClass('hidden');
|
||||
}
|
||||
|
||||
$(frappe.render_template('item_dashboard', context)).appendTo(page.result);
|
||||
|
||||
}
|
||||
|
||||
refresh();
|
||||
|
||||
}
|
22
erpnext/stock/page/stock_balance/stock_balance.json
Normal file
22
erpnext/stock/page/stock_balance/stock_balance.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"content": null,
|
||||
"creation": "2016-04-21 04:59:00.141546",
|
||||
"docstatus": 0,
|
||||
"doctype": "Page",
|
||||
"idx": 0,
|
||||
"modified": "2016-04-21 05:04:30.228526",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "stock-balance",
|
||||
"owner": "Administrator",
|
||||
"page_name": "stock-balance",
|
||||
"roles": [
|
||||
{
|
||||
"role": "Stock User"
|
||||
}
|
||||
],
|
||||
"script": null,
|
||||
"standard": "Yes",
|
||||
"style": null,
|
||||
"title": "Stock Balance"
|
||||
}
|
14
erpnext/stock/page/stock_balance/stock_balance.py
Normal file
14
erpnext/stock/page/stock_balance/stock_balance.py
Normal file
@ -0,0 +1,14 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_data(item_code=None, warehouse=None, start=0, sort_by='actual_qty', sort_order='desc'):
|
||||
filters = {}
|
||||
if item_code:
|
||||
filters = {'item_code': item_code }
|
||||
if warehouse:
|
||||
filters = {'warehouse': warehouse }
|
||||
return frappe.get_list("Bin", filters=filters, fields=['item_code', 'warehouse',
|
||||
'projected_qty', 'reserved_qty', 'reserved_qty_for_production', 'actual_qty'],
|
||||
order_by='{0} {1}'.format(sort_by, sort_order), start=start, page_length = 21)
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
{% include 'controllers/js/contact_address_common.js' %};
|
||||
{% include 'erpnext/controllers/js/contact_address_common.js' %};
|
||||
|
||||
frappe.ui.form.on("Address", "validate", function(frm) {
|
||||
// clear linked customer / supplier / sales partner on saving...
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
{% include 'controllers/js/contact_address_common.js' %};
|
||||
{% include 'erpnext/controllers/js/contact_address_common.js' %};
|
||||
|
||||
cur_frm.email_field = "email_id";
|
||||
frappe.ui.form.on("Contact", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user