-
Notifications
You must be signed in to change notification settings - Fork 0
sprint-3 #9
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
base: master
Are you sure you want to change the base?
sprint-3 #9
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| class OnlineSalesRegisterCollector: | ||
|
|
||
| def __init__(self): | ||
| self.__name_items = [] | ||
| self.__number_items = 0 | ||
| self.__item_price = {'чипсы': 50, 'кола': 100, 'печенье': 45, 'молоко': 55, 'кефир': 70} | ||
| self.__tax_rate = {'чипсы': 20, 'кола': 20, 'печенье': 20, 'молоко': 10, 'кефир': 10} | ||
|
|
||
| @property | ||
| def get_name_items(self): | ||
| return self.__name_items | ||
|
|
||
| @property | ||
| def get_number_items(self): | ||
| return self.__number_items | ||
|
|
||
| def add_item_to_cheque(self, name): | ||
| if len(name) != 0 or len(name) < 40: | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: условие составлено не верно There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Коммент необходимо описать более развернуто, указать, что именно мы получим при такой реализации условия, а что мы должны быти получить по заданию, чтобы дать студенту направление мысли для исправления |
||
| raise ValueError('Нельзя добавить товар, если в его названии нет символов или их больше 40') | ||
| else: | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: отсутствует проверка наличия товара в справочнике |
||
| self.__name_items.append(name) | ||
| self.__number_items += 1 | ||
|
|
||
| def delete_item_from_check(self, name): | ||
| if name in self.__name_items: | ||
| self.__name_items.remove(name) | ||
| self.__number_items -= 1 | ||
| else: | ||
| raise NameError('Позиция отсутствует в чеке') | ||
|
|
||
| def check_amount(self): | ||
| total = [] | ||
| for i in range(len(self.__name_items)): | ||
| if self.__name_items[i] in self.__item_price: | ||
| total.append(self.__item_price.get(self.__name_items[i])) | ||
| if len(self.__name_items) > 10: | ||
| return sum(total) - (sum(total) * 10) / 100 | ||
| else: | ||
| return sum(total) * 0.9 | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: в данном случае должна возвращаться полная стоимость товаров |
||
|
|
||
| def twenty_percent_tax_calculation(self): | ||
| twenty_percent_tax = [] | ||
| for i in range(0, len(self.__name_items)): | ||
| if self.__name_items[i] in self.__tax_rate: | ||
| if self.__tax_rate.get(self.__name_items[i]) == 20: | ||
| twenty_percent_tax.append(self.__name_items[i]) | ||
| total = [] | ||
| for i in range(0, len(twenty_percent_tax)): | ||
| if twenty_percent_tax[i] in self.__item_price: | ||
| total.append(self.__item_price.get(twenty_percent_tax[i])) | ||
| if len(twenty_percent_tax) > 10: | ||
| return (sum(total) - (sum(total) * 10) / 100) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Отсутствует коммент: Нужно исправить: применена формула для расчета 10% ндс а не 20 по методу |
||
| else: | ||
| return sum(total) | ||
|
Comment on lines
+51
to
+54
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: не верная формула расчета НДС. Рассчитана полная стоимость всех позиций |
||
|
|
||
| def ten_percent_tax_calculation(self): | ||
| ten_percent_tax = [] | ||
| for i in range(0, len(self.__name_items)): | ||
| if self.__name_items[i] in self.__tax_rate: | ||
| if self.__tax_rate.get(self.__name_items[i]) == 20: | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: неверное условие фильтрации |
||
| ten_percent_tax.append(self.__name_items[i]) | ||
| total = [] | ||
| for i in range(0, len(ten_percent_tax)): | ||
| if ten_percent_tax[i] in self.__item_price: | ||
| total.append(self.__item_price.get(ten_percent_tax[i])) | ||
| if len(ten_percent_tax) > 10: | ||
| return (sum(total) - (sum(total) * 10) / 100) | ||
| else: | ||
| return sum(total) | ||
|
Comment on lines
+66
to
+69
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: не верная формула расчета НДС. Рассчитана полная стоимость всех позиций |
||
|
|
||
| def total_tax(self): | ||
| return OnlineSalesRegisterCollector.ten_percent_tax_calculation() + OnlineSalesRegisterCollector.twenty_percent_tax_calculation() | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: для вызова данных методов необходимо создать экземпляр класса, а раз вызов происходит внутри класса, то вызов должен происходить через self There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Коммент дает студенту вариативность написания, что является неверным. Создавать экземпляр класса внутри методов этого же класса нельзя, корректным будет только обращение через self |
||
|
|
||
| @staticmethod | ||
| def get_telephone_number(telephone_number): | ||
| if len(str(telephone_number)) > 10: | ||
| raise ValueError('Необходимо ввести 10 цифр после "+7"') | ||
| try: | ||
| float(telephone_number) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: необходимо проверять является ли введенное значение целочисленным. Лучше всего для этого подойдет функция isinstance |
||
| except ValueError: | ||
| raise ValueError('Необходимо ввести цифры') from None | ||
| return f'+7{telephone_number}' | ||
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.
Можно лучше: название пропертей стоит давать по названию атрибута