Fixed bill number problem and added fee extra lines

This commit is contained in:
Marc Aymerich 2016-01-29 14:07:55 +00:00
parent 447f9d7cd1
commit db652484c1
6 changed files with 51 additions and 6 deletions

View File

@ -456,3 +456,7 @@ mkhomedir_helper or create ssh homes with bash.rc and such
* setuppostgres use porject_name for db name and user instead of orchestra * setuppostgres use porject_name for db name and user instead of orchestra
* show all available choices (plugins) on admin settings value i.e. payment methods * show all available choices (plugins) on admin settings value i.e. payment methods
# POSTFIX web traffic monitor '": uid=" from=<%(user)s>'

View File

@ -227,7 +227,7 @@ class Bill(models.Model):
if self.is_open: if self.is_open:
prefix = 'O{}'.format(prefix) prefix = 'O{}'.format(prefix)
year = timezone.now().strftime("%Y") year = timezone.now().strftime("%Y")
bills = cls.objects.filter(number__regex=r'^%s%s[1-9]+' % (prefix, year)) bills = cls.objects.filter(number__regex=r'^%s%s[0-9]+' % (prefix, year))
last_number = bills.order_by('-number').values_list('number', flat=True).first() last_number = bills.order_by('-number').values_list('number', flat=True).first()
if last_number is None: if last_number is None:
last_number = 0 last_number = 0
@ -412,6 +412,9 @@ class BillLine(models.Model):
amended_line = models.ForeignKey('self', verbose_name=_("amended line"), amended_line = models.ForeignKey('self', verbose_name=_("amended line"),
related_name='amendment_lines', null=True, blank=True) related_name='amendment_lines', null=True, blank=True)
class Meta:
get_latest_by = 'id'
def __str__(self): def __str__(self):
return "#%i" % self.pk if self.pk else self.description return "#%i" % self.pk if self.pk else self.description

View File

@ -24,6 +24,14 @@
margin: 10px; margin: 10px;
} }
#extralines {
clear: left;
clear: right;
text-align: right;
color: #A40000;
font-weight: bold;
text-align: center;
}
#number-date { #number-date {
font-size: large; font-size: large;
@ -66,7 +74,7 @@
clear: left; clear: left;
clear: right; clear: right;
text-align: right; text-align: right;
margin: 240px 10px 50px 10px; margin: 40px 10px 50px 10px;
font-weight: bold; font-weight: bold;
color: #666; color: #666;
} }
@ -110,13 +118,28 @@ hr {
</div> </div>
<div id="date" class="column-2"> <div id="date" class="column-2">
{% with line=bill.lines.get %} {% with line=bill.lines.first %}
{% blocktrans with ini=line.start_on|date:"F j, Y" end=line.end_on|date:"F j, Y" %}From {{ ini }} to {{ end }}{% endblocktrans %} {% blocktrans with ini=line.start_on|date:"F j, Y" end=line.end_on|date:"F j, Y" %}From {{ ini }} to {{ end }}{% endblocktrans %}
{% endwith %} {% endwith %}
</div> </div>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% block lines %}
<div id="extralines">
{% for line in bill.lines.all %}
<ul>
{% if not forloop.first %}
<li>{{ line.description }}</li>
{% endif %}
</ul>
{% endfor %}
</div>
{% endblock %}
{% block text %}
<div id="text"> <div id="text">
{% blocktrans %} {% blocktrans %}
<strong>With your membership</strong> you are supporting ... <strong>With your membership</strong> you are supporting ...
@ -124,6 +147,8 @@ hr {
</div> </div>
{% endblock %} {% endblock %}
{% endblock %}
{% block footer %} {% block footer %}
<hr> <hr>
{{ block.super }} {{ block.super }}

View File

@ -69,6 +69,7 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% block lines %}
<div id="lines"> <div id="lines">
<span class="title column-id">id</span> <span class="title column-id">id</span>
<span class="title column-description">{% trans "description" %}</span> <span class="title column-description">{% trans "description" %}</span>
@ -106,6 +107,9 @@
{% endwith %} {% endwith %}
{% endfor %} {% endfor %}
</div> </div>
{% endblock %}
{% block totals %}
<div id="totals"> <div id="totals">
<br>&nbsp;<br> <br>&nbsp;<br>
{% for tax, subtotal in bill.compute_subtotals.items %} {% for tax, subtotal in bill.compute_subtotals.items %}
@ -121,6 +125,7 @@
<br> <br>
</div> </div>
{% endblock %} {% endblock %}
{% endblock %}
{% block footer %} {% block footer %}
</div> </div>

View File

@ -1,4 +1,4 @@
from django.db.models.signals import pre_save, post_delete from django.db.models.signals import pre_save, post_delete, post_save
from django.dispatch import receiver from django.dispatch import receiver
from . import settings from . import settings
@ -37,7 +37,15 @@ def create_local_address(sender, *args, **kwargs):
name=mbox.name, domain=domain, account_id=domain.account_id) name=mbox.name, domain=domain, account_id=domain.account_id)
if created: if created:
if domain.account_id == mbox.account_id: if domain.account_id == mbox.account_id:
addr.mailboxes.add(mbox) mbox._post_save_add_address = addr
else: else:
addr.forward = mbox.name addr.forward = mbox.name
addr.save(update_fields=('forward',)) addr.save(update_fields=('forward',))
@receiver(post_save, sender=Mailbox, dispatch_uid='mailboxes.add_local_address')
def add_local_address(sender, *args, **kwargs):
mbox = kwargs['instance']
addr = getattr(mbox, '_post_save_add_address', None)
if addr:
addr.mailboxes.add(mbox)

View File

@ -161,7 +161,7 @@ class OwnCloudDiskQuota(OwnClouwAPIMixin, ServiceMonitor):
user = self.get_user(saas) user = self.get_user(saas)
context = { context = {
'object_id': saas.pk, 'object_id': saas.pk,
'used': user['quota'].get('used', 0), 'used': int(user['quota'].get('used', 0)),
} }
sys.stdout.write('%(object_id)i %(used)i\n' % context) sys.stdout.write('%(object_id)i %(used)i\n' % context)