Skip to content

Commit 382aaee

Browse files
committed
contract view
1 parent 0d65767 commit 382aaee

File tree

4 files changed

+79
-14
lines changed

4 files changed

+79
-14
lines changed

app/views.py

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
)
2424

2525

26+
ICON_SIZE_BIG = 36
27+
ICON_SIZE_SMALL = 24
28+
29+
2630
class AppView(UserControl):
2731
def __init__(
2832
self,
@@ -177,10 +181,63 @@ def make_contact_view(contact: Contact):
177181
def make_contract_view(contract: Contract):
178182
return Card(
179183
content=Container(
180-
content=Row(
184+
content=Column(
181185
[
182-
Icon(icons.HISTORY_EDU),
183-
Text(contract.title),
186+
ListTile(
187+
leading=Icon(icons.HISTORY_EDU, size=ICON_SIZE_BIG),
188+
title=Text(contract.title),
189+
subtitle=Text(contract.client.name),
190+
trailing=PopupMenuButton(
191+
icon=icons.MORE_VERT,
192+
items=[
193+
PopupMenuItem(
194+
icon=icons.EDIT,
195+
text="Edit",
196+
),
197+
PopupMenuItem(
198+
icon=icons.DELETE,
199+
text="Delete",
200+
),
201+
],
202+
),
203+
),
204+
Column(
205+
[
206+
# date range
207+
Row(
208+
[
209+
Icon(icons.DATE_RANGE),
210+
Text(
211+
f"{contract.start_date} - {contract.end_date}"
212+
),
213+
]
214+
),
215+
Row(
216+
[
217+
Icon(icons.MONEY),
218+
Text(
219+
f"{contract.rate} {contract.currency} / {contract.unit}"
220+
),
221+
]
222+
),
223+
Row(
224+
[
225+
Icon(icons.PERCENT),
226+
Text(
227+
f"VAT rate: {(contract.VAT_rate) * 100:.0f} %"
228+
),
229+
]
230+
),
231+
Row(
232+
[
233+
Icon(icons.OUTGOING_MAIL),
234+
Text(
235+
f"billing cycle: {str(contract.billing_cycle)} \t term of payment: {contract.term_of_payment} days"
236+
),
237+
]
238+
),
239+
]
240+
),
184241
],
185242
),
186243
padding=12,

tuttle/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import email
44
from typing import Optional, List, Dict, Type
5-
from pydantic import constr, BaseModel
5+
from pydantic import constr, BaseModel, condecimal
66

77
import datetime
88
import hashlib
@@ -214,7 +214,7 @@ class Contract(SQLModel, table=True):
214214
default=None,
215215
foreign_key="client.id",
216216
)
217-
rate: Decimal = Field(
217+
rate: condecimal(decimal_places=2) = Field(
218218
description="Rate of remuneration",
219219
)
220220
currency: str # TODO: currency representation

tuttle/time.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33

44

55
class Cycle(enum.Enum):
6-
hourly = 0
7-
daily = 1
8-
weekly = 2
9-
monthly = 3
10-
quarterly = 4
11-
yearly = 5
6+
hourly = "hourly"
7+
daily = "daily"
8+
weekly = "weekly"
9+
monthly = "monthly"
10+
quarterly = "quarterly"
11+
yearly = "yearly"
12+
13+
def __str__(self):
14+
return str(self.value)
1215

1316

1417
class TimeUnit(enum.Enum):
15-
minute = 0
16-
hour = 1
17-
day = 2
18+
minute = "minute"
19+
hour = "hour"
20+
day = "day"
1821

1922
def to_timedelta(self):
2023
if self == TimeUnit.minute:
@@ -23,3 +26,6 @@ def to_timedelta(self):
2326
return datetime.timedelta(hours=1)
2427
elif self == TimeUnit.day:
2528
return datetime.timedelta(days=1)
29+
30+
def __str__(self):
31+
return str(self.value)

tuttle_tests/demo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
billing_cycle=time.Cycle.monthly,
117117
signature_date=datetime.date(2022, 2, 1),
118118
start_date=datetime.date(2022, 2, 1),
119+
end_date=datetime.date(2022, 12, 31),
119120
)
120121

121122
contract_two = Contract(
@@ -129,6 +130,7 @@
129130
billing_cycle=time.Cycle.monthly,
130131
signature_date=datetime.date(2022, 1, 1),
131132
start_date=datetime.date(2022, 1, 1),
133+
end_date=datetime.date(2022, 12, 31),
132134
)
133135

134136
# PROJECTS

0 commit comments

Comments
 (0)