Split display of purchase orders by company view

This commit is contained in:
Oliver Walters 2019-06-10 22:43:09 +10:00
parent b8bcc5ce0c
commit c132f275f5
4 changed files with 28 additions and 42 deletions

View File

@ -135,6 +135,16 @@ class Company(models.Model):
""" Return purchase orders which are 'outstanding' """
return self.purchase_orders.filter(status__in=OrderStatus.OPEN)
def closed_purchase_orders(self):
""" Return purchase orders which are not 'outstanding'
- Complete
- Failed / lost
- Returned
"""
return self.purchase_orders.exclude(status__in=OrderStatus.OPEN)
def complete_purchase_orders(self):
return self.purchase_orders.filter(status=OrderStatus.COMPLETE)

View File

@ -4,17 +4,13 @@
{% include 'company/tabs.html' with tab='po' %}
<h4>Purchase Orders</h4>
<h4>Open Purchase Orders</h4>
{% include "order/po_table.html" with orders=company.outstanding_purchase_orders.all %}
{% if company.closed_purchase_orders.count > 0 %}
{% include "order/po_table_collapse.html" with title="Closed Orders" orders=company.closed_purchase_orders.all %}
{% endif %}
<table class='table table-striped table-condensed' id='po-table'>
<tr>
<th>Reference</th>
<th>Description</th>
<th>Status</th>
</tr>
{% include "company/po_list.html" with orders=company.outstanding_purchase_orders %}
{% include "company/po_list.html" with orders=company.complete_purchase_orders %}
{% include "company/po_list.html" with orders=company.failed_purchase_orders %}
</table>
{% endblock %}

View File

@ -1,31 +0,0 @@
{% extends "supplier/supplier_base.html" %}
{% block details %}
{% include "supplier/tabs.html" with tab='order' %}
<h3>Supplier Orders</h3>
<table class="table table-striped">
<tr>
<th>Reference</th>
<th>Issued</th>
<th>Delivery</th>
<th>Status</th>
</tr>
{% for order in supplier.orders.all %}
<tr>
<td><a href="{% url 'supplier-order-detail' order.id %}">{{ order.internal_ref }}</a></td>
<td>{% if order.issued_date %}{{ order.issued_date }}{% endif %}</td>
<td>{% if order.delivery_date %}{{ order.delivery_date }}{% endif %}</td>
<td>{% include "supplier/order_status.html" with order=order %}</td>
</tr>
{% endfor %}
</table>
<div class='container-fluid'>
<a href="{% url 'supplier-order-create' %}?supplier={{ supplier.id }}">
<button class="btn btn-success">New Order</button>
</a>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "collapse.html" %}
{% load static %}
{% block collapse_title %}
<h4>{{ title }}</h4>
{% endblock %}
{% block collapse_content %}
{% include "order/po_table.html" %}
{% endblock %}