11"""Tests for the invoice module."""
22
33import datetime
4+ from decimal import Decimal
45from pathlib import Path
56
67from tuttle import invoicing , timetracking , rendering
@@ -12,36 +13,39 @@ def test_invoice():
1213 the_invoice = Invoice (
1314 number = "27B-6" ,
1415 date = datetime .date .today (),
15- due_date = datetime .date .today () + datetime .timedelta (days = 14 ),
16- sent_date = datetime .date .today (),
1716 sent = True ,
18- paid = "foo" ,
17+ paid = False ,
1918 cancelled = False ,
2019 )
2120
2221 item_1 = InvoiceItem (
2322 invoice = the_invoice ,
24- date = datetime .date .today (),
23+ start_date = datetime .date .today (),
24+ end_date = datetime .date .today (),
2525 quantity = 10 ,
2626 unit = "hours" ,
27- unit_price = 50 ,
27+ unit_price = Decimal ( 50 ) ,
2828 description = "work work" ,
29- VAT_rate = 0.20 ,
29+ VAT_rate = Decimal ( 0.20 ) ,
3030 )
3131
3232 item_2 = InvoiceItem (
3333 invoice = the_invoice ,
34- date = datetime .date .today (),
34+ start_date = datetime .date .today (),
35+ end_date = datetime .date .today (),
3536 quantity = 10 ,
3637 unit = "hours" ,
37- unit_price = 100 ,
38+ unit_price = Decimal ( 100 ) ,
3839 description = "work work" ,
39- VAT_rate = 0.20 ,
40+ VAT_rate = Decimal ( 0.20 ) ,
4041 )
4142
42- assert the_invoice .sum == 1500
43- assert the_invoice .VAT_total == 300
44- assert the_invoice .total == 1800
43+ assert item_1 .invoice == the_invoice
44+ assert item_2 .invoice == the_invoice
45+
46+ assert the_invoice .sum == Decimal (1500 )
47+ assert the_invoice .VAT_total == Decimal (300 )
48+ assert the_invoice .total == Decimal (1800 )
4549
4650
4751def test_generate_invoice (
0 commit comments