diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index f3b1777d..0c42ae86 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -247,8 +247,8 @@ class Regie(models.Model): notification_reminder_id = self.get_notification_reminder_id(invoice) if pay_limit_date < now: # invoice is out of date - Notification.forget(user, notification_id) - Notification.forget(user, notification_reminder_id) + Notification.objects.find(user, notification_id).forget() + Notification.objects.find(user, notification_reminder_id).forget() else: # invoice can be paid if pay_limit_date > now + remind_delta: diff --git a/tests/test_notification.py b/tests/test_notification.py index c9ddd376..6e2032b9 100644 --- a/tests/test_notification.py +++ b/tests/test_notification.py @@ -318,6 +318,16 @@ def test_notify_remote_items(mock_get, app, user, user2, regie): 'created': creation_date, 'pay_limit_date': pay_limit_date, 'has_pdf': False, + }, + { + + 'id': 'O5', + 'label': '050505', + 'total_amount': '24', + 'amount': '24', + 'created': (invoice_now - timedelta(days=25)).date().isoformat(), + 'pay_limit_date': (invoice_now - timedelta(days=10)).date().isoformat(), + 'has_pdf': False, } ] }, @@ -387,12 +397,12 @@ def test_notify_remote_items(mock_get, app, user, user2, regie): assert Notification.objects.exclude(external_id__startswith='invoice-%s:reminder-' % regie.slug) \ .visible().count() == 0 assert Notification.objects.filter(external_id__startswith='invoice-%s:reminder-' % regie.slug) \ - .visible().new().count() == 2 - assert Notification.objects.count() == 4 + .visible().new().count() == 3 + assert Notification.objects.count() == 5 # url appeared on new reminder notifications - assert len([notif for notif in Notification.objects.all() if notif.url == page.get_online_url()]) == 2 + assert len([notif for notif in Notification.objects.all() if notif.url == page.get_online_url()]) == 3 # be sure the are no more reminders created regie.notify_new_remote_invoices() - assert Notification.objects.count() == 4 + assert Notification.objects.count() == 5