diff --git a/templates/nav.html b/templates/nav.html index 887d1d6..eb9468e 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -52,7 +52,7 @@ Manage diff --git a/templates/transaction/order_filter.html b/templates/transaction/order.html similarity index 100% rename from templates/transaction/order_filter.html rename to templates/transaction/order.html diff --git a/templates/transaction/transfer.html b/templates/transaction/transfer.html new file mode 100644 index 0000000..db9922b --- /dev/null +++ b/templates/transaction/transfer.html @@ -0,0 +1,128 @@ +{% extends "base.html" %} + +{% block content %} + + + +
+ + {% include "nav.html" %} + + +
+ + + +
+ + + +
+ + +

{{ warehouse_name }}

+

Order Listing

+ +
+ + +
Filter
+
+ +
+
+ {{ filter.form.as_p }} +
+ +
+ +
+
+
+ + + + + + +
+
+
Order
+
+
+
+ + + + + + + + + + + + + + + + + + + + + {% if filter.is_bound %} + {% for transfer in filter.qs %} + + {% comment %} {% endcomment %} + + + + + + + {% endfor %} + {% else %} + {% for transfer in transfer_list %} + + {% comment %} {% endcomment %} + + + + + + + {% endfor %} + {% endif %} + +
Transfer FromTransfer ToItem NameQuantityUpdated Time
Transfer FromTransfer ToItem NameQuantityUpdated Time
{{ inventory.stock_identifier }}{{ transfer.from_warehouse }}{{ transfer.to_warehouse }}{{ transfer.item }}{{ transfer.quantity }}{{ transfer.update_time }}
{{ inventory.stock_identifier }}{{ transfer.from_warehouse }}{{ transfer.to_warehouse }}{{ transfer.item }}{{ transfer.quantity }}{{ transfer.update_time }}
+
+
+
+ +
+ + +
+ + + +
+ + +
+ + + + + + + + {% include "footer.html" %} + + +{% endblock content %} \ No newline at end of file diff --git a/transaction/filters.py b/transaction/filters.py index a7b0f17..74b2117 100644 --- a/transaction/filters.py +++ b/transaction/filters.py @@ -1,6 +1,6 @@ from django import forms import django_filters -from transaction.models import Order +from transaction.models import Order, Transfer class OrderFilter(django_filters.FilterSet): customer_name = django_filters.CharFilter(field_name='customer__name', lookup_expr='icontains', label='Customer Name') @@ -10,3 +10,13 @@ class OrderFilter(django_filters.FilterSet): class Meta: model = Order fields = ['customer_name', 'item_name', 'order_date'] + + +class TransferFilter(django_filters.FilterSet): + from_warehouse = django_filters.CharFilter(field_name='from_warehouse__name', lookup_expr='icontains', label='From Warehouse') + to_warehouse = django_filters.CharFilter(field_name='to_warehouse__name', lookup_expr='icontains', label='To Warehouse') + item_name = django_filters.CharFilter(field_name='item__name', lookup_expr='icontains', label='Item Name') + + class Meta: + model = Transfer + fields = ['from_warehouse', 'to_warehouse', 'item_name'] \ No newline at end of file diff --git a/transaction/urls.py b/transaction/urls.py index 4c17f3c..f44029b 100644 --- a/transaction/urls.py +++ b/transaction/urls.py @@ -1,7 +1,8 @@ from django.urls import path -from transaction.views import CustomerOrderView +from transaction.views import CustomerOrderView, TransferListView urlpatterns = [ path('order/', CustomerOrderView.as_view(), name='customer-order'), + path('transfers/', TransferListView.as_view(), name='transfer-list'), ] diff --git a/transaction/views.py b/transaction/views.py index 23e9d1f..927ee5f 100644 --- a/transaction/views.py +++ b/transaction/views.py @@ -1,19 +1,31 @@ from django_filters.views import FilterView from django.contrib.auth.mixins import LoginRequiredMixin -from transaction.models import Order, Customer -from transaction.filters import OrderFilter +from transaction.models import Order, Transfer +from transaction.filters import OrderFilter, TransferFilter class CustomerOrderView(FilterView, LoginRequiredMixin): - template_name = 'transaction/order_filter.html' + template_name = 'transaction/order.html' model = Order filterset_class = OrderFilter context_object_name = 'orders' def get_queryset(self): queryset = super().get_queryset() - return queryset.filter(customer__isnull=False) # Exclude orders without a customer + return queryset.filter(customer__isnull=False) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context['customers'] = Customer.objects.all() + context['order_list'] = Order.objects.all() + return context + + +class TransferListView(FilterView): + template_name = 'transaction/transfer.html' + model = Transfer + filterset_class = TransferFilter + context_object_name = 'transfers_list' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['transfer_list'] = Transfer.objects.all() return context \ No newline at end of file