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
* 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:
prefix = 'O{}'.format(prefix)
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()
if last_number is None:
last_number = 0
@ -412,6 +412,9 @@ class BillLine(models.Model):
amended_line = models.ForeignKey('self', verbose_name=_("amended line"),
related_name='amendment_lines', null=True, blank=True)
class Meta:
get_latest_by = 'id'
def __str__(self):
return "#%i" % self.pk if self.pk else self.description

View file

@ -24,6 +24,14 @@
margin: 10px;
}
#extralines {
clear: left;
clear: right;
text-align: right;
color: #A40000;
font-weight: bold;
text-align: center;
}
#number-date {
font-size: large;
@ -66,7 +74,7 @@
clear: left;
clear: right;
text-align: right;
margin: 240px 10px 50px 10px;
margin: 40px 10px 50px 10px;
font-weight: bold;
color: #666;
}
@ -110,13 +118,28 @@ hr {
</div>
<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 %}
{% endwith %}
</div>
{% endblock %}
{% 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">
{% blocktrans %}
<strong>With your membership</strong> you are supporting ...
@ -124,6 +147,8 @@ hr {
</div>
{% endblock %}
{% endblock %}
{% block footer %}
<hr>
{{ block.super }}

View file

@ -69,6 +69,7 @@
{% endblock %}
{% block content %}
{% block lines %}
<div id="lines">
<span class="title column-id">id</span>
<span class="title column-description">{% trans "description" %}</span>
@ -106,6 +107,9 @@
{% endwith %}
{% endfor %}
</div>
{% endblock %}
{% block totals %}
<div id="totals">
<br>&nbsp;<br>
{% for tax, subtotal in bill.compute_subtotals.items %}
@ -121,6 +125,7 @@
<br>
</div>
{% endblock %}
{% endblock %}
{% block footer %}
</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 . import settings
@ -37,7 +37,15 @@ def create_local_address(sender, *args, **kwargs):
name=mbox.name, domain=domain, account_id=domain.account_id)
if created:
if domain.account_id == mbox.account_id:
addr.mailboxes.add(mbox)
mbox._post_save_add_address = addr
else:
addr.forward = mbox.name
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)
context = {
'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)