예제 #1
0
 def update_expense(self, expense_uuid, new_expense):
     i = 0
     for idx, l_expense in enumerate(self._expenses):
         if 'expense_uuid' in l_expense:
             c_expense = Expense()
             c_expense.from_mongo(l_expense)
             if c_expense.expense_uuid == expense_uuid:
                 self._expenses[idx] = new_expense.json()
                 return [True, "expense found and updated"]
         i += 1
     return [False, "expense not found"]
예제 #2
0
    def delete_expense(self, _expense_uuid=None, delete_all: bool = False):
        i = 0
        if delete_all:
            self._expenses = []
            return [True, "deleted all events"]

        for idx, l_expense in enumerate(self._expenses):
            if 'expense_uuid' in l_expense:
                c_expense = Expense()
                c_expense.from_mongo(l_expense)
                if c_expense.expense_uuid == _expense_uuid:
                    del self._expenses[idx]
                    return [True, "expense found and deleted"]
            i += 1
        return [False, "expense not found"]