From 60ad6efa3fe2c1a7a67d186a9506cf3d38e6b4be Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Fri, 8 Jul 2016 03:27:02 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9e=20des=20listes=20de=20moyens=20de=20p?= =?UTF-8?q?aiement,=20banque,=20et=20articles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/cotisations/aff_article.html | 21 +++ .../templates/cotisations/aff_banque.html | 15 +++ .../templates/cotisations/aff_paiement.html | 15 +++ .../templates/cotisations/factures.tex | 124 ++++++++++++++++++ .../templates/cotisations/index_article.html | 15 +++ .../templates/cotisations/index_banque.html | 15 +++ .../templates/cotisations/index_paiement.html | 15 +++ .../templates/cotisations/sidebar.html | 9 +- cotisations/urls.py | 7 + cotisations/views.py | 69 +++++++++- 10 files changed, 292 insertions(+), 13 deletions(-) create mode 100644 cotisations/templates/cotisations/aff_article.html create mode 100644 cotisations/templates/cotisations/aff_banque.html create mode 100644 cotisations/templates/cotisations/aff_paiement.html create mode 100644 cotisations/templates/cotisations/factures.tex create mode 100644 cotisations/templates/cotisations/index_article.html create mode 100644 cotisations/templates/cotisations/index_banque.html create mode 100644 cotisations/templates/cotisations/index_paiement.html diff --git a/cotisations/templates/cotisations/aff_article.html b/cotisations/templates/cotisations/aff_article.html new file mode 100644 index 00000000..d39bc312 --- /dev/null +++ b/cotisations/templates/cotisations/aff_article.html @@ -0,0 +1,21 @@ + + + + + + + + + + + {% for article in article_list %} + + + + + + + + {% endfor %} +
Nom de l'articlePrixCotisationDurée (en mois)
{{ article.name }}{{ article.prix }}{{ article.cotisation }}{{ article.duration }} Editer
+ diff --git a/cotisations/templates/cotisations/aff_banque.html b/cotisations/templates/cotisations/aff_banque.html new file mode 100644 index 00000000..4db16bdd --- /dev/null +++ b/cotisations/templates/cotisations/aff_banque.html @@ -0,0 +1,15 @@ + + + + + + + + {% for banque in banque_list %} + + + + + {% endfor %} +
Banque
{{ banque.name }} Editer
+ diff --git a/cotisations/templates/cotisations/aff_paiement.html b/cotisations/templates/cotisations/aff_paiement.html new file mode 100644 index 00000000..1bfec970 --- /dev/null +++ b/cotisations/templates/cotisations/aff_paiement.html @@ -0,0 +1,15 @@ + + + + + + + + {% for paiement in paiement_list %} + + + + + {% endfor %} +
Moyen de paiement
{{ paiement.moyen }} Editer
+ diff --git a/cotisations/templates/cotisations/factures.tex b/cotisations/templates/cotisations/factures.tex new file mode 100644 index 00000000..d4fe7aee --- /dev/null +++ b/cotisations/templates/cotisations/factures.tex @@ -0,0 +1,124 @@ +{% load i18n %} +{% language 'fr' %} +\nonstopmode +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Invoice Template +% LaTeX Template +% Version 1.0 (3/11/12) +% +% This template has been downloaded from: +% http://www.LaTeXTemplates.com +% +% Original author: +% Trey Hunner (http://www.treyhunner.com/) +% +% License: +% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/) +% +% Important note: +% This template requires the invoice.cls file to be in the same directory as +% the .tex file. The invoice.cls file provides the style used for structuring the +% document. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%---------------------------------------------------------------------------------------- +% DOCUMENT CONFIGURATION +%---------------------------------------------------------------------------------------- + +\documentclass[12pt]{article} % Use the custom invoice class (invoice.cls) +\usepackage[utf8]{inputenc} +\usepackage[frenchb]{babel} +\usepackage{eurosym} +\usepackage{tabularx} +\usepackage[letterpaper,hmargin=0.79in,vmargin=0.79in]{geometry} +\usepackage[parfill]{parskip} % Do not indent paragraphs +\usepackage{fp} % Fixed-point arithmetic +\usepackage{calc} % Counters for totaling hours and cost +\usepackage{longtable} +\usepackage{graphicx} +\usepackage[absolute]{textpos} +\usepackage{calc} +\usepackage{xparse} + +\pagestyle{empty} % No page numbers +\linespread{1.5} % Line spacing + +\setlength{\doublerulesep}{\arrayrulewidth} % Double rules look like one thick one +\def \tab {\hspace*{3ex}} % Define \tab to create some horizontal white space + + + + +\begin{document} +%\newcommand{\product}[5][0][0][0][0][0]{ +%\setlength{ptotal}{#3*\real{#4}} +%\addtolength{total}{#3*\real{#4}} +\DeclareDocumentCommand{\product}{ O{0} O{0} O{0} O{0} O{0} }{ +#1 & #2 & #3 & #4 & #5 \\ +\hline +} + +%---------------------------------------------------------------------------------------- +% HEADING SECTION +%---------------------------------------------------------------------------------------- +\begin{titlepage} +\begin{textblock*}{4cm}(20mm,5mm) +%\includegraphics[scale=0.3]{% templatetag openbrace %}{{tpl_path}}/logo.png} +\end{textblock*} +\end{titlepage} +\hfil{\Huge\bf ReZo Metz}\hfil % Company providing the invoice +\bigskip\break % Whitespace +\hrule % Horizontal line +2 rue Edouard Belin \\ % Your address and contact information +57070 Metz \hfill augustin.lemesle@supelec.fr \\ +Siret : +\\ \\ +{\bf À :} \tab {{f.user.name}} {{f.user.surname}} \\ % Invoice recipient + +{\bf Date:} \tab {{DATE}} \\ % Invoice date + +{\bf Facture \no:} \tab {{fid}} \\ % Invoice number + +%---------------------------------------------------------------------------------------- +% TABLE OF EXPENSES +%---------------------------------------------------------------------------------------- + + +\begin{tabularx}{\textwidth}{|l|X|r|r|r|} +\hline + \textbf{Code} & \textbf{Désignation} & \textbf{Qté.} & \textbf{Prix Unit.} \euro & \textbf{Prix Tot.} \euro\\ +\hline + +{% for a in f.article %} +\product[{{a.code}}][{{a.designation}}][{{a.nombre}}][{{a.pu|floatformat:2}}][{{a.ptotal|floatformat:2}}] +{% endfor %} + + \hline +\end{tabularx} + +%\setcounter{paid}{0} +%\setcounter{topay}{\real{\value{total}}-\value{paid}} + +\hfill +\begin{tabular}{|l|r|} +\hline +\textbf{Total} & {{total|floatformat:2}}\euro \\ +\textbf{Votre règlement} & {{paid|floatformat:2}}\euro \\ +\hline +\textbf{À PAYER} & {{topay|floatformat:2}}\euro \\ +\hline +\hline + +\end{tabular} + +\vspace{1.5cm} % Whitespace +\hrule % Horizontal line +\footnotesize{TVA non applicable, art. 293 B du CGI} + +{% endlanguage %} +%---------------------------------------------------------------------------------------- + +\end{document} + + diff --git a/cotisations/templates/cotisations/index_article.html b/cotisations/templates/cotisations/index_article.html new file mode 100644 index 00000000..0f3011a5 --- /dev/null +++ b/cotisations/templates/cotisations/index_article.html @@ -0,0 +1,15 @@ +{% extends "cotisations/sidebar.html" %} +{% load bootstrap3 %} + +{% block title %}Articles{% endblock %} + +{% block content %} +

Liste des types d'articles

+ Ajouter un type d'articles + Supprimer un ou plusieurs types d'articles + {% include "cotisations/aff_article.html" with article_list=article_list %} +
+
+
+{% endblock %} + diff --git a/cotisations/templates/cotisations/index_banque.html b/cotisations/templates/cotisations/index_banque.html new file mode 100644 index 00000000..cad36320 --- /dev/null +++ b/cotisations/templates/cotisations/index_banque.html @@ -0,0 +1,15 @@ +{% extends "cotisations/sidebar.html" %} +{% load bootstrap3 %} + +{% block title %}Banques{% endblock %} + +{% block content %} +

Liste des banques

+ Ajouter une banque + Supprimer une ou plusieurs banques + {% include "cotisations/aff_banque.html" with banque_list=banque_list %} +
+
+
+{% endblock %} + diff --git a/cotisations/templates/cotisations/index_paiement.html b/cotisations/templates/cotisations/index_paiement.html new file mode 100644 index 00000000..5163165e --- /dev/null +++ b/cotisations/templates/cotisations/index_paiement.html @@ -0,0 +1,15 @@ +{% extends "cotisations/sidebar.html" %} +{% load bootstrap3 %} + +{% block title %}Paiements{% endblock %} + +{% block content %} +

Liste des types de paiements

+ Ajouter un type de paiement + Supprimer un ou plusieurs types de paiements + {% include "cotisations/aff_paiement.html" with paiement_list=paiement_list %} +
+
+
+{% endblock %} + diff --git a/cotisations/templates/cotisations/sidebar.html b/cotisations/templates/cotisations/sidebar.html index be622d09..e34d045b 100644 --- a/cotisations/templates/cotisations/sidebar.html +++ b/cotisations/templates/cotisations/sidebar.html @@ -2,10 +2,7 @@ {% block sidebar %}

Liste des factures

-

Ajouter un article

-

Retirer un article

-

Ajouter un moyen de paiement

-

Retirer un moyen de paiement

-

Ajouter une banque

-

Retirer une banque

+

Liste des articles en vente

+

Liste des banques

+

Liste des moyens de paiement

{% endblock %} diff --git a/cotisations/urls.py b/cotisations/urls.py index fca9c331..56d090e2 100644 --- a/cotisations/urls.py +++ b/cotisations/urls.py @@ -5,12 +5,19 @@ from . import views urlpatterns = [ url(r'^new_facture/(?P[0-9]+)$', views.new_facture, name='new-facture'), url(r'^edit_facture/(?P[0-9]+)$', views.edit_facture, name='edit-facture'), + url(r'^new_facture_pdf/$', views.new_facture_pdf, name='new-facture-pdf'), url(r'^add_article/$', views.add_article, name='add-article'), + url(r'^edit_article/(?P[0-9]+)$', views.edit_article, name='edit-article'), url(r'^del_article/$', views.del_article, name='del-article'), url(r'^add_paiement/$', views.add_paiement, name='add-paiement'), + url(r'^edit_paiement/(?P[0-9]+)$', views.edit_paiement, name='edit-paiement'), url(r'^del_paiement/$', views.del_paiement, name='del-paiement'), url(r'^add_banque/$', views.add_banque, name='add-banque'), + url(r'^edit_banque/(?P[0-9]+)$', views.edit_banque, name='edit-banque'), url(r'^del_banque/$', views.del_banque, name='del-banque'), + url(r'^index_article/$', views.index_article, name='index-article'), + url(r'^index_banque/$', views.index_banque, name='index-banque'), + url(r'^index_paiement/$', views.index_paiement, name='index-paiement'), url(r'^$', views.index, name='index'), ] diff --git a/cotisations/views.py b/cotisations/views.py index 31ebaddc..eac23d25 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -8,9 +8,10 @@ from django.template import Context, RequestContext, loader from django.contrib import messages from django.db.models import Max, ProtectedError -from .models import Facture, Article, Cotisation, Article +from .models import Facture, Article, Cotisation, Paiement, Banque from .forms import NewFactureForm, EditFactureForm, ArticleForm, DelArticleForm, PaiementForm, DelPaiementForm, BanqueForm, DelBanqueForm from users.models import User +from .tex import render_tex from dateutil.relativedelta import relativedelta from django.utils import timezone @@ -69,6 +70,9 @@ def new_facture(request, userid): return redirect("/users/profil/" + userid) return form({'factureform': facture_form}, 'cotisations/facture.html', request) +def new_facture_pdf(request): + return render_tex(request, 'cotisations/factures.tex', {'DATE':None}) + def edit_facture(request, factureid): try: facture = Facture.objects.get(pk=factureid) @@ -87,7 +91,20 @@ def add_article(request): if article.is_valid(): article.save() messages.success(request, "L'article a été ajouté") - return redirect("/cotisations/") + return redirect("/cotisations/index_article/") + return form({'factureform': article}, 'cotisations/facture.html', request) + +def edit_article(request, articleid): + try: + article_instance = Article.objects.get(pk=articleid) + except Article.DoesNotExist: + messages.error(request, u"Entrée inexistante" ) + return redirect("/cotisations/index_article/") + article = ArticleForm(request.POST or None, instance=article_instance) + if article.is_valid(): + article.save() + messages.success(request, "Type d'article modifié") + return redirect("/cotisations/index_article/") return form({'factureform': article}, 'cotisations/facture.html', request) def del_article(request): @@ -96,7 +113,7 @@ def del_article(request): article_del = article.cleaned_data['articles'] article_del.delete() messages.success(request, "Le/les articles ont été supprimé") - return redirect("/cotisations/") + return redirect("/cotisations/index_article") return form({'factureform': article}, 'cotisations/facture.html', request) def add_paiement(request): @@ -104,7 +121,20 @@ def add_paiement(request): if paiement.is_valid(): paiement.save() messages.success(request, "Le moyen de paiement a été ajouté") - return redirect("/cotisations/") + return redirect("/cotisations/index_paiement/") + return form({'factureform': paiement}, 'cotisations/facture.html', request) + +def edit_paiement(request, paiementid): + try: + paiement_instance = Paiement.objects.get(pk=paiementid) + except Paiement.DoesNotExist: + messages.error(request, u"Entrée inexistante" ) + return redirect("/cotisations/index_paiement/") + paiement = PaiementForm(request.POST or None, instance=paiement_instance) + if paiement.is_valid(): + paiement.save() + messages.success(request, "Type de paiement modifié") + return redirect("/cotisations/index_paiement/") return form({'factureform': paiement}, 'cotisations/facture.html', request) def del_paiement(request): @@ -117,7 +147,7 @@ def del_paiement(request): messages.success(request, "Le moyen de paiement a été supprimé") except ProtectedError: messages.error(request, "Le moyen de paiement %s est affecté à au moins une facture, vous ne pouvez pas le supprimer" % paiement_del) - return redirect("/cotisations/") + return redirect("/cotisations/index_paiement/") return form({'factureform': paiement}, 'cotisations/facture.html', request) def add_banque(request): @@ -125,7 +155,20 @@ def add_banque(request): if banque.is_valid(): banque.save() messages.success(request, "La banque a été ajoutée") - return redirect("/cotisations/") + return redirect("/cotisations/index_banque/") + return form({'factureform': banque}, 'cotisations/facture.html', request) + +def edit_banque(request, banqueid): + try: + banque_instance = Article.objects.get(pk=banqueid) + except Banque.DoesNotExist: + messages.error(request, u"Entrée inexistante" ) + return redirect("/cotisations/index_banque/") + banque = BanqueForm(request.POST or None, instance=banque_instance) + if banque.is_valid(): + banque.save() + messages.success(request, "Banque modifiée") + return redirect("/cotisations/index_banque/") return form({'factureform': banque}, 'cotisations/facture.html', request) def del_banque(request): @@ -138,9 +181,21 @@ def del_banque(request): messages.success(request, "La banque a été supprimée") except ProtectedError: messages.error(request, "La banque %s est affectée à au moins une facture, vous ne pouvez pas la supprimer" % banque_del) - return redirect("/cotisations/") + return redirect("/cotisations/index_banque/") return form({'factureform': banque}, 'cotisations/facture.html', request) +def index_article(request): + article_list = Article.objects.order_by('name') + return render(request, 'cotisations/index_article.html', {'article_list':article_list}) + +def index_paiement(request): + paiement_list = Paiement.objects.order_by('moyen') + return render(request, 'cotisations/index_paiement.html', {'paiement_list':paiement_list}) + +def index_banque(request): + banque_list = Banque.objects.order_by('name') + return render(request, 'cotisations/index_banque.html', {'banque_list':banque_list}) + def index(request): facture_list = Facture.objects.order_by('date').reverse() return render(request, 'cotisations/index.html', {'facture_list': facture_list})