Ejemplo n.º 1
0
 def add_obj(self):
     ed = SapyValues.get_value('end_date')
     o = objs.Objective(description=SapyValues.get_value('cause'),
                        duedate=ed)
     print('New Objective')
     print('------------------------------')
     print('|\tid\t|\tdescription\t\t|\tdue date\t|')
     print('|\t{}\t|\t{}\t|\t{}\t|'.format(o.id, o.description, o.duedate))
     print('------------------------------')
Ejemplo n.º 2
0
    def run(self):
        self.logger.debug("start")

        l = SapyValues.get_value('lom')

        ed = SapyValues.get_value('end_date')

        print('------------------------------')
        print(l.name)
        print('------------------------------')
        print(' balance : ' + str(l.balance(end_date=ed)))
        print('------------------------------')
        self.logger.debug("end")
Ejemplo n.º 3
0
    def run( self ):
        self.logger.debug("start")

        l = SapyValues.get_value('lom') 

        mlist = []
        with self.file.open('r') as data_file:
            data = csv.DictReader( data_file, fieldnames=[
                'date',
                'cause',
                'value'
            ] )

            for raw in data:
                
                
                
                mlist.append( moms.Mom( 
                    day = se.parse_date( raw['date'], self.logger ).day,
                    month = se.parse_date( raw['date'], self.logger ).month,
                    year = se.parse_date( raw['date'], self.logger ).year,
                    cause = raw['cause'],
                    value = float( raw['value'] )
                 ) ) 

        l.add(mlist)

        self.logger.debug("end")
Ejemplo n.º 4
0
 def add_tag(self):
     l = tags.Tag(name=SapyValues.get_value('name'))
     print('New Tag')
     print('------------------------------')
     print('|\tid\t|\tname\t|')
     print('|\t{}\t|\t{}\t|'.format(l.id, l.name))
     print('------------------------------')
Ejemplo n.º 5
0
 def add_lom(self):
     l = loms.Lom(name=SapyValues.get_value('name'))
     print('New Lom')
     print('------------------------------')
     print('|\tid\t|\tname\t|')
     print('|\t{}\t|\t{}\t|'.format(l.id, l.name))
     print('------------------------------')
Ejemplo n.º 6
0
    def database(self):
        # open db connection

        if not os.path.exists(self.cfg['private']['data']):
            db_iface.open()
            cur = db_iface.get_cursor()
            cur.execute(SapyValues.get_value('db.create.app_meta'))
            cur.execute(SapyValues.get_value('db.populate.app_meta'),
                        (SapyConstants.APP.VERSION, ))
            db_iface.commit()
            cur.close()
            moms.create_tables()
            loms.create_tables()
            tags.create_tables()
            objs.create_tables()
        else:
            db_iface.open()
Ejemplo n.º 7
0
    def run(self):
        self.logger.debug("start")
        sd = datetime.date(
            SapyValues.get_value("date").year,
            SapyValues.get_value("date").month, 1)

        ed = datetime.date(
            SapyValues.get_value("date").year,
            SapyValues.get_value("date").month,
            calendar.monthrange(
                SapyValues.get_value("date").year,
                SapyValues.get_value("date").month)[0])

        print("objectives this month was:")
        for o in objs.get_objs(self.logger):
            if o.duedate.month == SapyValues.get_value("date").month:
                print("|\t{}\t|\t{}\t|".format(o.description, o.duedate))

        #TODO ask for complete objectives

        l_real = loms.get_lom(name="real")

        l_b = l_real.balance(start_date=sd, end_date=ed)

        l_planned = loms.get_lom(name="expected")

        p_b = l_planned.balance(start_date=sd, end_date=ed)

        print("============================")
        print("expected balance :", p_b)
        print("real balance :", l_b)
        print("============================")

        self.logger.debug("end")
Ejemplo n.º 8
0
    def add_mom(self):
        mlist = []
        l = SapyValues.get_value('lom')

        sd = SapyValues.get_value('start_date')
        ed = SapyValues.get_value('end_date')
        f = SapyValues.get_value('frequency')

        if sd != ed and ed > sd and f:
            if f == SapyConstants.FREQUENCY.DAILY:
                step = datetime.timedelta(days=1)

            if f == SapyConstants.FREQUENCY.WEEKLY:
                step = datetime.timedelta(days=7)

            if f == SapyConstants.FREQUENCY.MONTHLY:
                step = datetime.timedelta(days=30)

            itr = datetime.timedelta(days=0)

            while itr + sd <= ed:
                mlist.append(
                    moms.Mom(value=SapyValues.get_value('value'),
                             cause=SapyValues.get_value('cause'),
                             year=(sd + itr).year,
                             month=(sd + itr).month,
                             day=(sd + itr).day))

                itr += step

        else:
            mlist.append(
                moms.Mom(value=SapyValues.get_value('value'),
                         cause=SapyValues.get_value('cause'),
                         year=sd.year,
                         month=sd.month,
                         day=sd.day))

        l.add(mlist)

        print('Lom')
        print('------------------------------')
        print('|\tid\t|\tname\t|')
        print('|\t{}\t|\t{}\t|'.format(l.id, l.name))
        print('------------------------------')
        print('New Moms')
        print('------------------------------')
        print('|\tid\t|\tvalue\t|\tcause\t|\tdate\t|')
        for m in mlist:
            print('|\t{}\t|\t{}\t|\t{}\t|\t{}\t|'.format(
                m.id, m.value, m.cause, m.time))
        print('------------------------------')
Ejemplo n.º 9
0
    def list_mom(self):
        sd = SapyValues.get_value('start_date')
        ed = SapyValues.get_value('end_date')

        if sd == ed:
            sd = datetime.datetime.today().date() - datetime.timedelta(days=15)
            ed = datetime.datetime.today().date() + datetime.timedelta(days=15)

        l = SapyValues.get_value('lom')

        print('------------------------------')
        print(l.name)
        print('------------------------------')
        print('\tid\t|\ttime\t|\tvalue\t|\tcause\t')
        for m in l.get_moms(start_date=sd, end_date=ed):
            print('\t{}\t|\t{}\t|\t{}\t|\t{}\t'.format(m.id, m.time, m.value,
                                                       m.cause))
        print('------------------------------')
        print(' balance : ' + str(l.balance(sd, ed)))
        print('------------------------------')
Ejemplo n.º 10
0
    def run(self):
        self.logger.debug("start")

        self.id2rm = SapyValues.get_value('id')

        if self.target == 'mom':
            self.rm_mom()
        elif self.target == 'lom':
            self.rm_lom()
        elif self.target == 'obj':
            self.rm_obj()
        elif self.target == 'tag':
            self.rm_tag()
        else:
            print('invalid targget :{}'.format(self.target))

        self.logger.debug("end")
Ejemplo n.º 11
0
 def rm_mom(self):
     l = SapyValues.get_value('lom')
     mlist = l.get_moms(id=self.id2rm)
     mlist[0].delete()