def getMoneyStat(self, filter_dict, currency, user): moneyio_list = MoneyIO.all() if filter_dict: for filter_key in filter_dict.keys(): moneyio_list = moneyio_list.filter(filter_key, filter_dict[filter_key]) moneyio_list.filter('currency', currency) if user: moneyio_list = moneyio_list.filter('user', user) moneystat = None if moneyio_list.count() > 0: moneystat = MoneyStat(total_income=0, total_expense=0, currency=currency, income_dict={}, expense_dict={}) for moneyio in moneyio_list: moneystat.addMoneyIO(moneyio) for income_key in moneystat.income_dict.keys(): moneystat.total_income = moneystat.total_income + moneystat.income_dict[ income_key] for expense_key in moneystat.expense_dict.keys(): moneystat.total_expense = moneystat.total_expense + moneystat.expense_dict[ expense_key] return moneystat
def getMoneyIO(self, id, user): moneyio = None try: moneyio = MoneyIO.get_by_id(int(id)) if moneyio.user.id <> user.id: moneyio = None except: moneyio = None return moneyio
def deleteAlarm(self, id, user): alarm = self.getAlarm(id, user) if alarm: moneyiotemplate_list = MoneyIOTemplate.all().filter('alarm', alarm) for moneyiotemplate in moneyiotemplate_list: moneyiotemplate.delete() moneyio_list = MoneyIO.all().filter('alarm', alarm) for moneyio in moneyio_list: moneyio.alarm = None moneyio.put() alarm.delete()
def deleteMoneyIOUserType(self, id, user): moneyiousertype = self.getMoneyIOUserType(id, user) if moneyiousertype: #Create a new base money io type if it does not exist basemoneytype = self.getBaseMoneyIOUserType(moneyiousertype) moneyio_list = MoneyIO.all().filter('moneyiotype', moneyiousertype) for moneyio in moneyio_list: moneyio.moneyiotype = basemoneytype moneyio.put() moneyiousertype.delete()
def getMoneyIOCount(self, filter_dict, user): moneyio_list = MoneyIO.all() if filter_dict: for filter_key in filter_dict.keys(): moneyio_list = moneyio_list.filter(filter_key, filter_dict[filter_key]) if user: moneyio_list = moneyio_list.filter('user', user) return moneyio_list.count()
def getMoneyIOListForData(self, filter_dict, orderby, pagesize, pagecount, user): moneyio_list = MoneyIO.all() if filter_dict: for filter_key in filter_dict.keys(): moneyio_list = moneyio_list.filter(filter_key, filter_dict[filter_key]) if user: moneyio_list = moneyio_list.filter('user', user) if orderby: moneyio_list = moneyio_list.order(orderby) if pagesize > 0: moneyio_list = moneyio_list.fetch(pagesize, pagesize * (pagecount-1)) return moneyio_list
def getMoneyIOListForData(self, filter_dict, orderby, pagesize, pagecount, user): moneyio_list = MoneyIO.all() if filter_dict: for filter_key in filter_dict.keys(): moneyio_list = moneyio_list.filter(filter_key, filter_dict[filter_key]) if user: moneyio_list = moneyio_list.filter('user', user) if orderby: moneyio_list = moneyio_list.order(orderby) if pagesize > 0: moneyio_list = moneyio_list.fetch(pagesize, pagesize * (pagecount - 1)) return moneyio_list
def getMoneyIOList(self, filter_dict, orderby, pagesize, pagecount, user): moneyio_list = MoneyIO.all() if filter_dict: for filter_key in filter_dict.keys(): moneyio_list = moneyio_list.filter(filter_key, filter_dict[filter_key]) if user: moneyio_list = moneyio_list.filter('user', user) total_records = moneyio_list.count() moneyio_list = moneyio_list.order('-happentime') if orderby: moneyio_list = moneyio_list.order(orderby) if pagesize > 0: moneyio_list = moneyio_list.fetch(pagesize, pagesize * (pagecount-1)) return moneyio_list, total_records
def getMoneyIOList(self, filter_dict, orderby, pagesize, pagecount, user): moneyio_list = MoneyIO.all() if filter_dict: for filter_key in filter_dict.keys(): moneyio_list = moneyio_list.filter(filter_key, filter_dict[filter_key]) if user: moneyio_list = moneyio_list.filter('user', user) total_records = moneyio_list.count() moneyio_list = moneyio_list.order('-happentime') if orderby: moneyio_list = moneyio_list.order(orderby) if pagesize > 0: moneyio_list = moneyio_list.fetch(pagesize, pagesize * (pagecount - 1)) return moneyio_list, total_records
def getMoneyStat(self, filter_dict, currency, user): moneyio_list = MoneyIO.all() if filter_dict: for filter_key in filter_dict.keys(): moneyio_list = moneyio_list.filter(filter_key, filter_dict[filter_key]) moneyio_list.filter('currency', currency) if user: moneyio_list = moneyio_list.filter('user', user) moneystat = None if moneyio_list.count() > 0: moneystat = MoneyStat(total_income=0, total_expense=0, currency=currency, income_dict={}, expense_dict={}) for moneyio in moneyio_list: moneystat.addMoneyIO(moneyio) for income_key in moneystat.income_dict.keys(): moneystat.total_income = moneystat.total_income + moneystat.income_dict[income_key] for expense_key in moneystat.expense_dict.keys(): moneystat.total_expense = moneystat.total_expense + moneystat.expense_dict[expense_key] return moneystat
def addMoneyIO(self, account, happentime, moneyiotype, money, currency, isshare, description, user, alarm=None): moneyio = MoneyIO() moneyio.account = account moneyio.happentime = happentime moneyio.moneyiotype = moneyiotype moneyio.money = money moneyio.currency = currency moneyio.isshare = isshare moneyio.description = description if user: moneyio.user = user if alarm: moneyio.alarm = alarm moneyio.put() AccountService().updateAccountMoney(account, money, moneyiotype.isio)