Commit 0227df9a authored by jocelyn's avatar jocelyn

Merge branch 'fix-inline-paiment-creation' into 'master'

Fix inline paiement creation in the context of not using the auto accounting mechanism

Closes #210

See merge request !7
parents e1033cb5 35acd271
......@@ -426,6 +426,12 @@ class Payment(models.Model):
amount_to_pay = invoice.amount_remaining_to_pay()
amount_to_allocate = min(amount_can_pay, amount_to_pay)
if amount_to_allocate <= 0:
accounting_log.info(
"No amount to allocate from payment {} to invoice {}".format(
self.date, invoice.number))
return
accounting_log.info(
"Allocating {} from payment {} to invoice {}".format(
amount_to_allocate, self.date, invoice.number))
......@@ -597,7 +603,15 @@ def payment_changed(sender, instance, created, **kwargs):
# this member
if (created or instance.amount_not_allocated() != 0) \
and (instance.member is not None):
update_accounting_for_member(instance.member)
# Not using the auto-accounting module ... and apparently the user did chose explicitly to which invoice
if not settings.HANDLE_BALANCE and instance.invoice:
instance.allocate_to_invoice(instance.invoice)
# Otherwise, if we know to which member to use this payment for, we trigger an update of its accounting
elif instance.member is not None:
update_accounting_for_member(instance.member)
@receiver(post_save, sender=Invoice)
......
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