Adds initial inventory management, Django 1.6, ++

Adds dep on south
This commit is contained in:
nikolark committed 2014-07-23 22:39:44 +02:00
1 parent 09d41ba682
commit 32e41c05ae
32 files changed
+5561 -1382

No files matched your search

+2
View File
@@ -38,6 +38,8 @@
<script type="text/javascript" src="{{ STATIC_URL }}js/bootstrap/collapse.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/bootstrap/dropdown.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/bootstrap/tooltip.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/locales/bootstrap-datepicker.nb.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/highcharts.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/underscore-min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/app.js"></script>
+1 -1
View File
@@ -80,7 +80,7 @@
<div class="row">
<div class="col-md-12">
<button type="submit" class="btn btn-lg btn-primary" name="submit_order">Sett inn</button>
  <a href="{% url register %}" class="btn btn-default">Avbryt</a>
  <a href="{% url 'register' %}" class="btn btn-default">Avbryt</a>
</div>
</div>
</form>
+80
View File
@@ -0,0 +1,80 @@
{% extends "base.html" %}
{% block header %}
{% include "nav.html" with active="inventory" %}
{% endblock %}
{% block content %}
<section id="inventory" class="row">
<div class="row">
<div class="col-md-7">
<h2>Varebeholdning</h2>
<!-- TODO History view -->
<!--<div class="text-right">
<div class="btn-group">
<a href="#list" class="btn btn-default"><i class="glyphicon glyphicon-list"></i> Liste</a>
<a href="#stats" class="btn btn-default"><i class="glyphicon glyphicon-stats"></i> Historikk</a>
</div>
</div>-->
<table class="table table-striped">
<thead>
<tr>
<th>Sist oppdatert</th>
<th>Vare</th>
<th>Beholdning</th>
<th>Pris (intern)</th>
<th>Verdi</th>
<th>I salg</th>
</tr>
</thead>
<tbody>
{% for product in products %}
<tr class="{% if not product.active %}info inactive{% elif product.inventory_amount <= 0 %}warning{% else %}success{% endif %}">
<td>{{ product.updated }}</td>
<td>{{ product.name }}</td>
<td class="product-amount">{{ product.inventory_amount }}</td>
<td>{{ product.sale_price_int }}</td>
<td>{{ product.inventory_value }}</td>
<td class="product-active">{% if product.active %}<i class="glyphicon glyphicon-ok"></i>{% endif %}</td>
</tr>
{% endfor %}
<tr>
<td><em>Sum</em></td>
<td></td>
<td> {{ num_products }}</td>
<td></td>
<td><b>{{ inventory_value }}</b></td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-5">
<h2>Varetransaksjoner</h2>
<div class="text-right">
<a href="{% url 'inventory-add' %}" class="btn btn-primary"><i class="glyphicon glyphicon-plus"></i> Sett inn varer</a>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>Når</th>
<th>Hva</th>
<th>Antall</th>
<th>Hvem</th>
</tr>
</thead>
<tbody>
{% for t in transactions %}
<tr>
<td>{{ t.created }}</td>
<td>{{ t.product }}</td>
<td>{{ t.amount }}</td>
<td>{% if t.user.get_profile.image %}<img src="{{ t.user.get_profile.image }}" class="customer" title="{{ t.user.first_name }} {{ t.user.last_name|slice:":1"}}" />{% else %}{{ t.user.first_name }} {{ t.user.last_name|slice:":1"}}{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</section>
{% endblock %}
+37
View File
@@ -0,0 +1,37 @@
{% extends "base.html" %}
{% load widget_tweaks %}
{% load bootstrap %}
{% block title %}Legg til nye varer {% endblock %}
{% block header %}
{% include "nav.html" with active="inventory_add" %}
{% endblock %}
{% block content %}
{% if perms.auth.can_add_inventory_transaction %}
<section class="row">
<div class="col-md-4">
{% for message in messages %}
<div {% if message.tags %} class="alert alert-{{ message.tags }}"{% endif %}>{{ message }}<a class="close" data-dismiss="alert">×</a></div>
{% endfor %}
</div>
</section>
<section class="row">
<div class="col-md-5">
<h1>Legg til nye varer</h1>
{% if form.non_field_errors %}
<p>{{ form.non_field_errors}}.</p>
{% endif %}
<form method="post" role="form">
{% csrf_token %}
{{ form|bootstrap }}
<input type="submit" value="Legg til" class="btn btn-primary btn-lg" />
<a href="{% url 'inventory' %}" class="btn btn-default" />Tilbake</a>
</form>
</div>
</section>
{% endif %}
{% endblock %}
+4 -4
View File
@@ -19,10 +19,10 @@
<section id="orders">
{% if not limit %}
<h2 title="Alle registrerte ordre">Alle ordre</h2><br />
<a href="{% url log %}">Vis kun siste</a>
<a href="{% url 'log' %}">Vis kun siste</a>
{% else %}
<h2 title="Ordre fra de siste 2 dagene eller de 5 siste ordrene.">Siste ordre</h2><br />
<a href="{% url log-all %}">Vis alle</a>
<a href="{% url 'log-all' %}">Vis alle</a>
{%endif %}
<table class="table table-striped">
<thead>
@@ -53,10 +53,10 @@
<section id="transactions">
{% if not limit %}
<h2 title="Alle registrerte transaksjoner">Alle transaksjoner</h2>
<br /><a href="{% url log %}#transactions">Vis kun siste</a>
<br /><a href="{% url 'log' %}#transactions">Vis kun siste</a>
{% else %}
<h2 title="Transaksjoner fra de siste 2 dagene eller de 5 siste transaksjonene.">Siste transaksjoner</h2><br />
<a href="{% url log-all %}#transactions">Vis alle</a>
<a href="{% url 'log-all' %}#transactions">Vis alle</a>
{%endif %}
<table class="table table-striped">
<thead>
+5 -3
View File
@@ -19,15 +19,17 @@
</ul>
<ul class="nav navbar-nav navbar-right">
{% if not user.is_authenticated %}
<li><a href="{% url login %}">Logg inn</a></li>
<li><a href="{% url 'login' %}">Logg inn</a></li>
{% else %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Innstillinger <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="{% if active = "create_user" %}active{% endif %}"><a href="{% url create-user %}"><i class="glyphicon glyphicon-plus"></i> Ny bruker</a></li>
<li class="{% if active = "create_user" %}active{% endif %}"><a href="{% url 'create-user' %}"><i class="glyphicon glyphicon-plus"></i> Ny bruker</a></li>
{% if request.user.is_superuser %}<li><a href="/admin"><i class="glyphicon glyphicon-cog"></i> Administrasjon</a></li>{% endif %}
{% if request.user.is_superuser %}<li><a href="{% url 'inventory' %}"><i class="glyphicon glyphicon-briefcase"></i> Varebeholdning</a></li>{% endif %}
{% if request.user.is_superuser %}<li><a href="{% url 'report' %}"><i class="glyphicon glyphicon-briefcase"></i> Rapport</a></li>{% endif %}
<li class="divider"></li>
<li><a href="{% url logout %}"><i class="glyphicon glyphicon-log-out"></i> Logg ut</a></li>
<li><a href="{% url 'logout' %}"><i class="glyphicon glyphicon-log-out"></i> Logg ut</a></li>
</ul>
</li>
{% endif %}
+1 -1
View File
@@ -61,7 +61,7 @@
<div class="row">
<div class="col-md-3">
<h2>Hvem kjøper?</h2>
<div class="alert alert-error">Ingen har positiv saldo i BBS.</div><a href="{% url deposit %}" class="btn">Sett inn penger</a>
<div class="alert alert-error">Ingen har positiv saldo i BBS.</div><a href="{% url 'deposit' %}" class="btn">Sett inn penger</a>
</div>
</div>
{%endif%}
+1 -1
View File
@@ -42,7 +42,7 @@
</div>
<input type="submit" value="Legg til" class="btn btn-primary btn-lg" />
<a href="{% url register %}" class="btn btn-default" />Tilbake</a>
<a href="{% url 'register' %}" class="btn btn-default" />Tilbake</a>
</form>
</div>
</section>
+1 -1
View File
@@ -4,7 +4,7 @@
<p class="alert alert-danger">Brukernavn og passord stemmer ikke overens. Prøv igjen.</p>
{% endif %}
<form method="post" action="{% url django.contrib.auth.views.login %}" class="">
<form method="post" action="{% url 'django.contrib.auth.views.login' %}" class="">
{% csrf_token %}
<label for="id_username">Brukernavn:</label>
{{ form.username|add_class:"form-control" }}
+1 -1
View File
@@ -6,7 +6,7 @@
<div class="row">
<div class="col-md-6">
<p class="alert alert-success">Du er logget ut.</p>
<p>Vil du <a href="{% url home %}">logge inn igjen?</a></p>
<p>Vil du <a href="{% url 'home' %}">logge inn igjen?</a></p>
</div>
</div>
{% endblock %}
+98
View File
@@ -0,0 +1,98 @@
{% extends "base.html" %}
{% load bootstrap %}
{% block header %}
{% include "nav.html" with active="inventory" %}
{% endblock %}
{% block content %}
<section id="inventory-report" class="row">
<div class="col-md-7">
<h2>Varerapport</h2>
<form class="inventory-report-form">
{{ form|bootstrap_horizontal }} ({{ start_time|timesince:end_time}})
<button type="submit" class="btn btn-default">Oppdater</button>
</form>
<h2>Beholdning</h2>
<table class="table table-striped">
<thead>
<tr>
<th>Navn</th>
<th>Sum verdi (innkjøp)</th>
<th>Sum verdi (salg)</th>
<th>Endring verdi</th>
<th>Enheter (innkjøp)</th>
<th>Enheter (salg)</th>
<th>Endring enheter</th>
</tr>
</thead>
<tbody>
{% for name,p in inventory_products.items %}
<tr>
<td>{{name}}</td>
<td>{{p.transactions_sum|default:"0"}} kr</td>
<td>{{p.orderlines_sum|default:"0"}} kr</td>
<td class="{% if p.value_diff > 0 %}positive{% elif p.value_diff < 0 %}negative{% endif %}">{% if p.value_diff > 0 %}<i class="glyphicon glyphicon-arrow-up"></i> {% elif p.value_diff < 0 %}<i class="glyphicon glyphicon-arrow-down"></i> {% endif %}{{ p.value_diff }}</td>
<td>{{p.transactions_units|default:"0"}} stk</td>
<td>{{p.orderlines_units|default:"0"}} stk</td>
<td class="{% if p.units_diff > 0 %}positive{% elif p.units_diff < 0 %}negative{% endif %}">{% if p.units_diff > 0 %}<i class="glyphicon glyphicon-arrow-up"></i> {% elif p.units_diff < 0 %}<i class="glyphicon glyphicon-arrow-down"></i> {% endif %}{{ p.units_diff }}</td>
</tr>
{% endfor %}
<tr>
<td><strong>Totalt</strong></td>
<td>{{ inv_in }} kr</td>
<td>{{ inv_out }} kr</td>
<td class="{% if inv_diff > 0 %}positive{% elif inv_diff < 0 %}negative{% endif %}">{% if inv_diff > 0 %}<i class="glyphicon glyphicon-arrow-up"></i> {% elif inv_diff < 0 %}<i class="glyphicon glyphicon-arrow-down"></i> {% endif %}{{ inv_diff }}</td>
<td></td>
</tr>
</tbody>
</table>
</ul>
<h2>Innskudd</h2>
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th>Dato</th>
<th>Saldo</th>
<th>Innskudd</th>
<th>Kjøp</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fra</td>
<td>{{ start_time|date:"Y-m-d" }}</td>
<td>{{ saldo_start }}</td>
<td>{{ deposits_start }}</td>
<td>{{ purchases_start }}</td>
</tr>
<tr>
<td>Til</td>
<td>{{ end_time|date:"Y-m-d" }}</td>
<td>{{ saldo_end }}</td>
<td>{{ deposits_end }}</td>
<td>{{ purchases_end }}</td>
</tr>
<tr>
<td><strong>Endring</strong></td>
<td>Siste {{ start_time|timesince:end_time}}</td>
<td class="{% if saldo_diff > 0 %}positive{% elif saldo_diff < 0 %}negative{% endif %}">{% if saldo_diff > 0 %}<i class="glyphicon glyphicon-arrow-up"></i> {% elif saldo_diff < 0 %}<i class="glyphicon glyphicon-arrow-down"></i> {% endif %}{{ saldo_diff }}</td>
<td class="{% if deposits_diff > 0 %}positive{% elif deposits_diff < 0 %}negative{% endif %}">{% if deposits_diff > 0 %}<i class="glyphicon glyphicon-arrow-up"></i> {% elif deposits_diff < 0 %}<i class="glyphicon glyphicon-arrow-down"></i> {% endif %}{{ deposits_diff }}</td>
<td class="{% if purchases_diff > 0 %}positive{% elif purchases_diff < 0 %}negative{% endif %}">{% if purchases_diff > 0 %}<i class="glyphicon glyphicon-arrow-up"></i> {% elif purchases_diff < 0 %}<i class="glyphicon glyphicon-arrow-down"></i> {% endif %}{{ purchases_diff }}</td>
</tr>
{% if end_time|date:"Y-m-d" != datetime_now|date:"Y-m-d" %}
<tr>
<td>I dag</td>
<td>{% now "Y-m-d" %}</td>
<td>{{ saldo }} (innskudd - kjøp) / {{ saldo_profiles }} kr (profil)</td>
<td>{{ deposits }}</td>
<td>{{ purchases }}</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</section>
{% endblock %}