Skip to content

Commit c856045

Browse files
committed
invoice and timesheet rendering
1 parent 9dbc61a commit c856045

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

templates/invoice-anvil/invoice.html

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,15 @@
4141
{{ invoice.contract.client.invoicing_contact.address.html }}
4242
</td>
4343
<td>
44-
{{ user.name }}<br>
44+
<big>{{ user.name }}</big><br>
45+
{{ user.subtitle }}<br>
46+
<br>
4547
{{ user.address.html }}
48+
<br>
49+
<br>
50+
<span>{{ user.email}}</span><br>
51+
<span>{{ user.phone_number }}</span><br>
52+
<span>{{ user.website }}</span>
4653
</td>
4754
</tr>
4855
<tr>
@@ -60,8 +67,9 @@
6067
</tr>
6168
<tr>
6269
<td>
63-
Invoice Date: <strong>{{ invoice.date }}</strong><br>
64-
Invoice Number: <strong>{{ invoice.number }}</strong>
70+
<br>
71+
<big>Invoice Date: <strong>{{ invoice.date }}</strong></big> <br>
72+
<big>Invoice Number: <strong>{{ invoice.number }}<big></big></strong>
6573
</td>
6674
<td>
6775
</td>
@@ -84,7 +92,7 @@
8492
<tbody>
8593
{% for item in invoice.items %}
8694
<tr>
87-
<td>{{ item.date }}</td>
95+
<td>{{ item.start_date }} - {{ item.end_date }}</td>
8896
<td>{{ item.description }}</td>
8997
<td class="right">{{ item.quantity }}</td>
9098
<td class="right">{{ item.unit }}</td>
@@ -110,7 +118,7 @@
110118
<tr>
111119
<td class="payment-info">
112120
<div>
113-
Account No: <strong>{{ user.bank_account.IBAN }}</strong>
121+
IBAN: <strong>{{ user.bank_account.IBAN }}</strong><br>
114122
</div>
115123
</td>
116124
<td class="bold">{{ invoice.due_date }}</td>
@@ -120,14 +128,22 @@
120128
</tbody>
121129
</table>
122130

131+
<div>
132+
<p>
133+
<br>
134+
<span>Thank you for your business</span>
135+
</p>
136+
<br>
137+
<br>
138+
<hr align="left" width="25%">
139+
{{ user.name }}
140+
</div>
141+
123142
<div class="footer">
124143
<div class="footer-info">
125-
<span>{{ user.e_mail}}</span> |
126-
<span>{{ user.phone_number }}</span> |
127-
<span>{{ user.website }}</span>
128-
</div>
129-
<div class="footer-thanks">
130-
<span>Thank you!</span>
144+
<span>IBAN: {{ user.bank_account.IBAN }} </span> |
145+
<span>BIC: {{ user.bank_account.BIC }}</span> |
146+
<span>VAT No: {{ user.VAT_number }}</span>
131147
</div>
132148
</div>
133149

templates/timesheet-anvil/timesheet.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@
103103

104104
<div class="footer">
105105
<div class="footer-info">
106-
<span>{{ user.e_mail}}</span> |
107-
<span>{{ user.phone_number }}</span> |
108-
<span>{{ user.website }}</span>
109106
</div>
110107
</div>
111108

tuttle/invoicing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def generate_invoice(
2828
total_hours = timesheet.total / pandas.Timedelta("1h")
2929
item = InvoiceItem(
3030
invoice=invoice,
31-
date=date,
31+
start_date=timesheet.table["begin"].min().date(),
32+
end_date=timesheet.table["end"].max().date(),
3233
quantity=total_hours,
3334
unit="hour",
3435
unit_price=timesheet.project.contract.rate,

tuttle/model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,10 @@ def client(self):
361361
class InvoiceItem(SQLModel, table=True):
362362
id: Optional[int] = Field(default=None, primary_key=True)
363363
# date and time
364-
date: datetime.date
364+
start_date: datetime.date = Field(description="Start date of the invoice item.")
365+
end_date: Optional[datetime.date] = Field(
366+
description="End date of the invoice item."
367+
)
365368
#
366369
quantity: int
367370
unit: str

tuttle/rendering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def as_percentage(number):
8383
return html
8484
else:
8585
# write invoice html
86-
prefix = f"Invoice-{invoice.number}"
86+
prefix = f"{invoice.number}-{invoice.client.name.lower()}"
8787
invoice_dir = Path(out_dir) / Path(prefix)
8888
invoice_dir.mkdir(parents=True, exist_ok=True)
8989
invoice_path = invoice_dir / Path(f"{prefix}.html")

0 commit comments

Comments
 (0)