1
+ from decimal import Decimal
1
2
from django .utils import timezone
2
3
from django .conf import settings
3
- from holviapp .utils import list_invoices , get_invoice
4
- from holviapi .utils import barcode
4
+ from holviapp .utils import list_invoices
5
+ from holviapi .utils import barcode as bank_barcode
5
6
from .models import NotificationSent
6
7
from django .core .mail import EmailMessage
7
8
from django .template import Context
10
11
class HolviOverdueInvoicesHandler (object ):
11
12
def process_overdue (self , send = False ):
12
13
barcode_iban = settings .HOLVI_BARCODE_IBAN
13
- if not barcode_iban :
14
- raise RuntimeError ('HOLVI_BARCODE_IBAN is not configured' )
15
14
body_template = get_template ('velkoja/notification_email_body.jinja' )
16
15
subject_template = get_template ('velkoja/notification_email_subject.jinja' )
17
16
overdue = list_invoices (status = 'overdue' )
@@ -28,7 +27,10 @@ def process_overdue(self, send=False):
28
27
29
28
if send :
30
29
invoice .send ()
31
- barcode = barcode (barcode_iban , invoice .rf_reference , invoice .due_sum )
30
+
31
+ barcode = None
32
+ if barcode_iban :
33
+ barcode = bank_barcode (barcode_iban , invoice .rf_reference , Decimal (invoice .due_sum ))
32
34
33
35
mail = EmailMessage ()
34
36
mail .subject = subject_template .render (Context ({ "invoice" : invoice , "barcode" : barcode })).strip ()
0 commit comments