From e231c612c635e7b1410944749061fb3b86dfe49d Mon Sep 17 00:00:00 2001 From: klmp200 Date: Tue, 6 Dec 2016 23:04:41 +0100 Subject: [PATCH 1/2] Separate counter for account refounding --- accounting/views.py | 8 ++++---- core/management/commands/populate.py | 5 ++++- core/templates/core/user_tools.jinja | 2 ++ sith/settings.py | 4 ++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/accounting/views.py b/accounting/views.py index 5b1bf6d1..73c7f744 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -19,7 +19,7 @@ from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultip from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin from core.views.forms import SelectFile, SelectDate from accounting.models import BankAccount, ClubAccount, GeneralJournal, Operation, AccountingType, Company, SimplifiedAccountingType, Label -from counter.models import Counter, Selling +from counter.models import Counter, Selling, Product # Main accounting view @@ -524,11 +524,11 @@ class RefoundAccountView(FormView): def create_selling(self): with transaction.atomic(): uprice = self.customer.customer.amount - main_club_counter = Counter.objects.filter(club__unix_name=settings.SITH_MAIN_CLUB['unix_name'], - type='OFFICE').first() + main_club_counter = Counter.objects.get(name=settings.SITH_COUNTER_REFOUND[1]) main_club = main_club_counter.club s = Selling(label=_('Refound account'), unit_price=uprice, quantity=1, seller=self.operator, customer=self.customer.customer, - club=main_club, counter=main_club_counter) + club=main_club, counter=main_club_counter, + product=Product.objects.get(code=settings.SITH_COUNTER_REFOUND_PRODUCT[1])) s.save() diff --git a/core/management/commands/populate.py b/core/management/commands/populate.py index 1c49e06e..52e00611 100644 --- a/core/management/commands/populate.py +++ b/core/management/commands/populate.py @@ -74,6 +74,7 @@ class Command(BaseCommand): self.reset_index("counter") Counter(name="Eboutic", club=main_club, type='EBOUTIC').save() Counter(name="AE", club=main_club, type='OFFICE').save() + Counter(name=settings.SITH_COUNTER_REFOUND[1], club=main_club, type='OFFICE').save() home_root.view_groups = [Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first()] club_root.view_groups = [Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first()] @@ -273,6 +274,9 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site. mde.products.add(barb) mde.products.add(cble) mde.save() + refound = Product(name=settings.SITH_COUNTER_REFOUND_PRODUCT[2], code=settings.SITH_COUNTER_REFOUND_PRODUCT[1], purchase_price="0", selling_price="0", + special_selling_price="0", club=main_club) + refound.save() # Accounting test values: BankAccount(name="AE TG", club=main_club).save() @@ -295,4 +299,3 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site. target_id=bar_club.id).save() woenzco = Company(name="Woenzel & co") woenzco.save() - diff --git a/core/templates/core/user_tools.jinja b/core/templates/core/user_tools.jinja index 7fc227d0..46e5f122 100644 --- a/core/templates/core/user_tools.jinja +++ b/core/templates/core/user_tools.jinja @@ -29,6 +29,8 @@
  • {% trans %}Products management{% endtrans %}
  • {% trans %}Product types management{% endtrans %}
  • {% trans %}Cash register summaries{% endtrans %}
  • +
  • {% trans %}Invoices call{% endtrans %}
  • +
  • {% trans %}Etickets{% endtrans %}
  • {% endif %} {% for b in settings.SITH_COUNTER_BARS %} {% if user.is_in_group(b[1]+" admin") %} diff --git a/sith/settings.py b/sith/settings.py index 356c7124..c9be5609 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -313,6 +313,10 @@ SITH_COUNTER_BANK = [ ('LA-POSTE', 'La Poste'), ] +SITH_COUNTER_REFOUND = (88, 'Carte AE') + +SITH_COUNTER_REFOUND_PRODUCT = (1899, 'REMBOURS', 'Remboursement') + # Defines which product type is the refilling type, and thus increases the account amount SITH_COUNTER_PRODUCTTYPE_REFILLING = 11 From 7227a5d6f94cacd0492a17c2ad6cd057fd8b802b Mon Sep 17 00:00:00 2001 From: klmp200 Date: Thu, 15 Dec 2016 12:17:19 +0100 Subject: [PATCH 2/2] Refactor refounding function --- accounting/views.py | 20 ++++++++++---------- core/management/commands/populate.py | 13 +++++++++---- sith/settings.py | 9 +++++---- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/accounting/views.py b/accounting/views.py index 73c7f744..1ac65e3f 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -367,11 +367,11 @@ class OperationPDFView(CanViewMixin, DetailView): im = ImageReader("core/static/core/img/logo.jpg") iw, ih = im.getSize() p.drawImage(im, 40, height - 50, width=iw/2, height=ih/2) - + labelStr = [["%s %s - %s %s" % (_("Journal"), ti, _("Operation"), num)]] label = Table(labelStr, colWidths=[150], rowHeights=[20]) - + label.setStyle(TableStyle([ ('ALIGN',(0,0),(-1,-1),'CENTER'), ('BOX', (0,0), (-1,-1), 0.25, colors.black), @@ -384,11 +384,11 @@ class OperationPDFView(CanViewMixin, DetailView): p.drawString(90, height - 160, _("Label: %(op_label)s") % {"op_label": op_label if op_label != None else ""}) data = [] - + data += [["%s" % (_("Credit").upper() if nature == 'CREDIT' else _("Debit").upper())]] data += [[_("Amount: %(amount).2f €") % {"amount": amount}]] - + payment_mode = "" for m in settings.SITH_ACCOUNTING_PAYMENT_METHOD: if m[0] == mode: @@ -398,11 +398,11 @@ class OperationPDFView(CanViewMixin, DetailView): payment_mode += " %s\n" %(m[1]) data += [[payment_mode]] - + data += [["%s : %s" % (_("Debtor") if nature == 'CREDIT' else _("Creditor"), target), ""]] data += [["%s \n%s" % (_("Comment:"), remark)]] - + t = Table(data, colWidths=[(width-90*2)/2]*2, rowHeights=[20, 20, 70, 20, 80]) t.setStyle(TableStyle([ ('ALIGN',(0,0),(-1,-1),'CENTER'), @@ -524,11 +524,11 @@ class RefoundAccountView(FormView): def create_selling(self): with transaction.atomic(): uprice = self.customer.customer.amount - main_club_counter = Counter.objects.get(name=settings.SITH_COUNTER_REFOUND[1]) - main_club = main_club_counter.club + refound_club_counter = Counter.objects.get(id=settings.SITH_COUNTER_REFOUND_ID) + refound_club = refound_club_counter.club s = Selling(label=_('Refound account'), unit_price=uprice, quantity=1, seller=self.operator, customer=self.customer.customer, - club=main_club, counter=main_club_counter, - product=Product.objects.get(code=settings.SITH_COUNTER_REFOUND_PRODUCT[1])) + club=refound_club, counter=refound_club_counter, + product=Product.objects.get(id=settings.SITH_PRODUCT_REFOUND_ID)) s.save() diff --git a/core/management/commands/populate.py b/core/management/commands/populate.py index 52e00611..3a3bb1ca 100644 --- a/core/management/commands/populate.py +++ b/core/management/commands/populate.py @@ -74,7 +74,6 @@ class Command(BaseCommand): self.reset_index("counter") Counter(name="Eboutic", club=main_club, type='EBOUTIC').save() Counter(name="AE", club=main_club, type='OFFICE').save() - Counter(name=settings.SITH_COUNTER_REFOUND[1], club=main_club, type='OFFICE').save() home_root.view_groups = [Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first()] club_root.view_groups = [Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first()] @@ -254,6 +253,9 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site. troll = Club(name="Troll Penché", unix_name="troll", address="Terre Du Milieu", parent=main_club) troll.save() + refound = Club(name="Carte AE", unix_name="carte_ae", + address="Jamais imprimée", parent=main_club) + refound.save() # Counters Customer(user=skia, account_id="6568j", amount=0).save() @@ -274,9 +276,12 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site. mde.products.add(barb) mde.products.add(cble) mde.save() - refound = Product(name=settings.SITH_COUNTER_REFOUND_PRODUCT[2], code=settings.SITH_COUNTER_REFOUND_PRODUCT[1], purchase_price="0", selling_price="0", - special_selling_price="0", club=main_club) - refound.save() + + refound_counter = Counter(name="Carte AE", club=refound, type='OFFICE') + refound_counter.save() + refound_product = Product(name="remboursement", code="REMBOURS", purchase_price="0", selling_price="0", + special_selling_price="0", club=refound) + refound_product.save() # Accounting test values: BankAccount(name="AE TG", club=main_club).save() diff --git a/sith/settings.py b/sith/settings.py index c9be5609..d33c939e 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -257,6 +257,11 @@ SITH_GROUP_BANNED_COUNTER_ID = 7 SITH_GROUP_BANNED_SUBSCRIPTION_ID = 8 SITH_GROUP_SAS_ADMIN_ID = 9 +SITH_CLUB_REFOUND_ID = 89 +SITH_COUNTER_REFOUND_ID = 38 +SITH_PRODUCT_REFOUND_ID = 5 + + # SAS variables SITH_SAS_ROOT_DIR_ID = 4 @@ -313,10 +318,6 @@ SITH_COUNTER_BANK = [ ('LA-POSTE', 'La Poste'), ] -SITH_COUNTER_REFOUND = (88, 'Carte AE') - -SITH_COUNTER_REFOUND_PRODUCT = (1899, 'REMBOURS', 'Remboursement') - # Defines which product type is the refilling type, and thus increases the account amount SITH_COUNTER_PRODUCTTYPE_REFILLING = 11