Commit 3201817b authored by Patrick's avatar Patrick

Work in progress

parent 4021606f
...@@ -241,7 +241,12 @@ class BankAccountFilterByStatus(SimpleListFilter): ...@@ -241,7 +241,12 @@ class BankAccountFilterByStatus(SimpleListFilter):
parameter_name = 'is_filled_exact' parameter_name = 'is_filled_exact'
def lookups(self, request, model_admin): def lookups(self, request, model_admin):
return [(1, _('not invoiced')), (2, _('balance')), (3, _('subscriptions')), (4, _('losts and profits')), (5, _('taxes'))] return [
(1, _('not invoiced')),
(2, _('balance')),
(3, _('membership fees')),
(4, _('losts and profits')),
(5, _('taxes'))]
def queryset(self, request, queryset): def queryset(self, request, queryset):
value = self.value() value = self.value()
...@@ -254,7 +259,7 @@ class BankAccountFilterByStatus(SimpleListFilter): ...@@ -254,7 +259,7 @@ class BankAccountFilterByStatus(SimpleListFilter):
elif value == "2": elif value == "2":
return queryset.filter(permanence_id__isnull=False, customer_id__isnull=True, producer_id__isnull=True) return queryset.filter(permanence_id__isnull=False, customer_id__isnull=True, producer_id__isnull=True)
elif value == "3": elif value == "3":
return queryset.filter(operation_status=BANK_SUBSCRIPTION) return queryset.filter(operation_status=BANK_MEMBERSHIP_FEE)
elif value == "4": elif value == "4":
return queryset.filter(operation_status=BANK_PROFIT) return queryset.filter(operation_status=BANK_PROFIT)
else: else:
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from django import forms from django import forms
from django.conf.urls import url
from django.contrib import admin from django.contrib import admin
from django.core import urlresolvers
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from easy_select2 import apply_select2 from easy_select2 import apply_select2
from import_export import resources, fields from import_export import resources, fields
...@@ -278,6 +281,13 @@ class BankAccountAdmin(ImportExportMixin, admin.ModelAdmin): ...@@ -278,6 +281,13 @@ class BankAccountAdmin(ImportExportMixin, admin.ModelAdmin):
def has_change_permission(self, request, bank_account=None): def has_change_permission(self, request, bank_account=None):
return self.has_add_permission(request) return self.has_add_permission(request)
# def get_urls(self):
# urls = super(BankAccountAdmin, self).get_urls()
# my_urls = [
# url(r'^expenses_to_be_apportioned/$', self.expenses_to_be_apportioned),
# ]
# return my_urls + urls
def get_readonly_fields(self, request, obj=None): def get_readonly_fields(self, request, obj=None):
readonly_fields = [ readonly_fields = [
'is_updated_on', 'is_updated_on',
...@@ -285,6 +295,10 @@ class BankAccountAdmin(ImportExportMixin, admin.ModelAdmin): ...@@ -285,6 +295,10 @@ class BankAccountAdmin(ImportExportMixin, admin.ModelAdmin):
] ]
return readonly_fields return readonly_fields
# def expenses_to_be_apportioned(self, request):
# redirect_to = urlresolvers.reverse('admin:repanier_bankaccount_changelist', )
# return HttpResponseRedirect(redirect_to)
def get_actions(self, request): def get_actions(self, request):
actions = super(BankAccountAdmin, self).get_actions(request) actions = super(BankAccountAdmin, self).get_actions(request)
if 'delete_selected' in actions: if 'delete_selected' in actions:
...@@ -304,3 +318,6 @@ class BankAccountAdmin(ImportExportMixin, admin.ModelAdmin): ...@@ -304,3 +318,6 @@ class BankAccountAdmin(ImportExportMixin, admin.ModelAdmin):
""" """
return [f for f in (XLS, XLSX_OPENPYXL_1_8_6) if f().can_import()] return [f for f in (XLS, XLSX_OPENPYXL_1_8_6) if f().can_import()]
# class Media:
# js = ('js/expenses_to_be_apportioned.js',)
...@@ -142,7 +142,7 @@ class CustomerResource(resources.ModelResource): ...@@ -142,7 +142,7 @@ class CustomerResource(resources.ModelResource):
email = fields.Field(attribute='user', default="ask.it@to.me", widget=OneToOneWidget(User, 'email'), readonly=False) email = fields.Field(attribute='user', default="ask.it@to.me", widget=OneToOneWidget(User, 'email'), readonly=False)
phone1 = fields.Field(attribute='phone1', default="1234", widget=CharWidget(), readonly=False) phone1 = fields.Field(attribute='phone1', default="1234", widget=CharWidget(), readonly=False)
phone2 = fields.Field(attribute='phone2', widget=CharWidget(), readonly=False) phone2 = fields.Field(attribute='phone2', widget=CharWidget(), readonly=False)
date_balance = fields.Field(attribute='get_admin_date_balance', widget=DateWidgetExcel(), readonly=True) date_balance = fields.Field(attribute='get_admin_date_balance', widget=CharWidget(), readonly=True)
balance = fields.Field(attribute='get_admin_balance', widget=TwoMoneysWidget(), readonly=True) balance = fields.Field(attribute='get_admin_balance', widget=TwoMoneysWidget(), readonly=True)
may_order = fields.Field(attribute='may_order', default=False, widget=DecimalBooleanWidget(), readonly=False) may_order = fields.Field(attribute='may_order', default=False, widget=DecimalBooleanWidget(), readonly=False)
is_group = fields.Field(attribute='is_group', default=False, widget=DecimalBooleanWidget(), readonly=False) is_group = fields.Field(attribute='is_group', default=False, widget=DecimalBooleanWidget(), readonly=False)
...@@ -163,6 +163,7 @@ class CustomerResource(resources.ModelResource): ...@@ -163,6 +163,7 @@ class CustomerResource(resources.ModelResource):
delivery_point = fields.Field(attribute='delivery_point', delivery_point = fields.Field(attribute='delivery_point',
widget=TranslatedForeignKeyWidget(LUT_DeliveryPoint, field='short_name')) widget=TranslatedForeignKeyWidget(LUT_DeliveryPoint, field='short_name'))
valid_email = fields.Field(attribute='valid_email', widget=DecimalBooleanWidget(), readonly=True) valid_email = fields.Field(attribute='valid_email', widget=DecimalBooleanWidget(), readonly=True)
date_joined = fields.Field(attribute='get_admin_date_joined', widget=CharWidget(), readonly=True)
def before_save_instance(self, instance, using_transactions, dry_run): def before_save_instance(self, instance, using_transactions, dry_run):
""" """
...@@ -286,14 +287,6 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin): ...@@ -286,14 +287,6 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin):
get_email.short_description = _("email") get_email.short_description = _("email")
get_email.admin_order_field = 'user__email' get_email.admin_order_field = 'user__email'
def get_date_joined(self, customer):
if customer.user is not None:
return customer.user.date_joined.strftime(settings.DJANGO_SETTINGS_DATE)
else:
return EMPTY_STRING
get_date_joined.short_description = _("date joined")
def get_last_login(self, customer): def get_last_login(self, customer):
if customer.user is not None and customer.user.last_login is not None: if customer.user is not None and customer.user.last_login is not None:
return customer.user.last_login.strftime(settings.DJANGO_SETTINGS_DATE) return customer.user.last_login.strftime(settings.DJANGO_SETTINGS_DATE)
...@@ -356,7 +349,7 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin): ...@@ -356,7 +349,7 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin):
'bank_account1', 'bank_account1',
'bank_account2', 'bank_account2',
'get_last_login', 'get_last_login',
'get_date_joined', 'get_admin_date_joined',
'get_last_membership_fee', 'get_last_membership_fee',
'get_last_membership_fee_date', 'get_last_membership_fee_date',
'get_participation', 'get_participation',
...@@ -374,20 +367,20 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin): ...@@ -374,20 +367,20 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin):
return [ return [
'get_admin_date_balance', 'get_admin_balance', 'get_admin_date_balance', 'get_admin_balance',
'represent_this_buyinggroup', 'get_last_login', 'represent_this_buyinggroup', 'get_last_login',
'get_date_joined', 'get_participation', 'get_purchase', 'get_admin_date_joined', 'get_participation', 'get_purchase',
'get_last_membership_fee', 'get_last_membership_fee_date' 'get_last_membership_fee', 'get_last_membership_fee_date'
] ]
else: else:
return [ return [
'get_admin_date_balance', 'get_admin_balance', 'get_admin_date_balance', 'get_admin_balance',
'get_last_login', 'get_last_login',
'get_date_joined', 'get_participation', 'get_purchase', 'get_admin_date_joined', 'get_participation', 'get_purchase',
'get_last_membership_fee', 'get_last_membership_fee_date' 'get_last_membership_fee', 'get_last_membership_fee_date'
] ]
else: else:
return [ return [
'represent_this_buyinggroup', 'get_last_login', 'represent_this_buyinggroup', 'get_last_login',
'get_date_joined', 'get_participation', 'get_purchase', 'get_admin_date_joined', 'get_participation', 'get_purchase',
'get_last_membership_fee', 'get_last_membership_fee_date' 'get_last_membership_fee', 'get_last_membership_fee_date'
] ]
......
...@@ -404,6 +404,7 @@ class PermanenceInPreparationAdmin(TranslatableAdmin): ...@@ -404,6 +404,7 @@ class PermanenceInPreparationAdmin(TranslatableAdmin):
context = TemplateContext({ context = TemplateContext({
'offer_description': mark_safe(offer_description), 'offer_description': mark_safe(offer_description),
'offer_detail' : offer_detail, 'offer_detail' : offer_detail,
'offer_recent_detail': offer_detail,
'offer_producer' : offer_producer, 'offer_producer' : offer_producer,
'permanence_link' : mark_safe('<a href="#">%s</a>' % permanence), 'permanence_link' : mark_safe('<a href="#">%s</a>' % permanence),
'signature' : mark_safe( 'signature' : mark_safe(
......
...@@ -521,7 +521,7 @@ class ProductAdmin(ImportExportMixin, TranslatableAdmin): ...@@ -521,7 +521,7 @@ class ProductAdmin(ImportExportMixin, TranslatableAdmin):
if hasattr(picture_field.widget, 'upload_to'): if hasattr(picture_field.widget, 'upload_to'):
picture_field.widget.upload_to = "%s%s%d" % ("product", os_sep, producer.id) picture_field.widget.upload_to = "%s%s%d" % ("product", os_sep, producer.id)
if producer.represent_this_buyinggroup: if producer.represent_this_buyinggroup:
order_unit_choices = LUT_PRODUCT_ORDER_UNIT order_unit_choices = LUT_PRODUCT_ORDER_UNIT_W_SUBSCRIPTION
order_unit_field.choices = order_unit_choices order_unit_field.choices = order_unit_choices
if product is not None: if product is not None:
...@@ -570,9 +570,12 @@ class ProductAdmin(ImportExportMixin, TranslatableAdmin): ...@@ -570,9 +570,12 @@ class ProductAdmin(ImportExportMixin, TranslatableAdmin):
def get_queryset(self, request): def get_queryset(self, request):
queryset = super(ProductAdmin, self).get_queryset(request) queryset = super(ProductAdmin, self).get_queryset(request)
return queryset.filter(is_box=False, is_membership_fee=False, return queryset.filter(
producer__is_active=True, is_box=False,
translations__language_code=translation.get_language()) # is_membership_fee=False,
producer__is_active=True,
translations__language_code=translation.get_language()
).exclude(order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE)
def get_import_formats(self): def get_import_formats(self):
""" """
......
...@@ -108,8 +108,9 @@ PRODUCT_ORDER_UNIT_KG = '120' ...@@ -108,8 +108,9 @@ PRODUCT_ORDER_UNIT_KG = '120'
PRODUCT_ORDER_UNIT_PC_KG = '140' PRODUCT_ORDER_UNIT_PC_KG = '140'
PRODUCT_ORDER_UNIT_LT = '150' PRODUCT_ORDER_UNIT_LT = '150'
PRODUCT_ORDER_UNIT_DEPOSIT = '300' PRODUCT_ORDER_UNIT_DEPOSIT = '300'
PRODUCT_ORDER_UNIT_SUBSCRIPTION = '400' PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE = '400'
PRODUCT_ORDER_UNIT_TRANSPORTATION = '500' PRODUCT_ORDER_UNIT_TRANSPORTATION = '500'
PRODUCT_ORDER_UNIT_SUBSCRIPTION = '600'
LUT_PRODUCT_ORDER_UNIT = ( LUT_PRODUCT_ORDER_UNIT = (
(PRODUCT_ORDER_UNIT_PC, _("bought per piece")), (PRODUCT_ORDER_UNIT_PC, _("bought per piece")),
...@@ -122,7 +123,7 @@ LUT_PRODUCT_ORDER_UNIT = ( ...@@ -122,7 +123,7 @@ LUT_PRODUCT_ORDER_UNIT = (
(PRODUCT_ORDER_UNIT_DEPOSIT, (PRODUCT_ORDER_UNIT_DEPOSIT,
_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.')), _('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.')),
(PRODUCT_ORDER_UNIT_SUBSCRIPTION, _( (PRODUCT_ORDER_UNIT_SUBSCRIPTION, _(
'As a subscription, common expense : add the minimal order quantity of this product to each customer of the group')), 'Subscription')),
(PRODUCT_ORDER_UNIT_TRANSPORTATION, _( (PRODUCT_ORDER_UNIT_TRANSPORTATION, _(
'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.')), 'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.')),
) )
...@@ -138,7 +139,7 @@ LUT_PRODUCT_ORDER_UNIT_REVERSE = ( ...@@ -138,7 +139,7 @@ LUT_PRODUCT_ORDER_UNIT_REVERSE = (
(_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.'), (_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.'),
PRODUCT_ORDER_UNIT_DEPOSIT), PRODUCT_ORDER_UNIT_DEPOSIT),
(_( (_(
'As a subscription, common expense : add the minimal order quantity of this product to each customer of the group'), 'Subscription'),
PRODUCT_ORDER_UNIT_SUBSCRIPTION), PRODUCT_ORDER_UNIT_SUBSCRIPTION),
(_( (_(
'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.'), 'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.'),
...@@ -159,6 +160,20 @@ LUT_PRODUCT_ORDER_UNIT_WO_SUBSCRIPTION = ( ...@@ -159,6 +160,20 @@ LUT_PRODUCT_ORDER_UNIT_WO_SUBSCRIPTION = (
'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.')), 'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.')),
) )
LUT_PRODUCT_ORDER_UNIT_W_SUBSCRIPTION = (
(PRODUCT_ORDER_UNIT_PC, _("bought per piece")),
(PRODUCT_ORDER_UNIT_PC_PRICE_KG, _("bought per piece (price /kg)")),
(PRODUCT_ORDER_UNIT_PC_PRICE_LT, _("bought per piece (price /l)")),
(PRODUCT_ORDER_UNIT_PC_PRICE_PC, _("bought per piece (price /pc)")),
(PRODUCT_ORDER_UNIT_KG, _("bought per kg")),
(PRODUCT_ORDER_UNIT_PC_KG, _("bought per piece, invoiced following the weight")),
(PRODUCT_ORDER_UNIT_LT, _("bought per l")),
(PRODUCT_ORDER_UNIT_DEPOSIT,
_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.')),
(PRODUCT_ORDER_UNIT_SUBSCRIPTION, _(
'Subscription')),
)
LUT_PRODUCER_PRODUCT_ORDER_UNIT = ( LUT_PRODUCER_PRODUCT_ORDER_UNIT = (
(PRODUCT_ORDER_UNIT_PC_PRICE_PC, _("Sold by piece")), (PRODUCT_ORDER_UNIT_PC_PRICE_PC, _("Sold by piece")),
(PRODUCT_ORDER_UNIT_PC_PRICE_KG, _("Sold by weight")), (PRODUCT_ORDER_UNIT_PC_PRICE_KG, _("Sold by weight")),
...@@ -230,7 +245,7 @@ LUT_ALL_VAT_REVERSE = ( ...@@ -230,7 +245,7 @@ LUT_ALL_VAT_REVERSE = (
) )
BANK_NOT_LATEST_TOTAL = '100' BANK_NOT_LATEST_TOTAL = '100'
BANK_SUBSCRIPTION = '150' BANK_MEMBERSHIP_FEE = '150'
BANK_COMPENSATION = '200' # BANK_COMPENSATION may occurs in previous release of Repanier BANK_COMPENSATION = '200' # BANK_COMPENSATION may occurs in previous release of Repanier
BANK_PROFIT = '210' BANK_PROFIT = '210'
BANK_TAX = '220' BANK_TAX = '220'
...@@ -240,7 +255,7 @@ BANK_LATEST_TOTAL = '400' ...@@ -240,7 +255,7 @@ BANK_LATEST_TOTAL = '400'
LUT_BANK_TOTAL = ( LUT_BANK_TOTAL = (
(BANK_NOT_LATEST_TOTAL, _('This is not the latest total')), (BANK_NOT_LATEST_TOTAL, _('This is not the latest total')),
(BANK_SUBSCRIPTION, BANK_SUBSCRIPTION), (BANK_MEMBERSHIP_FEE, BANK_MEMBERSHIP_FEE),
(BANK_PROFIT, BANK_PROFIT), (BANK_PROFIT, BANK_PROFIT),
(BANK_TAX, BANK_TAX), (BANK_TAX, BANK_TAX),
(BANK_CALCULATED_INVOICE, BANK_CALCULATED_INVOICE), (BANK_CALCULATED_INVOICE, BANK_CALCULATED_INVOICE),
......
...@@ -127,12 +127,22 @@ def send_open_order(permanence_id): ...@@ -127,12 +127,22 @@ def send_open_order(permanence_id):
) )
for o in qs for o in qs
),) ),)
two_weeks_ago = timezone.now().date() - datetime.timedelta(days=14)
qs = qs.filter(product__is_updated_on__gte=two_weeks_ago)
offer_recent_detail = '<ul>%s</ul>' % ("".join('<li>%s, %s, %s</li>' % (
o.get_long_name(box_unicode=EMPTY_STRING),
o.producer.short_profile_name,
o.email_offer_price_with_vat,
)
for o in qs
),)
template = Template(offer_customer_mail) template = Template(offer_customer_mail)
context = TemplateContext({ context = TemplateContext({
'permanence_link' : mark_safe('<a href="http://%s%s">%s</a>' % ( 'permanence_link' : mark_safe('<a href="http://%s%s">%s</a>' % (
settings.ALLOWED_HOSTS[0], reverse('order_view', args=(permanence.id,)), permanence)), settings.ALLOWED_HOSTS[0], reverse('order_view', args=(permanence.id,)), permanence)),
'offer_description': mark_safe(offer_description), 'offer_description': mark_safe(offer_description),
'offer_detail' : mark_safe(offer_detail), 'offer_detail' : mark_safe(offer_detail),
'offer_recent_detail' : mark_safe(offer_recent_detail),
'offer_producer' : offer_producer, 'offer_producer' : offer_producer,
'signature' : mark_safe( 'signature' : mark_safe(
'%s<br/>%s<br/>%s' % (signature, sender_function, REPANIER_SETTINGS_GROUP_NAME)) '%s<br/>%s<br/>%s' % (signature, sender_function, REPANIER_SETTINGS_GROUP_NAME))
......
...@@ -5,7 +5,6 @@ import sys ...@@ -5,7 +5,6 @@ import sys
from decimal import * from decimal import *
from django.conf import settings from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models from django.db import models
from django.db.models.expressions import BaseExpression, Expression from django.db.models.expressions import BaseExpression, Expression
from django.forms import DecimalField, NumberInput from django.forms import DecimalField, NumberInput
......
This diff is collapsed.
...@@ -7,8 +7,8 @@ msgid "" ...@@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: repanier\n" "Project-Id-Version: repanier\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-14 13:41+0200\n" "POT-Creation-Date: 2017-04-21 12:29+0200\n"
"PO-Revision-Date: 2017-04-15 08:56+0100\n" "PO-Revision-Date: 2017-04-21 12:30+0100\n"
"Last-Translator: Patrick Colmant <pcolmant@gmail.com>\n" "Last-Translator: Patrick Colmant <pcolmant@gmail.com>\n"
"Language-Team: Patrick Colmant <pcolmant@gmail.com>\n" "Language-Team: Patrick Colmant <pcolmant@gmail.com>\n"
"Language: fr\n" "Language: fr\n"
...@@ -18,6 +18,10 @@ msgstr "" ...@@ -18,6 +18,10 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 1.7.1\n" "X-Generator: Poedit 1.7.1\n"
#: static/js/expenses_to_be_apportioned.js:4
msgid "Expenses to be apportioned"
msgstr "Frais à répartir"
#: static/js/export_import_stock.js:4 #: static/js/export_import_stock.js:4
msgid "Export stock" msgid "Export stock"
msgstr "Exporter le stock" msgstr "Exporter le stock"
......
...@@ -114,6 +114,7 @@ class Configuration(TranslatableModel): ...@@ -114,6 +114,7 @@ class Configuration(TranslatableModel):
<br /> <br />
Les produits suivants sont en offre :<br /> Les produits suivants sont en offre :<br />
{{ offer_detail }}<br /> {{ offer_detail }}<br />
{{ offer_recent_detail }}<br />
<br /> <br />
{{ signature }} {{ signature }}
""", """,
...@@ -377,13 +378,14 @@ def configuration_post_save(sender, **kwargs): ...@@ -377,13 +378,14 @@ def configuration_post_save(sender, **kwargs):
represent_this_buyinggroup=True represent_this_buyinggroup=True
) )
if producer_buyinggroup is not None: if producer_buyinggroup is not None:
membership_fee_product = product.Product.objects.filter(is_membership_fee=True, is_active=True).order_by( membership_fee_product = product.Product.objects.filter(
'?').first() order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE,
is_active=True
).order_by('?').first()
if membership_fee_product is None: if membership_fee_product is None:
membership_fee_product = product.Product.objects.create( membership_fee_product = product.Product.objects.create(
producer_id=producer_buyinggroup.id, producer_id=producer_buyinggroup.id,
is_membership_fee=True, order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE,
order_unit=PRODUCT_ORDER_UNIT_SUBSCRIPTION,
vat_level=VAT_100 vat_level=VAT_100
) )
cur_language = translation.get_language() cur_language = translation.get_language()
......
...@@ -110,11 +110,20 @@ class Customer(models.Model): ...@@ -110,11 +110,20 @@ class Customer(models.Model):
preparation_order = models.IntegerField(null=True, blank=True, default=0) preparation_order = models.IntegerField(null=True, blank=True, default=0)
def get_admin_date_balance(self): def get_admin_date_balance(self):
return timezone.now().date() return timezone.now().date().strftime(settings.DJANGO_SETTINGS_DATE)
get_admin_date_balance.short_description = (_("date_balance")) get_admin_date_balance.short_description = (_("date_balance"))
get_admin_date_balance.allow_tags = False get_admin_date_balance.allow_tags = False
def get_admin_date_joined(self):
if self.user is not None:
return self.user.date_joined.strftime(settings.DJANGO_SETTINGS_DATE)
else:
return EMPTY_STRING
get_admin_date_joined.short_description = _("date joined")
get_admin_date_joined.allow_tags = False
def get_admin_balance(self): def get_admin_balance(self):
if self.id is not None: if self.id is not None:
return self.balance + self.get_bank_not_invoiced() - self.get_order_not_invoiced() return self.balance + self.get_bank_not_invoiced() - self.get_order_not_invoiced()
...@@ -190,7 +199,7 @@ class Customer(models.Model): ...@@ -190,7 +199,7 @@ class Customer(models.Model):
if self.id is not None: if self.id is not None:
last_membership_fee = purchase.Purchase.objects.filter( last_membership_fee = purchase.Purchase.objects.filter(
customer_id=self.id, customer_id=self.id,
offer_item__order_unit=PRODUCT_ORDER_UNIT_SUBSCRIPTION offer_item__order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE
).order_by("-id") ).order_by("-id")
if last_membership_fee.exists(): if last_membership_fee.exists():
return last_membership_fee.first().selling_price return last_membership_fee.first().selling_price
...@@ -203,7 +212,7 @@ class Customer(models.Model): ...@@ -203,7 +212,7 @@ class Customer(models.Model):
if self.id is not None: if self.id is not None:
last_membership_fee = purchase.Purchase.objects.filter( last_membership_fee = purchase.Purchase.objects.filter(
customer_id=self.id, customer_id=self.id,
offer_item__order_unit=PRODUCT_ORDER_UNIT_SUBSCRIPTION offer_item__order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE
).order_by("-id").prefetch_related("customer_invoice") ).order_by("-id").prefetch_related("customer_invoice")
if last_membership_fee.exists(): if last_membership_fee.exists():
return last_membership_fee.first().customer_invoice.date_balance return last_membership_fee.first().customer_invoice.date_balance
......
...@@ -128,7 +128,7 @@ class OfferItem(TranslatableModel): ...@@ -128,7 +128,7 @@ class OfferItem(TranslatableModel):
is_box = models.BooleanField(_("is_box"), default=False) is_box = models.BooleanField(_("is_box"), default=False)
is_box_content = models.BooleanField(_("is_box_content"), default=False) is_box_content = models.BooleanField(_("is_box_content"), default=False)
is_membership_fee = models.BooleanField(_("is_membership_fee"), default=False) # is_membership_fee = models.BooleanField(_("is_membership_fee"), default=False)
may_order = models.BooleanField(_("may_order"), default=True) may_order = models.BooleanField(_("may_order"), default=True)
is_active = models.BooleanField(_("is_active"), default=True) is_active = models.BooleanField(_("is_active"), default=True)
limit_order_quantity_to_stock = models.BooleanField(_("limit maximum order qty of the group to stock qty"), limit_order_quantity_to_stock = models.BooleanField(_("limit maximum order qty of the group to stock qty"),
......
...@@ -128,7 +128,7 @@ class Product(TranslatableModel): ...@@ -128,7 +128,7 @@ class Product(TranslatableModel):
is_box = models.BooleanField(_("is_box"), default=False) is_box = models.BooleanField(_("is_box"), default=False)
# is_mandatory = models.BooleanField(_("is_mandatory"), default=False) # is_mandatory = models.BooleanField(_("is_mandatory"), default=False)
is_membership_fee = models.BooleanField(_("is_membership_fee"), default=False) # is_membership_fee = models.BooleanField(_("is_membership_fee"), default=False)
is_active = models.BooleanField(_("is_active"), default=True) is_active = models.BooleanField(_("is_active"), default=True)
is_updated_on = models.DateTimeField( is_updated_on = models.DateTimeField(
_("is_updated_on"), auto_now=True, blank=True) _("is_updated_on"), auto_now=True, blank=True)
...@@ -308,7 +308,11 @@ def product_pre_save(sender, **kwargs): ...@@ -308,7 +308,11 @@ def product_pre_save(sender, **kwargs):
elif product.order_unit not in [PRODUCT_ORDER_UNIT_PC_KG, PRODUCT_ORDER_UNIT_PC_PRICE_KG, elif product.order_unit not in [PRODUCT_ORDER_UNIT_PC_KG, PRODUCT_ORDER_UNIT_PC_PRICE_KG,
PRODUCT_ORDER_UNIT_PC_PRICE_LT, PRODUCT_ORDER_UNIT_PC_PRICE_PC]: PRODUCT_ORDER_UNIT_PC_PRICE_LT, PRODUCT_ORDER_UNIT_PC_PRICE_PC]:
product.order_average_weight = DECIMAL_ZERO product.order_average_weight = DECIMAL_ZERO
if product.order_unit in [PRODUCT_ORDER_UNIT_DEPOSIT, PRODUCT_ORDER_UNIT_SUBSCRIPTION]: if product.order_unit in [
PRODUCT_ORDER_UNIT_DEPOSIT,
PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE,
PRODUCT_ORDER_UNIT_SUBSCRIPTION
]:
# No VAT on those products # No VAT on those products
product.vat_level = VAT_100 product.vat_level = VAT_100
...@@ -327,7 +331,8 @@ def product_pre_save(sender, **kwargs): ...@@ -327,7 +331,8 @@ def product_pre_save(sender, **kwargs):
product.limit_order_quantity_to_stock = False product.limit_order_quantity_to_stock = False
if product.limit_order_quantity_to_stock: if product.limit_order_quantity_to_stock:
product.customer_alert_order_quantity = min(999, product.stock) product.customer_alert_order_quantity = min(999, product.stock)
elif product.order_unit == PRODUCT_ORDER_UNIT_SUBSCRIPTION:
product.customer_alert_order_quantity = LIMIT_ORDER_QTY_ITEM
if product.customer_increment_order_quantity <= DECIMAL_ZERO: if product.customer_increment_order_quantity <= DECIMAL_ZERO:
product.customer_increment_order_quantity = DECIMAL_ONE product.customer_increment_order_quantity = DECIMAL_ONE
if product.customer_minimum_order_quantity <= DECIMAL_ZERO: if product.customer_minimum_order_quantity <= DECIMAL_ZERO:
......
(function($) {
$(document).ready(function($) {
if(location.pathname.indexOf('change') <= -1) {
$(".object-tools").prepend('<li><a href="./expenses_to_be_apportioned/' + location.search + '">' + gettext('Expenses to be apportioned')+ '</a></li>');
}
});
})(django.jQuery);
...@@ -322,29 +322,26 @@ def generate_invoice(permanence, payment_date): ...@@ -322,29 +322,26 @@ def generate_invoice(permanence, payment_date):
producer_invoice=None producer_invoice=None
) )
result_set = Purchase.objects.filter( for membership_fee in Purchase.objects.filter(
permanence_id=permanence.id, permanence_id=permanence.id,
producer_id=producer_buyinggroup.id, producer_id=producer_buyinggroup.id,
offer_item__order_unit=PRODUCT_ORDER_UNIT_SUBSCRIPTION offer_item__order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE
).order_by('?').aggregate(Sum('selling_price')) ).order_by('?').aggregate(Sum('selling_price')):
if result_set["selling_price__sum"] is not None: # --> This bank movement is not a real entry
subscriptions = result_set["selling_price__sum"] # making this, it will not be counted into the customer_buyinggroup movements twice
if subscriptions != DECIMAL_ZERO: # because Repanier will see it has already been counted into the customer_buyinggroup movements
# --> This bank movement is not a real entry BankAccount.objects.create(
# making this, it will not be counted into the customer_buyinggroup movements twice permanence_id=permanence.id,
# because Repanier will see it has already been counted into the customer_buyinggroup movements producer=None,
BankAccount.objects.create( customer_id=customer_buyinggroup.id,
permanence_id=permanence.id, operation_date=payment_date,
producer=None, operation_status=BANK_MEMBERSHIP_FEE,
customer_id=customer_buyinggroup.id, operation_comment="%s : %s" % (_("Membership fee"), membership_fee.customer),
operation_date=payment_date, bank_amount_in=membership_fee,
operation_status=BANK_SUBSCRIPTION, bank_amount_out=DECIMAL_ZERO,
operation_comment=_("Subscriptions"), customer_invoice_id=customer_invoice_buyinggroup.id,
bank_amount_in=subscriptions, producer_invoice=None
bank_amount_out=DECIMAL_ZERO, )
customer_invoice_id=customer_invoice_buyinggroup.id,
producer_invoice=None
)
for customer_invoice in CustomerInvoice.objects.filter( for customer_invoice in CustomerInvoice.objects.filter(
permanence_id=permanence.id, permanence_id=permanence.id,
...@@ -362,7 +359,7 @@ def generate_invoice(permanence, payment_date): ...@@ -362,7 +359,7 @@ def generate_invoice(permanence, payment_date):
producer=None, producer=None,
customer_id=customer_buyinggroup.id, customer_id=customer_buyinggroup.id,
operation_date=payment_date, operation_date=payment_date,
operation_status=BANK_SUBSCRIPTION, operation_status=BANK_PROFIT,
operation_comment="%s : %s" % (_("Transport"), customer_invoice.customer.short_basket_name), operation_comment="%s : %s" % (_("Transport"), customer_invoice.customer.short_basket_name),
bank_amount_in=customer_invoice.delta_transport, bank_amount_in=customer_invoice.delta_transport,
bank_amount_out=DECIMAL_ZERO, bank_amount_out=DECIMAL_ZERO,
...@@ -648,7 +645,7 @@ def cancel_invoice(permanence): ...@@ -648,7 +645,7 @@ def cancel_invoice(permanence):
BANK_CALCULATED_INVOICE, BANK_CALCULATED_INVOICE,
BANK_PROFIT, BANK_PROFIT,
BANK_TAX, BANK_TAX,
BANK_SUBSCRIPTION, BANK_MEMBERSHIP_FEE,
BANK_COMPENSATION # BANK_COMPENSATION may occurs in previous release of Repanier BANK_COMPENSATION # BANK_COMPENSATION may occurs in previous release of Repanier
] ]
).order_by('?').delete() ).order_by('?').delete()
......
This diff is collapsed.
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<div class="row"> <div class="row">
<div class="panel panel-danger"> <div class="panel panel-danger">