mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 12:36:45 +00:00
initial showcase implementation
This commit is contained in:
parent
53c9475e6d
commit
f647120cd1
13
InvenTree/InvenTree/static/script/chart.min.js
vendored
Normal file
13
InvenTree/InvenTree/static/script/chart.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -326,7 +326,7 @@ class PurchaseOrder(Order):
|
|||||||
return self.pending_line_items().count() == 0
|
return self.pending_line_items().count() == 0
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def receive_line_item(self, line, location, quantity, user, status=StockStatus.OK):
|
def receive_line_item(self, line, location, quantity, user, status=StockStatus.OK, purchase_price=None):
|
||||||
""" Receive a line item (or partial line item) against this PO
|
""" Receive a line item (or partial line item) against this PO
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -348,7 +348,8 @@ class PurchaseOrder(Order):
|
|||||||
location=location,
|
location=location,
|
||||||
quantity=quantity,
|
quantity=quantity,
|
||||||
purchase_order=self,
|
purchase_order=self,
|
||||||
status=status
|
status=status,
|
||||||
|
purchase_price=purchase_price,
|
||||||
)
|
)
|
||||||
|
|
||||||
stock.save()
|
stock.save()
|
||||||
|
@ -776,6 +776,7 @@ class PurchaseOrderReceive(AjaxUpdateView):
|
|||||||
line.receive_quantity,
|
line.receive_quantity,
|
||||||
self.request.user,
|
self.request.user,
|
||||||
status=line.status_code,
|
status=line.status_code,
|
||||||
|
purchase_price=line.purchase_price,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% extends "modal_form.html" %}
|
{% extends "modal_form.html" %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
{% block pre_form_content %}
|
{% block pre_form_content %}
|
||||||
|
|
||||||
<div class='alert alert-info alert-block'>
|
<div class='alert alert-info alert-block'>
|
||||||
@ -77,6 +78,76 @@ Pricing information for:<br>
|
|||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if price_history %}
|
||||||
|
<h4>{% trans 'Stock Pricing' %}</h4>
|
||||||
|
{% if price_history|length > 1 %}
|
||||||
|
<canvas id="priceChart"></canvas>
|
||||||
|
<script>
|
||||||
|
var pricedata = {
|
||||||
|
labels: [
|
||||||
|
{% for line in price_history %}'{{ line.date }}',{% endfor %}
|
||||||
|
],
|
||||||
|
datasets: [{
|
||||||
|
label: 'Price',
|
||||||
|
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
||||||
|
borderColor: 'rgb(255, 99, 132)',
|
||||||
|
yAxisID: 'y',
|
||||||
|
data: [
|
||||||
|
{% for line in price_history %}{{ line.price|stringformat:".2f" }},{% endfor %}
|
||||||
|
],
|
||||||
|
borderWidth: 1,
|
||||||
|
type: 'line'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Qty',
|
||||||
|
backgroundColor: 'rgba(255, 206, 86, 0.2)',
|
||||||
|
borderColor: 'rgb(255, 206, 86)',
|
||||||
|
yAxisID: 'y1',
|
||||||
|
data: [
|
||||||
|
{% for line in price_history %}{{ line.qty|stringformat:"f" }},{% endfor %}
|
||||||
|
],
|
||||||
|
borderWidth: 1
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
var ctx = document.getElementById('priceChart');
|
||||||
|
var priceChart = new Chart(ctx, {
|
||||||
|
type: 'bar',
|
||||||
|
data: pricedata,
|
||||||
|
options: {
|
||||||
|
responsive: true,
|
||||||
|
plugins: {legend: {position: 'bottom'}},
|
||||||
|
scales: {
|
||||||
|
y: {
|
||||||
|
type: 'linear',
|
||||||
|
position: 'left',
|
||||||
|
grid: {display: false},
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: 'Price - USD'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
y1: {
|
||||||
|
type: 'linear',
|
||||||
|
position: 'right',
|
||||||
|
grid: {display: false},
|
||||||
|
titel: {
|
||||||
|
display: true,
|
||||||
|
text: 'Qty',
|
||||||
|
position: 'right'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% else %}
|
||||||
|
<div class='alert alert-danger alert-block'>
|
||||||
|
{% trans 'No stock pricing history is available for this part.' %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if min_unit_buy_price or min_unit_bom_price %}
|
{% if min_unit_buy_price or min_unit_bom_price %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class='alert alert-danger alert-block'>
|
<div class='alert alert-danger alert-block'>
|
||||||
|
@ -2027,6 +2027,30 @@ class PartPricing(AjaxView):
|
|||||||
ctx['max_total_bom_price'] = max_bom_price
|
ctx['max_total_bom_price'] = max_bom_price
|
||||||
ctx['max_unit_bom_price'] = max_bom_price / quantity
|
ctx['max_unit_bom_price'] = max_bom_price / quantity
|
||||||
|
|
||||||
|
# Stock history
|
||||||
|
if part.total_stock > 1:
|
||||||
|
ret = []
|
||||||
|
stock = part.stock_entries(include_variants=False, in_stock=True)
|
||||||
|
|
||||||
|
for stock_item in stock:
|
||||||
|
if None in [stock_item.purchase_price, stock_item.quantity]:
|
||||||
|
continue
|
||||||
|
line = {
|
||||||
|
'price': stock_item.purchase_price.amount,
|
||||||
|
'qty': stock_item.quantity
|
||||||
|
}
|
||||||
|
if stock_item.supplier_part:
|
||||||
|
line['name'] = stock_item.supplier_part.pretty_name
|
||||||
|
|
||||||
|
if stock_item.supplier_part.unit_pricing and stock_item.purchase_price:
|
||||||
|
line['price_diff'] = stock_item.supplier_part.unit_pricing - stock_item.purchase_price.amount
|
||||||
|
if stock_item.purchase_order:
|
||||||
|
|
||||||
|
line['date'] = stock_item.purchase_order.issue_date.strftime('%d.%m.%Y')
|
||||||
|
ret.append(line)
|
||||||
|
|
||||||
|
ctx['price_history'] = ret
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
@ -136,6 +136,7 @@ InvenTree
|
|||||||
<script type="text/javascript" src="{% static 'fullcalendar/main.js' %}"></script>
|
<script type="text/javascript" src="{% static 'fullcalendar/main.js' %}"></script>
|
||||||
<script type="text/javascript" src="{% static 'script/select2/select2.js' %}"></script>
|
<script type="text/javascript" src="{% static 'script/select2/select2.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'script/moment.js' %}"></script>
|
<script type='text/javascript' src="{% static 'script/moment.js' %}"></script>
|
||||||
|
<script type='text/javascript' src="{% static 'script/chart.min.js' %}"></script>
|
||||||
|
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
|
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
|
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user