School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,31 @@
from domain.domain import Expense
from repositories.repository import Repository
class Services():
def __init__(self,repo:Repository) -> None:
self.repo=repo
self.undos=0
def add_expense(self,day,money,type_of_expense):
"""
:params:
day - integer between 1 and 30
money - positive integer
type_of_expense - string
The function creates a new Expense object and call the repository's insert_element method
The function increments the undo counter
"""
expense=Expense(day,money,type_of_expense)
self.repo.insert_element(expense)
self.undos+=1
def display_list(self):
return self.repo.get_elements()
def filter_list(self,value):
self.undos+=1
self.repo.filter_elements(value)
def undo(self):
if self.undos>0:
self.undos-=1
self.repo.undo()
else:
raise Exception("No more undos available")