File tree Expand file tree Collapse file tree 4 files changed +79
-14
lines changed Expand file tree Collapse file tree 4 files changed +79
-14
lines changed Original file line number Diff line number Diff line change 23
23
)
24
24
25
25
26
+ ICON_SIZE_BIG = 36
27
+ ICON_SIZE_SMALL = 24
28
+
29
+
26
30
class AppView (UserControl ):
27
31
def __init__ (
28
32
self ,
@@ -177,10 +181,63 @@ def make_contact_view(contact: Contact):
177
181
def make_contract_view (contract : Contract ):
178
182
return Card (
179
183
content = Container (
180
- content = Row (
184
+ content = Column (
181
185
[
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
+ ),
184
241
],
185
242
),
186
243
padding = 12 ,
Original file line number Diff line number Diff line change 2
2
3
3
import email
4
4
from typing import Optional , List , Dict , Type
5
- from pydantic import constr , BaseModel
5
+ from pydantic import constr , BaseModel , condecimal
6
6
7
7
import datetime
8
8
import hashlib
@@ -214,7 +214,7 @@ class Contract(SQLModel, table=True):
214
214
default = None ,
215
215
foreign_key = "client.id" ,
216
216
)
217
- rate : Decimal = Field (
217
+ rate : condecimal ( decimal_places = 2 ) = Field (
218
218
description = "Rate of remuneration" ,
219
219
)
220
220
currency : str # TODO: currency representation
Original file line number Diff line number Diff line change 3
3
4
4
5
5
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 )
12
15
13
16
14
17
class TimeUnit (enum .Enum ):
15
- minute = 0
16
- hour = 1
17
- day = 2
18
+ minute = "minute"
19
+ hour = "hour"
20
+ day = "day"
18
21
19
22
def to_timedelta (self ):
20
23
if self == TimeUnit .minute :
@@ -23,3 +26,6 @@ def to_timedelta(self):
23
26
return datetime .timedelta (hours = 1 )
24
27
elif self == TimeUnit .day :
25
28
return datetime .timedelta (days = 1 )
29
+
30
+ def __str__ (self ):
31
+ return str (self .value )
Original file line number Diff line number Diff line change 116
116
billing_cycle = time .Cycle .monthly ,
117
117
signature_date = datetime .date (2022 , 2 , 1 ),
118
118
start_date = datetime .date (2022 , 2 , 1 ),
119
+ end_date = datetime .date (2022 , 12 , 31 ),
119
120
)
120
121
121
122
contract_two = Contract (
129
130
billing_cycle = time .Cycle .monthly ,
130
131
signature_date = datetime .date (2022 , 1 , 1 ),
131
132
start_date = datetime .date (2022 , 1 , 1 ),
133
+ end_date = datetime .date (2022 , 12 , 31 ),
132
134
)
133
135
134
136
# PROJECTS
You can’t perform that action at this time.
0 commit comments