|
@@ -224,9 +224,11 @@ class Invoice(models.Model):
|
|
|
self.save()
|
|
|
self.generate_pdf()
|
|
|
|
|
|
- accounting_log.info("Draft invoice %s validated as invoice %s. "
|
|
|
- "(Total amount : %f ; Member : %s)"
|
|
|
- % (old_number, self.number, self.amount(), self.member))
|
|
|
+ accounting_log.info(
|
|
|
+ "Draft invoice {} validated as invoice {}. ".format(
|
|
|
+ old_number, self.number) +
|
|
|
+ "(Total amount : {} ; Member : {})".format(
|
|
|
+ self.amount(), self.member))
|
|
|
assert self.pdf_exists()
|
|
|
if self.member is not None:
|
|
|
update_accounting_for_member(self.member)
|
|
@@ -241,7 +243,8 @@ class Invoice(models.Model):
|
|
|
return reverse('billing:invoice', args=[self.number])
|
|
|
|
|
|
def __unicode__(self):
|
|
|
- return '#%s %0.2f€ %s' % (self.number, self.amount(), self.date_due)
|
|
|
+ return '#{} {:0.2f}€ {}'.format(
|
|
|
+ self.number, self.amount(), self.date_due)
|
|
|
|
|
|
def reminder_needed(self):
|
|
|
|
|
@@ -276,8 +279,9 @@ class Invoice(models.Model):
|
|
|
if not self.reminder_needed():
|
|
|
return False
|
|
|
|
|
|
- accounting_log.info("Sending reminder email to %s to pay invoice %s"
|
|
|
- % (str(self.member), str(self.number)))
|
|
|
+ accounting_log.info(
|
|
|
+ "Sending reminder email to {} to pay invoice {}".format(
|
|
|
+ self.member, str(self.number)))
|
|
|
|
|
|
isp_info = ISPInfo.objects.first()
|
|
|
kwargs = {}
|
|
@@ -416,9 +420,9 @@ class Payment(models.Model):
|
|
|
amount_to_pay = invoice.amount_remaining_to_pay()
|
|
|
amount_to_allocate = min(amount_can_pay, amount_to_pay)
|
|
|
|
|
|
- accounting_log.info("Allocating %f from payment %s to invoice %s"
|
|
|
- % (float(amount_to_allocate), str(self.date),
|
|
|
- invoice.number))
|
|
|
+ accounting_log.info(
|
|
|
+ "Allocating {} from payment {} to invoice {}".format(
|
|
|
+ amount_to_allocate, self.date, invoice.number))
|
|
|
|
|
|
PaymentAllocation.objects.create(invoice=invoice,
|
|
|
payment=self,
|
|
@@ -426,8 +430,9 @@ class Payment(models.Model):
|
|
|
|
|
|
# Close invoice if relevant
|
|
|
if (invoice.amount_remaining_to_pay() <= 0) and (invoice.status == "open"):
|
|
|
- accounting_log.info("Invoice %s has been paid and is now closed"
|
|
|
- % invoice.number)
|
|
|
+ accounting_log.info(
|
|
|
+ "Invoice {} has been paid and is now closed".format(
|
|
|
+ invoice.number))
|
|
|
invoice.status = "closed"
|
|
|
|
|
|
invoice.save()
|
|
@@ -435,11 +440,11 @@ class Payment(models.Model):
|
|
|
|
|
|
def __unicode__(self):
|
|
|
if self.member is not None:
|
|
|
- return 'Paiment de %0.2f€ le %s par %s' \
|
|
|
- % (self.amount, str(self.date), self.member)
|
|
|
+ return 'Paiment de {:0.2f}€ le {} par {}'.format(
|
|
|
+ self.amount, self.date, self.member)
|
|
|
else:
|
|
|
- return 'Paiment de %0.2f€ le %s' \
|
|
|
- % (self.amount, str(self.date))
|
|
|
+ return 'Paiment de {:0.2f}€ le {}'.format(
|
|
|
+ self.amount, self.date)
|
|
|
|
|
|
class Meta:
|
|
|
verbose_name = 'paiement'
|
|
@@ -484,10 +489,9 @@ def update_accounting_for_member(member):
|
|
|
d'un utilisateur
|
|
|
"""
|
|
|
|
|
|
- accounting_log.info("Updating accounting for member %s ..."
|
|
|
- % str(member))
|
|
|
- accounting_log.info("Member %s current balance is %f ..."
|
|
|
- % (str(member), float(member.balance)))
|
|
|
+ accounting_log.info("Updating accounting for member {} ...".format(member))
|
|
|
+ accounting_log.info(
|
|
|
+ "Member {} current balance is {} ...".format(member, member.balance))
|
|
|
|
|
|
reconcile_invoices_and_payments(member)
|
|
|
|
|
@@ -498,8 +502,8 @@ def update_accounting_for_member(member):
|
|
|
this_member_payments)
|
|
|
member.save()
|
|
|
|
|
|
- accounting_log.info("Member %s new balance is %f"
|
|
|
- % (str(member), float(member.balance)))
|
|
|
+ accounting_log.info("Member {} new balance is {:f}".format(
|
|
|
+ member, member.balance))
|
|
|
|
|
|
|
|
|
def reconcile_invoices_and_payments(member):
|
|
@@ -511,18 +515,19 @@ def reconcile_invoices_and_payments(member):
|
|
|
active_payments, active_invoices = get_active_payment_and_invoices(member)
|
|
|
|
|
|
if active_payments == []:
|
|
|
- accounting_log.info("(No active payment for %s. No invoice/payment "
|
|
|
- "reconciliation needed.)."
|
|
|
- % str(member))
|
|
|
+ accounting_log.info(
|
|
|
+ "(No active payment for {}.".format(member)
|
|
|
+ + " No invoice/payment reconciliation needed.).")
|
|
|
return
|
|
|
elif active_invoices == []:
|
|
|
- accounting_log.info("(No active invoice for %s. No invoice/payment "
|
|
|
- "reconciliation needed.)."
|
|
|
- % str(member))
|
|
|
+ accounting_log.info(
|
|
|
+ "(No active invoice for {}. No invoice/payment ".format(member) +
|
|
|
+ "reconciliation needed.).")
|
|
|
return
|
|
|
|
|
|
- accounting_log.info("Initiating reconciliation between "
|
|
|
- "invoice and payments for %s" % str(member))
|
|
|
+ accounting_log.info(
|
|
|
+ "Initiating reconciliation between invoice and payments for {}".format(
|
|
|
+ member))
|
|
|
|
|
|
while active_payments != [] and active_invoices != []:
|
|
|
|
|
@@ -534,8 +539,9 @@ def reconcile_invoices_and_payments(member):
|
|
|
# Assert that the invoice is still 'active'
|
|
|
assert p.invoice in active_invoices
|
|
|
i = p.invoice
|
|
|
- accounting_log.info("Payment is to be allocated specifically to " \
|
|
|
- "invoice %s" % str(i.number))
|
|
|
+ accounting_log.info(
|
|
|
+ "Payment is to be allocated specifically to invoice {}".format(
|
|
|
+ i.number))
|
|
|
else:
|
|
|
i = active_invoices[0]
|
|
|
|
|
@@ -591,15 +597,19 @@ def payment_changed(sender, instance, created, **kwargs):
|
|
|
def invoice_changed(sender, instance, created, **kwargs):
|
|
|
|
|
|
if created:
|
|
|
- accounting_log.info("Creating draft invoice %s (Member: %s)."
|
|
|
- % ('DRAFT-{}'.format(instance.pk), instance.member))
|
|
|
+ accounting_log.info(
|
|
|
+ "Creating draft invoice DRAFT-{} (Member: {}).".format(
|
|
|
+ instance.pk, instance.member))
|
|
|
else:
|
|
|
if not instance.validated:
|
|
|
- accounting_log.info("Updating draft invoice %s (Member: %s)."
|
|
|
- % (instance.number, instance.member))
|
|
|
+ accounting_log.info(
|
|
|
+ "Updating draft invoice DRAFT-{} (Member: {}).".format(
|
|
|
+ instance.number, instance.member))
|
|
|
else:
|
|
|
- accounting_log.info("Updating invoice %s (Member: %s, Total amount: %s, Amount paid: %s)."
|
|
|
- % (instance.number, instance.member, instance.amount(), instance.amount_paid() ))
|
|
|
+ accounting_log.info(
|
|
|
+ "Updating invoice {} (Member: {}, Total amount: {}, Amount paid: {}).".format(
|
|
|
+ instance.number, instance.member,
|
|
|
+ instance.amount(), instance.amount_paid()))
|
|
|
|
|
|
@receiver(post_delete, sender=PaymentAllocation)
|
|
|
def paymentallocation_deleted(sender, instance, **kwargs):
|
|
@@ -608,7 +618,7 @@ def paymentallocation_deleted(sender, instance, **kwargs):
|
|
|
|
|
|
# Reopen invoice if relevant
|
|
|
if (invoice.amount_remaining_to_pay() > 0) and (invoice.status == "closed"):
|
|
|
- accounting_log.info("Reopening invoice %s ..." % invoice.number)
|
|
|
+ accounting_log.info("Reopening invoice {} ...".format(invoice.number))
|
|
|
invoice.status = "open"
|
|
|
invoice.save()
|
|
|
|
|
@@ -616,9 +626,9 @@ def paymentallocation_deleted(sender, instance, **kwargs):
|
|
|
@receiver(post_delete, sender=Payment)
|
|
|
def payment_deleted(sender, instance, **kwargs):
|
|
|
|
|
|
- accounting_log.info("Deleted payment %s (Date: %s, Member: %s, Amount: %s, Label: %s)."
|
|
|
- % (instance.pk, instance.date, instance.member,
|
|
|
- instance.amount, instance.label))
|
|
|
+ accounting_log.info(
|
|
|
+ "Deleted payment {} (Date: {}, Member: {}, Amount: {}, Label: {}).".forma(
|
|
|
+ instance.pk, instance.date, instance.member, instance.amount, instance.label))
|
|
|
|
|
|
member = instance.member
|
|
|
|