Fabs 11 years ago
parent
commit
721fcfab20
4 changed files with 26 additions and 20 deletions
  1. 10 4
      coin/billing/admin.py
  2. 2 1
      coin/billing/models.py
  3. 5 3
      coin/billing/process_latex.py
  4. 9 12
      coin/billing/views.py

+ 10 - 4
coin/billing/admin.py

@@ -7,17 +7,23 @@ import autocomplete_light
 class InvoiceDetailInline(admin.StackedInline):
     model = InvoiceDetail
     extra = 0
-    fields = (('label','amount','quantity','tax','offer'),)
+    fields = (('label', 'amount', 'quantity', 'tax', 'offer'),)
 
 
 class PaymentInline(admin.StackedInline):
     model = Payment
     extra = 0
-    fields = (('date','payment_mean','amount'),)
+    fields = (('date', 'payment_mean', 'amount'),)
 
 
 class InvoiceAdmin(admin.ModelAdmin):
-    inlines = [InvoiceDetailInline, PaymentInline]
+	list_display = ('number', 'date', 'status', 'amount', 'member')
+	list_display_links = ('number', 'date')
+	inlines = [InvoiceDetailInline, PaymentInline]
+	fields = (('number', 'date', 'status'),
+			  ('period_from', 'period_to', 'date_due'),
+			  'member')
+	form = autocomplete_light.modelform_factory(Invoice)
 
 
-admin.site.register(Invoice,InvoiceAdmin)
+admin.site.register(Invoice, InvoiceAdmin)

+ 2 - 1
coin/billing/models.py

@@ -5,6 +5,7 @@ from django.db import models
 from coin.offers.models import Offer
 from coin.members.models import Member
 
+
 class Invoice(models.Model):
 
     INVOICES_STATUS_CHOICES = (
@@ -39,7 +40,7 @@ class Invoice(models.Model):
         null=True,
         verbose_name=u'Date d\'échéance de paiement')
     member = models.ForeignKey(Member, null=True, blank=True, default=None,
-        verbose_name='Membre')
+                               verbose_name='Membre')
 
     def __unicode__(self):
         return u'#%s %s€ %s' % (self.number, self.amount, self.date_due)

+ 5 - 3
coin/billing/process_latex.py

@@ -6,6 +6,7 @@ from tempfile import NamedTemporaryFile
 from django.template import loader, Context
 from django.conf import settings
 
+
 def process_latex(template, context={}, type='pdf', outfile=None):
     """
     Processes a template as a LaTeX source file.
@@ -31,7 +32,7 @@ def process_latex(template, context={}, type='pdf', outfile=None):
         pdflatex(base, 'dvi')
         call(['dvipng', '-bg', '-transparent',
               names['dvi'], '-o', names['png']],
-              cwd=dirname(base), stdout=PIPE, stderr=PIPE)
+             cwd=dirname(base), stdout=PIPE, stderr=PIPE)
 
     remove(names['log'])
     remove(names['aux'])
@@ -43,7 +44,8 @@ def process_latex(template, context={}, type='pdf', outfile=None):
     else:
         rename(output, outfile)
 
+
 def pdflatex(file, type='pdf'):
     call([settings.PDFLATEX_PATH, '-interaction=nonstopmode',
-                      '-output-format', type, file],
-         cwd=dirname(file), stdout=PIPE, stderr=PIPE)
+          '-output-format', type, file],
+         cwd=dirname(file), stdout=PIPE, stderr=PIPE)

+ 9 - 12
coin/billing/views.py

@@ -1,16 +1,13 @@
 # -*- coding: utf-8 -*-
 from django.http import HttpResponse
-# from django.template import Context, loader
-from django.shortcuts import render #, get_object_or_404
-#from django.http import Http404
-#from coin.members.models import Member
+from django.shortcuts import render, get_object_or_404
 from coin.billing.process_latex import process_latex
-from django.shortcuts import get_object_or_404
 from coin.billing.models import Invoice
 
+
 def pdf_test(request):
 
-    context = {"blop":"COIN !"}
+    context = {"blop": "COIN !"}
 
     response = HttpResponse(content_type='application/pdf')
     response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"'
@@ -20,10 +17,10 @@ def pdf_test(request):
 
 def invoice_pdf(request, pk):
 
-	invoice = get_object_or_404(Invoice, pk=1)
-	context = {"invoice":invoice}
+    invoice = get_object_or_404(Invoice, pk=1)
+    context = {"invoice": invoice}
 
-	response = HttpResponse(content_type='application/pdf')
-	response['Content-Disposition'] = 'attachment; filename="facture.pdf"'
-	response.write(process_latex('billing/invoice.tex', context))
-	return response
+    response = HttpResponse(content_type='application/pdf')
+    response['Content-Disposition'] = 'attachment; filename="facture.pdf"'
+    response.write(process_latex('billing/invoice.tex', context))
+    return response