Пример #1
0
    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
Пример #2
0
 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
Пример #3
0
 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    
Пример #4
0
 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()
Пример #5
0
 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()
Пример #6
0
    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()
Пример #7
0
 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()
Пример #8
0
 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()
Пример #9
0
    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()
Пример #10
0
    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
Пример #11
0
    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
Пример #12
0
    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
Пример #13
0
    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
Пример #14
0
    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
Пример #15
0
    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)
Пример #16
0
    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)