Commit c2f38c51 authored by Patrick's avatar Patrick

Work in progress

parent a9d38a99
......@@ -7,6 +7,7 @@ import sys
from django.apps import AppConfig
from django.conf import settings
from django.db import connection
from django.db.models import F
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
......@@ -67,8 +68,8 @@ class RepanierSettings(AppConfig):
db_started = connection.cursor() is not None
except:
time.sleep(1)
from models import Configuration, LUT_DepartmentForCustomer, Staff
from const import DECIMAL_ONE, PERMANENCE_NAME_PERMANENCE, EMPTY_STRING, CURRENCY_EUR, ORDER_GROUP, \
from models import Configuration, LUT_DepartmentForCustomer, Staff, Purchase
from const import DECIMAL_ONE, PERMANENCE_NAME_PERMANENCE, CURRENCY_EUR, ORDER_GROUP, \
INVOICE_GROUP, CONTRIBUTOR_GROUP, COORDINATION_GROUP, WEBMASTER_GROUP
try:
# Create if needed and load RepanierSettings var when performing config.save()
......@@ -88,6 +89,13 @@ class RepanierSettings(AppConfig):
currency=CURRENCY_EUR
)
config.save()
# Purchase.objects.filter(customer_charged__isnull=True).update(
# customer_charged=F('customer_invoice__customer_charged')
# )
for purchase in Purchase.objects.filter(
customer_charged__isnull=True).select_related("customer_invoice").order_by('?'):
purchase.customer_charged = purchase.customer_invoice.customer_charged
purchase.save(update_fields=["customer_charged",])
Staff.objects.rebuild()
# Create groups with correct rights
order_group = Group.objects.filter(name=ORDER_GROUP).only('id').order_by('?').first()
......
......@@ -326,7 +326,7 @@ def generate_invoice(permanence, payment_date):
permanence_id=permanence.id,
producer_id=producer_buyinggroup.id,
offer_item__order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE
).order_by('?').aggregate(Sum('selling_price')):
).order_by('?'):
# --> This bank movement is not a real entry
# making this, it will not be counted into the customer_buyinggroup movements twice
# because Repanier will see it has already been counted into the customer_buyinggroup movements
......@@ -337,7 +337,7 @@ def generate_invoice(permanence, payment_date):
operation_date=payment_date,
operation_status=BANK_MEMBERSHIP_FEE,
operation_comment="%s : %s" % (_("Membership fee"), membership_fee.customer),
bank_amount_in=membership_fee,
bank_amount_in=membership_fee.selling_price,
bank_amount_out=DECIMAL_ZERO,
customer_invoice_id=customer_invoice_buyinggroup.id,
producer_invoice=None
......@@ -650,7 +650,7 @@ def cancel_invoice(permanence):
]
).order_by('?').delete()
Permanence.objects.filter(
permanence_id=permanence.id
id=permanence.id
).update(invoice_sort_order=None)
permanence.set_status(PERMANENCE_SEND)
......
......@@ -132,8 +132,10 @@
<span class="glyphicon glyphicon-arrow-left"></span>
</a>
{% endif %}
{% if download_invoice %}
<a href="{% url 'download_customer_invoice' object.id %}"
class="btn btn-disabled"> {% trans "Download" %} <span class="glyphicon glyphicon glyphicon-save"></span> </a>
{% endif %}
{% if next_customer_invoice_id %}
<a href="{% url 'customer_invoice_view' next_customer_invoice_id %}"
class="btn btn-success btn-disabled">&nbsp;&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-arrow-right"></span>&nbsp;&nbsp;&nbsp;&nbsp;</a>
......
......@@ -146,5 +146,5 @@ urlpatterns = [
url(r'^rest/product/(?P<producer_short_profile_name>.*)/(?P<reference>.*)/$', product_rest,
name='product_rest'),
url(r'^rest/version/$', version_rest, name='version_rest'),
url(r'^ajax/dowload-customer-invoice/(?P<customer_invoice_id>\d+)/$', download_customer_invoice, name='download_customer_invoice'),
url(r'^dowload-customer-invoice/(?P<customer_invoice_id>\d+)/$', download_customer_invoice, name='download_customer_invoice'),
]
......@@ -39,6 +39,7 @@ class CustomerInvoiceView(DetailView):
else:
customer = self.request.user.customer
context['customer'] = customer
context['download_invoice'] = False
else:
customer_invoice = self.get_object()
bank_account_set = BankAccount.objects.filter(customer_invoice=customer_invoice).order_by("operation_date")
......@@ -87,6 +88,10 @@ class CustomerInvoiceView(DetailView):
if next_customer_invoice is not None:
context['next_customer_invoice_id'] = next_customer_invoice.id
context['customer'] = customer_invoice.customer
context['download_invoice'] = Purchase.objects.filter(
customer_charged_id=customer_invoice.customer_id,
permanence_id=customer_invoice.permanence_id,
).order_by('?').exists()
return context
def get_queryset(self):
......
......@@ -43,6 +43,7 @@ def download_customer_invoice(request, customer_invoice_id):
slugify(_("Accounting report")),
REPANIER_SETTINGS_GROUP_NAME
)
wb.save(response)
return response
if wb is not None:
wb.save(response)
return response
raise Http404
......@@ -179,18 +179,17 @@ def export_invoice(permanence=None, year=None, customer=None, producer=None, wb=
# Detail of what has been prepared
hide_producer_prices = False
hide_customer_prices = False
purchase_set = Purchase.objects.all().distinct()
if customer is not None:
purchase_set = purchase_set.filter(customer_charged=customer)
hide_producer_prices = True
purchase_set = Purchase.objects.all()
if producer is not None:
purchase_set = purchase_set.filter(producer=producer)
purchase_set = purchase_set.filter(producer_id=producer.id)
hide_customer_prices = True
if permanence is not None:
purchase_set = purchase_set.filter(permanence_id=permanence.id)
if year is not None:
purchase_set = purchase_set.filter(permanence_date__year=year)
if customer is not None:
purchase_set = purchase_set.filter(customer_charged_id=customer.id)
hide_producer_prices = True
if purchase_set.exists():
wb, ws = new_landscape_a4_sheet(wb, sheet_name, permanence)
......@@ -199,6 +198,7 @@ def export_invoice(permanence=None, year=None, customer=None, producer=None, wb=
hide_column_deposit = True
for purchase in purchase_set:
print(slugify(purchase))
qty = purchase.quantity_invoiced
......
Django==1.10.6
Django-Select2==5.8.10
Pillow==4.0.0
Django==1.10.7
Django-Select2==5.10.0
Pillow==4.1.0
Unidecode==0.04.20
argparse==1.4.0
cmsplugin-filer==1.1.3
......@@ -11,24 +11,24 @@ django-classy-tags==0.8.0
django-cms==3.4.2
# https://github.com/divio/django-cms/archive/release/3.4.x.zip
django-compressor==2.1
django-easy-select2==1.3.3
django-easy-select2==1.3.4
django-filer==1.2.7
django-formtools==2.0
django-import-export==0.5.1
django-mptt==0.8.7
django-mptt-admin==0.4.4
django-mptt-admin==0.4.5
django-parler==1.7
django-polymorphic==1.0.2
django-reversion==2.0.8
django-sekizai==0.10.0
django-treebeard==4.1.0
djangocms-admin-style==1.2.6.2
djangocms-admin-style==1.2.7
djangocms-attributes-field==0.2.0
djangocms-cascade==0.12
djangocms-cascade==0.12.3
# https://github.com/jrief/djangocms-cascade/archive/releases/0.12.x.zip
djangocms-text-ckeditor==3.4.0
djangorestframework==3.5.4
easy-thumbnails==2.3
djangorestframework==3.6.2
easy-thumbnails==2.4.1
openpyxl==1.8.6
psycopg2==2.6.2
psycopg2==2.7.1
uwsgi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment