-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
15.create add account functionality #7
Conversation
account/account.py
Outdated
account_name = CharField() | ||
balance = DecimalField(decimal_places=2) | ||
user_id = BigIntegerField() | ||
currency = CharField() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currency_id
lub currency_code
account/account.py
Outdated
account_name: str, | ||
balance: float, | ||
user_id: int, | ||
currency: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currency_id
lub currency_code
account/account.py
Outdated
account_name=account_name, | ||
balance=balance, | ||
user_id=user_id, | ||
currency=currency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currency_id
lub currency_code
account_id = AutoField() | ||
account_number = CharField(unique=True) | ||
account_name = CharField() | ||
balance = DecimalField(decimal_places=2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maksymalnie (i minimalnie) 10 miliardów bez grosza dla jednego konta 😁
Typ/klasa decimal jest też w pythonie. Na pierwszym spotkaniu rozmawialiśmy, że wartości takie jak pieniądze najlepiej przechowywać w najmniejszej jednostce waluty jako liczby całkowite. Tak też jest zaimplementowana klasa Monetary, a liczba miejsc po przecinku wynika z parametrów waluty. Tak więc musiałby być typ IntegerField
(+/- ~21,5 mln zł) lub BigIntegerField
- ~92 biliardy.
menu.py
Outdated
while True: | ||
account_number = input('Podaj numer konta: ') | ||
if len(account_number) != 26: | ||
print('Numer konta skłąda się z 26 cyfr.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Literówka w 'składa'
break | ||
while True: | ||
try: | ||
balance = float(input('Podaj aktualny stan konta: ')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jak wyżej - wartość całkowita.
Ponadto, udało mi się wpisać 3.456
, zostało to zapisane do bazy, gdzie w definicji klasy tu miały być tylko dwa miejsca po przecinku.
class Account(Model): | ||
DoesNotExist = None | ||
account_id = AutoField() | ||
account_number = CharField(unique=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jak zapiszemy gotówkę w portfelu i 'w skarpecie'? Jeśli za pomocą tej klasy, to mamy dwa konta bez numeru (innymi słowy, dwa konta o tym samym, unikalnym 'None' numerze konta). Przychodzą mi na myśl dwa pomysły:
- Flaga, czy konto ma numer IBAN, a jeśli tak to unikalny
- Dziedziczenie klas, jedna podstawowa bez numeru, a druga z obowiązkowym, unikalnym numerem IBAN.
Druga opcja pozwoliłaby dodawać konta inne niż z polskich banków (inna długość IBAN)
break | ||
while True: | ||
currency = input('Podaj w jaką walutę obsługuje konto: ').upper() | ||
if currency not in ['PLN', 'USD', 'EUR']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Listę obsługiwanych walut możnaby pobrać z katalogu Currencies
- są w branchu 33.*, czekają na PR
* File requirements.txt has been created * .gitignore has been added * main.py has been added * 1.create menu (#4) * Class Actions has been added * Function choose_action has been added * Function do_action has been added * Abstarct class MenuItem and child classes UserHandling and AccountHandling has been added. Class Menu has been added with method show_menu. * Showing menu has been looped. Option quit has been added and handled * Exception handling has been corrected, get_submenu_items has been added to examples of child classes * Communtcates for user have been improved * Abstract property methods have been added to MenuItem class * Language of communicates has been changed to polish. __init__ has been removed from child classes in example. * Method do_action has been added to all classes * File example.py has been refactored to menu * Comments have been added to class MenuItem * Type hints in class MenuItem have been corrected * Call exact action funcionality has been added. Method choose_menu_option has been added to class Menu. Code hase been refactored. * Unnecessary elses have been removed. * Example menu classes have been removed * 15.create add account functionality (#7) * Account file has been created * Account and Currency models have been declared * Class AccountMenu has been added to menu * Method add_account has been added * Method do_action has been added to AccountHandling class * Data validation has been added * Test data have been deleted * Refactor currency to currency_id * 19, 17, 20, 21, 22, 23, 24 - income_outcome (#5) Zadania Jiry nr 19, 17, 20, 21, 22, 23, 24, autorstwa Jarosław Mazur. * Helper.py has been created with class Helper. Method check_type has been added * InvalidData exception has been defined and import to menu.py * Refactor variable names and add type hints * Method check_length has been added * Unnecessary else has been removed * parameter error_message has been added to methods * add_account has been modified to use class Helper * Unnecessary import has been removed --------- Co-authored-by: Dmarzorro <[email protected]>
https://jira.is-academy.pl/secure/RapidBoard.jspa?rapidView=752&projectKey=JPYDZR6MON&view=detail&selectedIssue=JPYDZR6MON-15