mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 02:24:26 +00:00
Format counter
This commit is contained in:
parent
e7de8b2aec
commit
d722efc40f
@ -36,4 +36,3 @@ admin.site.register(Selling)
|
||||
admin.site.register(Permanency)
|
||||
admin.site.register(CashRegisterSummary)
|
||||
admin.site.register(Eticket)
|
||||
|
||||
|
@ -22,13 +22,12 @@
|
||||
#
|
||||
#
|
||||
|
||||
from django.db import models, DataError
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.forms import ValidationError
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
from datetime import timedelta, date
|
||||
@ -43,6 +42,7 @@ from accounting.models import CurrencyField
|
||||
from core.models import Group, User, Notification
|
||||
from subscription.models import Subscription
|
||||
|
||||
|
||||
class Customer(models.Model):
|
||||
"""
|
||||
This class extends a user to make a customer. It adds some basic customers informations, such as the accound ID, and
|
||||
@ -118,6 +118,7 @@ class ProductType(models.Model):
|
||||
def get_absolute_url(self):
|
||||
return reverse('counter:producttype_list')
|
||||
|
||||
|
||||
class Product(models.Model):
|
||||
"""
|
||||
This describes a product, with all its related informations
|
||||
@ -156,6 +157,7 @@ class Product(models.Model):
|
||||
def get_absolute_url(self):
|
||||
return reverse('counter:product_list')
|
||||
|
||||
|
||||
class Counter(models.Model):
|
||||
name = models.CharField(_('name'), max_length=30)
|
||||
club = models.ForeignKey(Club, related_name="counters", verbose_name=_("club"))
|
||||
@ -265,6 +267,7 @@ class Counter(models.Model):
|
||||
"""
|
||||
return [b.id for b in self.get_barmen_list()]
|
||||
|
||||
|
||||
class Refilling(models.Model):
|
||||
"""
|
||||
Handle the refilling
|
||||
@ -309,6 +312,7 @@ class Refilling(models.Model):
|
||||
).save()
|
||||
super(Refilling, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class Selling(models.Model):
|
||||
"""
|
||||
Handle the sellings
|
||||
@ -414,7 +418,8 @@ class Selling(models.Model):
|
||||
try:
|
||||
if self.product.eticket:
|
||||
self.send_mail_customer()
|
||||
except: pass
|
||||
except:
|
||||
pass
|
||||
Notification(
|
||||
user=self.customer.user,
|
||||
url=reverse('core:user_account_detail',
|
||||
@ -424,6 +429,7 @@ class Selling(models.Model):
|
||||
).save()
|
||||
super(Selling, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class Permanency(models.Model):
|
||||
"""
|
||||
This class aims at storing a traceability of who was barman where and when
|
||||
@ -444,6 +450,7 @@ class Permanency(models.Model):
|
||||
self.end.strftime("%Y-%m-%d %H:%M:%S") if self.end else "",
|
||||
)
|
||||
|
||||
|
||||
class CashRegisterSummary(models.Model):
|
||||
user = models.ForeignKey(User, related_name="cash_summaries", verbose_name=_("user"))
|
||||
counter = models.ForeignKey(Counter, related_name="cash_summaries", verbose_name=_("counter"))
|
||||
@ -515,6 +522,7 @@ class CashRegisterSummary(models.Model):
|
||||
def get_absolute_url(self):
|
||||
return reverse('counter:cash_summary_list')
|
||||
|
||||
|
||||
class CashRegisterSummaryItem(models.Model):
|
||||
cash_summary = models.ForeignKey(CashRegisterSummary, related_name="items", verbose_name=_("cash summary"))
|
||||
value = CurrencyField(_("value"))
|
||||
@ -524,6 +532,7 @@ class CashRegisterSummaryItem(models.Model):
|
||||
class Meta:
|
||||
verbose_name = _("cash register summary item")
|
||||
|
||||
|
||||
class Eticket(models.Model):
|
||||
"""
|
||||
Eticket can be linked to a product an allows PDF generation
|
||||
@ -552,6 +561,6 @@ class Eticket(models.Model):
|
||||
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
||||
|
||||
def get_hash(self, string):
|
||||
import hashlib, hmac
|
||||
import hashlib
|
||||
import hmac
|
||||
return hmac.new(bytes(self.secret, 'utf-8'), bytes(string, 'utf-8'), hashlib.sha1).hexdigest()
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
import re
|
||||
|
||||
from pprint import pprint
|
||||
from django.test import TestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.management import call_command
|
||||
|
@ -22,7 +22,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from django.conf.urls import url, include
|
||||
from django.conf.urls import url
|
||||
|
||||
from counter.views import *
|
||||
|
||||
|
104
counter/views.py
104
counter/views.py
@ -22,7 +22,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.http import Http404
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.views.generic import ListView, DetailView, RedirectView, TemplateView
|
||||
@ -31,7 +31,6 @@ from django.views.generic.edit import UpdateView, CreateView, DeleteView, Proces
|
||||
from django.forms.models import modelform_factory
|
||||
from django.forms import CheckboxSelectMultiple
|
||||
from django.core.urlresolvers import reverse_lazy, reverse
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
from django.utils import timezone
|
||||
from django import forms
|
||||
@ -43,16 +42,17 @@ import re
|
||||
import pytz
|
||||
from datetime import date, timedelta, datetime
|
||||
from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultipleField
|
||||
from ajax_select import make_ajax_form, make_ajax_field
|
||||
from ajax_select import make_ajax_field
|
||||
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin, TabedViewMixin
|
||||
from core.views.forms import SelectUser, LoginForm, SelectDate, SelectDateTime
|
||||
from core.views import CanViewMixin, TabedViewMixin
|
||||
from core.views.forms import LoginForm, SelectDate, SelectDateTime
|
||||
from core.models import User
|
||||
from subscription.models import Subscription
|
||||
from counter.models import Counter, Customer, Product, Selling, Refilling, ProductType, \
|
||||
CashRegisterSummary, CashRegisterSummaryItem, Eticket, Permanency
|
||||
from accounting.models import CurrencyField
|
||||
|
||||
|
||||
class CounterAdminMixin(View):
|
||||
"""
|
||||
This view is made to protect counter admin section
|
||||
@ -72,13 +72,13 @@ class CounterAdminMixin(View):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not (request.user.is_root or self._test_group(request.user)
|
||||
or self._test_club(request.user)):
|
||||
raise PermissionDenied
|
||||
return super(CounterAdminMixin, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
class GetUserForm(forms.Form):
|
||||
"""
|
||||
The Form class aims at providing a valid user_id field in its cleaned data, in order to pass it to some view,
|
||||
@ -107,20 +107,24 @@ class GetUserForm(forms.Form):
|
||||
cleaned_data['user'] = cus.user
|
||||
return cleaned_data
|
||||
|
||||
|
||||
class RefillForm(forms.ModelForm):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
amount = forms.FloatField(min_value=0, widget=forms.NumberInput(attrs={'class': 'focus'}))
|
||||
|
||||
class Meta:
|
||||
model = Refilling
|
||||
fields = ['amount', 'payment_method', 'bank']
|
||||
|
||||
|
||||
class CounterTabsMixin(TabedViewMixin):
|
||||
def get_tabs_title(self):
|
||||
if hasattr(self.object, 'stock_owner'):
|
||||
return self.object.stock_owner.counter
|
||||
else:
|
||||
return self.object
|
||||
|
||||
def get_list_of_tabs(self):
|
||||
tab_list = []
|
||||
tab_list.append({
|
||||
@ -149,9 +153,11 @@ class CounterTabsMixin(TabedViewMixin):
|
||||
'slug': 'take_items_from_stock',
|
||||
'name': _("Take items from stock"),
|
||||
})
|
||||
except: pass # The counter just have no stock
|
||||
except:
|
||||
pass # The counter just have no stock
|
||||
return tab_list
|
||||
|
||||
|
||||
class CounterMain(CounterTabsMixin, CanViewMixin, DetailView, ProcessFormView, FormMixin):
|
||||
"""
|
||||
The public (barman) view
|
||||
@ -210,6 +216,7 @@ class CounterMain(CounterTabsMixin, CanViewMixin, DetailView, ProcessFormView, F
|
||||
def get_success_url(self):
|
||||
return reverse_lazy('counter:click', args=self.args, kwargs=self.kwargs)
|
||||
|
||||
|
||||
class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
||||
"""
|
||||
The click view
|
||||
@ -470,6 +477,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
||||
kwargs['categories'] = ProductType.objects.all()
|
||||
return kwargs
|
||||
|
||||
|
||||
class CounterLogin(RedirectView):
|
||||
"""
|
||||
Handle the login of a barman
|
||||
@ -477,6 +485,7 @@ class CounterLogin(RedirectView):
|
||||
Logged barmen are stored in the Permanency model
|
||||
"""
|
||||
permanent = False
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
Register the logged user as barman for this counter
|
||||
@ -501,8 +510,10 @@ class CounterLogin(RedirectView):
|
||||
def get_redirect_url(self, *args, **kwargs):
|
||||
return reverse_lazy('counter:details', args=args, kwargs=kwargs) + "?" + '&'.join(self.errors)
|
||||
|
||||
|
||||
class CounterLogout(RedirectView):
|
||||
permanent = False
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
Unregister the user from the barman
|
||||
@ -515,7 +526,8 @@ class CounterLogout(RedirectView):
|
||||
def get_redirect_url(self, *args, **kwargs):
|
||||
return reverse_lazy('counter:details', args=args, kwargs=kwargs)
|
||||
|
||||
## Counter admin views
|
||||
# Counter admin views
|
||||
|
||||
|
||||
class CounterAdminTabsMixin(TabedViewMixin):
|
||||
tabs_title = _("Counter administration")
|
||||
@ -562,6 +574,7 @@ class CounterAdminTabsMixin(TabedViewMixin):
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
class CounterListView(CounterAdminTabsMixin, CanViewMixin, ListView):
|
||||
"""
|
||||
A list view for the admins
|
||||
@ -570,6 +583,7 @@ class CounterListView(CounterAdminTabsMixin, CanViewMixin, ListView):
|
||||
template_name = 'counter/counter_list.jinja'
|
||||
current_tab = "counters"
|
||||
|
||||
|
||||
class CounterEditForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Counter
|
||||
@ -577,6 +591,7 @@ class CounterEditForm(forms.ModelForm):
|
||||
sellers = make_ajax_field(Counter, 'sellers', 'users', help_text="")
|
||||
products = make_ajax_field(Counter, 'products', 'products', help_text="")
|
||||
|
||||
|
||||
class CounterEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
"""
|
||||
Edit a counter's main informations (for the counter's manager)
|
||||
@ -595,6 +610,7 @@ class CounterEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
def get_success_url(self):
|
||||
return reverse_lazy('counter:admin', kwargs={'counter_id': self.object.id})
|
||||
|
||||
|
||||
class CounterEditPropView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
"""
|
||||
Edit a counter's main informations (for the counter's admin)
|
||||
@ -605,6 +621,7 @@ class CounterEditPropView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
template_name = 'core/edit.jinja'
|
||||
current_tab = "counters"
|
||||
|
||||
|
||||
class CounterCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||
"""
|
||||
Create a counter (for the admins)
|
||||
@ -615,6 +632,7 @@ class CounterCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||
template_name = 'core/create.jinja'
|
||||
current_tab = "counters"
|
||||
|
||||
|
||||
class CounterDeleteView(CounterAdminTabsMixin, CounterAdminMixin, DeleteView):
|
||||
"""
|
||||
Delete a counter (for the admins)
|
||||
@ -627,6 +645,7 @@ class CounterDeleteView(CounterAdminTabsMixin, CounterAdminMixin, DeleteView):
|
||||
|
||||
# Product management
|
||||
|
||||
|
||||
class ProductTypeListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||
"""
|
||||
A list view for the admins
|
||||
@ -635,6 +654,7 @@ class ProductTypeListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||
template_name = 'counter/producttype_list.jinja'
|
||||
current_tab = "product_types"
|
||||
|
||||
|
||||
class ProductTypeCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||
"""
|
||||
A create view for the admins
|
||||
@ -644,6 +664,7 @@ class ProductTypeCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView
|
||||
template_name = 'core/create.jinja'
|
||||
current_tab = "products"
|
||||
|
||||
|
||||
class ProductTypeEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
"""
|
||||
An edit view for the admins
|
||||
@ -654,6 +675,7 @@ class ProductTypeEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
pk_url_kwarg = "type_id"
|
||||
current_tab = "products"
|
||||
|
||||
|
||||
class ProductArchivedListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||
"""
|
||||
A list view for the admins
|
||||
@ -664,6 +686,7 @@ class ProductArchivedListView(CounterAdminTabsMixin, CounterAdminMixin, ListView
|
||||
ordering = ['name']
|
||||
current_tab = "archive"
|
||||
|
||||
|
||||
class ProductListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||
"""
|
||||
A list view for the admins
|
||||
@ -674,6 +697,7 @@ class ProductListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||
ordering = ['name']
|
||||
current_tab = "products"
|
||||
|
||||
|
||||
class ProductEditForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Product
|
||||
@ -702,6 +726,7 @@ class ProductEditForm(forms.ModelForm):
|
||||
c.save()
|
||||
return ret
|
||||
|
||||
|
||||
class ProductCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||
"""
|
||||
A create view for the admins
|
||||
@ -711,6 +736,7 @@ class ProductCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||
template_name = 'core/create.jinja'
|
||||
current_tab = "products"
|
||||
|
||||
|
||||
class ProductEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
"""
|
||||
An edit view for the admins
|
||||
@ -721,6 +747,7 @@ class ProductEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
template_name = 'core/edit.jinja'
|
||||
current_tab = "products"
|
||||
|
||||
|
||||
class RefillingDeleteView(DeleteView):
|
||||
"""
|
||||
Delete a refilling (for the admins)
|
||||
@ -745,6 +772,7 @@ class RefillingDeleteView(DeleteView):
|
||||
return super(RefillingDeleteView, self).dispatch(request, *args, **kwargs)
|
||||
raise PermissionDenied
|
||||
|
||||
|
||||
class SellingDeleteView(DeleteView):
|
||||
"""
|
||||
Delete a selling (for the admins)
|
||||
@ -771,6 +799,7 @@ class SellingDeleteView(DeleteView):
|
||||
|
||||
# Cash register summaries
|
||||
|
||||
|
||||
class CashRegisterSummaryForm(forms.Form):
|
||||
"""
|
||||
Provide the cash summary form
|
||||
@ -839,30 +868,46 @@ class CashRegisterSummaryForm(forms.Form):
|
||||
summary.save()
|
||||
summary.items.all().delete()
|
||||
# Cash
|
||||
if cd['ten_cents']: CashRegisterSummaryItem(cash_summary=summary, value=0.1, quantity=cd['ten_cents']).save()
|
||||
if cd['twenty_cents']: CashRegisterSummaryItem(cash_summary=summary, value=0.2, quantity=cd['twenty_cents']).save()
|
||||
if cd['fifty_cents']: CashRegisterSummaryItem(cash_summary=summary, value=0.5, quantity=cd['fifty_cents']).save()
|
||||
if cd['one_euro']: CashRegisterSummaryItem(cash_summary=summary, value=1, quantity=cd['one_euro']).save()
|
||||
if cd['two_euros']: CashRegisterSummaryItem(cash_summary=summary, value=2, quantity=cd['two_euros']).save()
|
||||
if cd['five_euros']: CashRegisterSummaryItem(cash_summary=summary, value=5, quantity=cd['five_euros']).save()
|
||||
if cd['ten_euros']: CashRegisterSummaryItem(cash_summary=summary, value=10, quantity=cd['ten_euros']).save()
|
||||
if cd['twenty_euros']: CashRegisterSummaryItem(cash_summary=summary, value=20, quantity=cd['twenty_euros']).save()
|
||||
if cd['fifty_euros']: CashRegisterSummaryItem(cash_summary=summary, value=50, quantity=cd['fifty_euros']).save()
|
||||
if cd['hundred_euros']: CashRegisterSummaryItem(cash_summary=summary, value=100, quantity=cd['hundred_euros']).save()
|
||||
if cd['ten_cents']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=0.1, quantity=cd['ten_cents']).save()
|
||||
if cd['twenty_cents']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=0.2, quantity=cd['twenty_cents']).save()
|
||||
if cd['fifty_cents']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=0.5, quantity=cd['fifty_cents']).save()
|
||||
if cd['one_euro']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=1, quantity=cd['one_euro']).save()
|
||||
if cd['two_euros']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=2, quantity=cd['two_euros']).save()
|
||||
if cd['five_euros']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=5, quantity=cd['five_euros']).save()
|
||||
if cd['ten_euros']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=10, quantity=cd['ten_euros']).save()
|
||||
if cd['twenty_euros']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=20, quantity=cd['twenty_euros']).save()
|
||||
if cd['fifty_euros']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=50, quantity=cd['fifty_euros']).save()
|
||||
if cd['hundred_euros']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=100, quantity=cd['hundred_euros']).save()
|
||||
# Checks
|
||||
if cd['check_1_quantity']: CashRegisterSummaryItem(cash_summary=summary, value=cd['check_1_value'],
|
||||
if cd['check_1_quantity']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=cd['check_1_value'],
|
||||
quantity=cd['check_1_quantity'], check=True).save()
|
||||
if cd['check_2_quantity']: CashRegisterSummaryItem(cash_summary=summary, value=cd['check_2_value'],
|
||||
if cd['check_2_quantity']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=cd['check_2_value'],
|
||||
quantity=cd['check_2_quantity'], check=True).save()
|
||||
if cd['check_3_quantity']: CashRegisterSummaryItem(cash_summary=summary, value=cd['check_3_value'],
|
||||
if cd['check_3_quantity']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=cd['check_3_value'],
|
||||
quantity=cd['check_3_quantity'], check=True).save()
|
||||
if cd['check_4_quantity']: CashRegisterSummaryItem(cash_summary=summary, value=cd['check_4_value'],
|
||||
if cd['check_4_quantity']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=cd['check_4_value'],
|
||||
quantity=cd['check_4_quantity'], check=True).save()
|
||||
if cd['check_5_quantity']: CashRegisterSummaryItem(cash_summary=summary, value=cd['check_5_value'],
|
||||
if cd['check_5_quantity']:
|
||||
CashRegisterSummaryItem(cash_summary=summary, value=cd['check_5_value'],
|
||||
quantity=cd['check_5_quantity'], check=True).save()
|
||||
if summary.items.count() < 1:
|
||||
summary.delete()
|
||||
|
||||
|
||||
class CounterLastOperationsView(CounterTabsMixin, CanViewMixin, DetailView):
|
||||
"""
|
||||
Provide the last operations to allow barmen to delete them
|
||||
@ -891,6 +936,7 @@ class CounterLastOperationsView(CounterTabsMixin, CanViewMixin, DetailView):
|
||||
kwargs['last_sellings'] = self.object.sellings.filter(date__gte=threshold).order_by('-id')[:20]
|
||||
return kwargs
|
||||
|
||||
|
||||
class CounterCashSummaryView(CounterTabsMixin, CanViewMixin, DetailView):
|
||||
"""
|
||||
Provide the cash summary form
|
||||
@ -933,6 +979,7 @@ class CounterCashSummaryView(CounterTabsMixin, CanViewMixin, DetailView):
|
||||
kwargs['form'] = self.form
|
||||
return kwargs
|
||||
|
||||
|
||||
class CounterActivityView(DetailView):
|
||||
"""
|
||||
Show the bar activity
|
||||
@ -941,6 +988,7 @@ class CounterActivityView(DetailView):
|
||||
pk_url_kwarg = "counter_id"
|
||||
template_name = 'counter/activity.jinja'
|
||||
|
||||
|
||||
class CounterStatView(DetailView, CounterAdminMixin):
|
||||
"""
|
||||
Show the bar stats
|
||||
@ -1003,6 +1051,7 @@ class CounterStatView(DetailView, CounterAdminMixin):
|
||||
return super(CanEditMixin, self).dispatch(request, *args, **kwargs)
|
||||
raise PermissionDenied
|
||||
|
||||
|
||||
class CashSummaryEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
"""Edit cash summaries"""
|
||||
model = CashRegisterSummary
|
||||
@ -1015,10 +1064,12 @@ class CashSummaryEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView)
|
||||
def get_success_url(self):
|
||||
return reverse('counter:cash_summary_list')
|
||||
|
||||
|
||||
class CashSummaryFormBase(forms.Form):
|
||||
begin_date = forms.DateTimeField(['%Y-%m-%d %H:%M:%S'], label=_("Begin date"), required=False, widget=SelectDateTime)
|
||||
end_date = forms.DateTimeField(['%Y-%m-%d %H:%M:%S'], label=_("End date"), required=False, widget=SelectDateTime)
|
||||
|
||||
|
||||
class CashSummaryListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||
"""Display a list of cash summaries"""
|
||||
model = CashRegisterSummary
|
||||
@ -1056,6 +1107,7 @@ class CashSummaryListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||
kwargs['refilling_sums'][c.name] = sum([s.amount for s in refillings.all()])
|
||||
return kwargs
|
||||
|
||||
|
||||
class InvoiceCallView(CounterAdminTabsMixin, CounterAdminMixin, TemplateView):
|
||||
template_name = 'counter/invoices_call.jinja'
|
||||
current_tab = 'invoices_call'
|
||||
@ -1087,6 +1139,7 @@ class InvoiceCallView(CounterAdminTabsMixin, CounterAdminMixin, TemplateView):
|
||||
)).exclude(selling_sum=None).order_by('-selling_sum')
|
||||
return kwargs
|
||||
|
||||
|
||||
class EticketListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||
"""
|
||||
A list view for the admins
|
||||
@ -1096,6 +1149,7 @@ class EticketListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
|
||||
ordering = ['id']
|
||||
current_tab = "etickets"
|
||||
|
||||
|
||||
class EticketForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Eticket
|
||||
@ -1105,6 +1159,7 @@ class EticketForm(forms.ModelForm):
|
||||
}
|
||||
product = AutoCompleteSelectField('products', show_help_text=False, label=_("Product"), required=True)
|
||||
|
||||
|
||||
class EticketCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||
"""
|
||||
Create an eticket
|
||||
@ -1114,6 +1169,7 @@ class EticketCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView):
|
||||
form_class = EticketForm
|
||||
current_tab = "etickets"
|
||||
|
||||
|
||||
class EticketEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
"""
|
||||
Edit an eticket
|
||||
@ -1124,6 +1180,7 @@ class EticketEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
|
||||
pk_url_kwarg = "eticket_id"
|
||||
current_tab = "etickets"
|
||||
|
||||
|
||||
class EticketPDFView(CanViewMixin, DetailView):
|
||||
"""
|
||||
Display the PDF of an eticket
|
||||
@ -1195,4 +1252,3 @@ class EticketPDFView(CanViewMixin, DetailView):
|
||||
p.showPage()
|
||||
p.save()
|
||||
return response
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user