Example #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
Example #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
Example #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    
Example #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()
Example #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()
Example #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()
Example #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()
Example #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()
Example #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()
Example #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
Example #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
Example #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
Example #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
Example #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
Example #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)
Example #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)