def add_expense(self): item_name = self.item_name.text value = self.value.text exp_date = self.datelabel.text if item_name is None or item_name == '' or \ value is None or value == '' or \ exp_date is None or exp_date == '': self.lbl_message.text = 'Required input missing.' self.lbl_message.theme_text_color = 'Error' return item_id = Items.get_item(item_name=item_name, item_link=None) if item_id is None or item_id == 0: self.lbl_message.text = 'No Category/Sub-Category by this name. ' \ 'Please create if required from Items screen.' self.lbl_message.theme_text_color = 'Error' return if value == '0': self.lbl_message.text = 'Enter an amount not equal to 0' self.lbl_message.theme_text_color = 'Error' return expense_id = Expenses.get_next_exp_id() kwargs = {'expense_id': expense_id, 'item_id': item_id, 'value': float(value), 'date': exp_date} Expenses.add_expense(**kwargs) toast('Expense Added') self.leave_screen()
def add_expense(self): item_name = self.item_name.text value = self.value.text exp_date = self.datelabel.text if (item_name is None or item_name == "" or value is None or value == "" or exp_date is None or exp_date == ""): self.lbl_message.text = "Required input missing." self.lbl_message.theme_text_color = "Error" return item_id = Items.get_item(item_name=item_name, item_link=None) if item_id is None or item_id == 0: self.lbl_message.text = ( "No Category/Sub-Category by this name. " "Please create if required from Items screen.") self.lbl_message.theme_text_color = "Error" return if value == "0": self.lbl_message.text = "Enter an amount not equal to 0" self.lbl_message.theme_text_color = "Error" return expense_id = Expenses.get_next_exp_id() kwargs = { "expense_id": expense_id, "item_id": item_id, "value": float(value), "date": exp_date, } Expenses.add_expense(**kwargs) toast("Expense Added") self.leave_screen()