Ejemplo n.º 1
0
    def add_run_clicked(self, latest_run_tag):
        latest_run = PayRun.get(latest_run_tag)
        run_tag = latest_run.next_tag()
        pay_period = PayRun.pay_period(run_tag)

        from controllers import VistaController
        vc = VistaController()
        self.save_run(vc.get_payrun_records(pay_period))
Ejemplo n.º 2
0
    def test_get_one(self):
        run = PayRun.get_one(1)
        self.assertEqual('13-15-015', str(run))
        self.assertEqual(39, len(run.records))
        self.assertEqual(0, len(run.diffs))

        run = PayRun.get_one(10)
        self.assertEqual('15-22-016', str(run))
        self.assertEqual(91, len(run.records))
        self.assertEqual(73, len(run.diffs))
Ejemplo n.º 3
0
def import_data():
    path = 'c:\\bench\\payrun\\pyvista\\fms\\tests\\run'
    runs = [
        {'ien': '559', 'fy': 13, 'pp': 15, 'cp': '015'},
        {'ien': '559', 'fy': 13, 'pp': 15, 'cp': '016'},
        {'ien': '560', 'fy': 13, 'pp': 16, 'cp': '015'},
        {'ien': '560', 'fy': 13, 'pp': 16, 'cp': '016'},
        {'ien': '616', 'fy': 15, 'pp': 20, 'cp': '015'},
        {'ien': '616', 'fy': 15, 'pp': 20, 'cp': '016'},
        {'ien': '617', 'fy': 15, 'pp': 21, 'cp': '015'},
        {'ien': '617', 'fy': 15, 'pp': 21, 'cp': '016'},
        {'ien': '618', 'fy': 15, 'pp': 22, 'cp': '015'},
        {'ien': '618', 'fy': 15, 'pp': 22, 'cp': '016'},
        {'ien': '619', 'fy': 15, 'pp': 23, 'cp': '015'},
        {'ien': '619', 'fy': 15, 'pp': 23, 'cp': '016'}
    ]
    with db.atomic():
        PayRun.insert_many(runs).execute()

    runs = [run for run in PayRun.select()]

    for run in runs:
        print('%d: %s: %s' % (run.id, run.ien, str(run)))
        filename = path + run.ien + '_' + run.cp + '.txt'
        f = open(filename)
        dta = f.readlines()
        f.close()

        for line in dta:
            if line[0].isdigit():
                emp = make_emp(line, run.cp)
                rec = make_rec(line.rstrip(), run.id, emp.id)

        prev_run_id = run.get_previous_run_id()
        if prev_run_id:
            print('getting rex...')
            rex = [rec for rec in run.records]
            print('%d rex' % len(rex))
            for rec in rex:
                print('rec: %d' % rec.id)
                rec.make_diffs(prev_run_id)
Ejemplo n.º 4
0
 def save_run(self, pay_period, run):
     for cp in run:
         tag = '%s-%s' % (pay_period, cp)
         for rec in run[cp]:
             rec['PAYRUN'] = tag
             self.db.payrun_records.insert(rec)
         payrun = PayRun(self.db, {'tag': tag})
         payrun.rex = run[cp]
         payrun.make_diffs()
         payrun.save()
Ejemplo n.º 5
0
 def test_get_previous_records(self):
     run = PayRun.get_by_tag('15-23-016')
     rex = run._get_previous_records()
     self.assertEqual(91, len(rex))
Ejemplo n.º 6
0
 def test_get_previous_run_id(self):
     run = PayRun.get_by_tag('15-22-016')
     run_id = run.get_previous_run_id()
     self.assertEqual(8, run_id)
Ejemplo n.º 7
0
 def test_get_by_tag(self):
     run = PayRun.get_by_tag('15-22-016')
     self.assertEqual('15-22-016', str(run))
     self.assertEqual(91, len(run.records))
     self.assertEqual(73, len(run.diffs))
Ejemplo n.º 8
0
 def test_get_all(self):
     runs = PayRun.get_all()
     self.assertEqual(12, len(runs))
Ejemplo n.º 9
0
 def payrun_selected(self, tag_str):
     self.run = PayRun.get_by_tag(tag_str)
     self.load_employees()
     self.widget.add_diffs_widget(PayDiffsWidget(self.run.diffs))
Ejemplo n.º 10
0
 def load_payruns(self):
     self.payruns = PayRun.get_all()
     if self.payruns:
         self.widget.load_payruns(self.payruns)
         self.widget.select_payrun(0)