Esempio n. 1
0
def create_engineer_histories():
    for num in range(12):
        engineer_history = EngineerHistory(
            engineer_id=num + 1,
            payment_start_day=date(2015, 1, 1),
            payment_end_day=datetime.today().date() + timedelta(days=-1 + num),
            payment_per_month=num + 1,
            payment_site=Site.twenty_five,
            payment_tax=Tax.eight,
            payment_rule=Rule.fixed,
            payment_bottom_base_hour=num + 1,
            payment_top_base_hour=num + 2,
            payment_free_base_hour='',
            payment_per_hour='1/100, 1/150',
            payment_per_bottom_hour=num + 1,
            payment_per_top_hour=num + 2,
            payment_fraction=Fraction.hundred,
            payment_fraction_rule=Round.down,
            payment_condition='test' + str(num),
            remarks='test' + str(num),
            created_at=datetime.today(),
            created_user='******',
            updated_at=datetime.today(),
            updated_user='******')
        db.session.add(engineer_history)
    db.session.commit()
    engineer_history = EngineerHistory(
        engineer_id=3,
        payment_start_day=datetime.today().date() + timedelta(days=1),
        payment_end_day=date(2099, 12, 31),
        payment_per_month=3,
        payment_site=Site.twenty_five,
        payment_tax=Tax.eight,
        payment_rule=Rule.fixed,
        payment_bottom_base_hour=3,
        payment_top_base_hour=4,
        payment_free_base_hour='',
        payment_per_hour='1/100, 1/150',
        payment_per_bottom_hour=3,
        payment_per_top_hour=4,
        payment_fraction=Fraction.hundred,
        payment_fraction_rule=Round.down,
        payment_condition='test' + str(2),
        remarks='test' + str(2),
        created_at=datetime.today(),
        created_user='******',
        updated_at=datetime.today(),
        updated_user='******')
    db.session.add(engineer_history)
    db.session.commit()
    def test_get_histories_by_date_is_none(self):
        # set_up
        company = Company(
            company_name='会社',
            contract_date=datetime.today().strftime('%Y/%m/%d'),
            payment_site=Site.fifty,
            payment_tax=Tax.eight,
            created_at=datetime.today(),
            created_user='******',
            updated_at=datetime.today(),
            updated_user='******')
        db.session.add(company)
        db.session.commit()

        company_client_flag = CompanyClientFlag(
            company_id=company.id,
            client_flag=ClientFlag.bp,
            created_at=datetime.today(),
            created_user='******',
            updated_at=datetime.today(),
            updated_user='******')
        db.session.add(company_client_flag)
        db.session.commit()

        engineer = Engineer(
            engineer_name='エンジニア',
            company_id=company.id,
            created_at=datetime.today(),
            created_user='******',
            updated_at=datetime.today(),
            updated_user='******')
        db.session.add(engineer)
        db.session.commit()

        history = EngineerHistory(
            engineer_id=engineer.id,
            payment_start_day=date(2016, 1, 1),
            payment_end_day=date(2016, 12, 31),
            payment_per_month=600000,
            payment_rule=Rule.fixed,
            payment_site=engineer.company.payment_site,
            payment_tax=engineer.company.payment_tax,
            created_at=datetime.today(),
            created_user='******',
            updated_at=datetime.today(),
            updated_user='******')
        db.session.add(history)
        db.session.commit()

        self.assertIsNone(engineer.get_payment_site_by_date(date(2017, 1, 1)))
    def test_delete_engineer_history(self):
        # 削除用のエンジニアを登録
        engineer_history = EngineerHistory(engineer_id=1,
                                           payment_start_day=date(2017, 1, 1),
                                           payment_end_day=date(2017, 2, 28),
                                           payment_site=Site.twenty_five,
                                           payment_tax=Tax.eight,
                                           payment_per_month=100000,
                                           payment_rule=Rule.fixed,
                                           created_at=datetime.today(),
                                           created_user='******',
                                           updated_at=datetime.today(),
                                           updated_user='******')
        db.session.add(engineer_history)
        db.session.commit()

        delete_engineer_history_id = engineer_history.id
        engineer_id = engineer_history.engineer_id

        # ログイン
        self.app.post('/login',
                      data={
                          'shain_number': 'test1',
                          'password': '******'
                      })
        engineer_history = self.engineer_history_repository.find_by_id(
            delete_engineer_history_id)

        result = self.app.get('/engineer/history/delete/' +
                              str(engineer_history.id))
        # 削除できることを確認
        self.assertEqual(result.status_code, 302)
        ok_('/engineer/detail/' +
            str(engineer_id) in result.headers['Location'])

        # 削除した履歴が存在しないことを確認
        engineer_history = self.engineer_history_repository.find_by_id(
            delete_engineer_history_id)
        self.assertIsNone(engineer_history.id)
Esempio n. 4
0
    def test_get_payment_detail_text(self):
        # set_up
        engineer_history = EngineerHistory(engineer_id=1,
                                           payment_start_day=date(2017, 1, 1),
                                           payment_end_day=date(2017, 2, 28),
                                           payment_site=Site.twenty_five,
                                           payment_tax=Tax.eight,
                                           payment_per_month=100000,
                                           payment_rule=Rule.variable,
                                           payment_per_top_hour=1000,
                                           payment_per_bottom_hour=2000,
                                           created_at=datetime.today(),
                                           created_user='******',
                                           updated_at=datetime.today(),
                                           updated_user='******')

        expected = "test0 氏  ¥100,000.-/月額"\
            + "\n        "\
            + "超過単価:¥1,000.-/H  "\
            + "欠業単価:¥2,000.-/H"

        # テスト対象のメソッドを実行
        text = self.bp_order_report.get_payment_detail_text(engineer_history)
        self.assertEqual(text, expected)
Esempio n. 5
0
 def create(self):
     return EngineerHistory()
Esempio n. 6
0
 def get_histories_by_date(self, date):
     for h in self.engineer_histories:
         if h.payment_start_day <= date <= h.payment_end_day:
             return h
     return EngineerHistory()
    def test_do_not_create_billing_when_billing_confirmation_money_none(self):
        before = len(self.project_billing_repository.find_all())
        # ログイン
        self.app.post('/login',
                      data={
                          'shain_number': 'test1',
                          'password': '******'
                      })

        # set_up
        project = Project(project_name='テスト',
                          project_name_for_bp='テスト',
                          status=Status.start,
                          recorded_department_id=1,
                          sales_person='営業担当',
                          estimation_no='do_not_create_bill',
                          end_user_company_id=4,
                          client_company_id=3,
                          start_date=date(2017, 1, 1),
                          end_date=date(2017, 12, 31),
                          contract_form=Contract.blanket,
                          billing_timing=BillingTiming.billing_at_last,
                          estimated_total_amount=1000000,
                          scope='test',
                          contents=None,
                          working_place=None,
                          delivery_place=None,
                          deliverables=None,
                          inspection_date=None,
                          responsible_person=None,
                          quality_control=None,
                          subcontractor=None,
                          remarks=None,
                          created_at=datetime.today(),
                          created_user='******',
                          updated_at=datetime.today(),
                          updated_user='******')
        db.session.add(project)
        db.session.commit()

        engineer = Engineer(engineer_name='エンジニア',
                            company_id=5,
                            created_at=datetime.today(),
                            created_user='******',
                            updated_at=datetime.today(),
                            updated_user='******')
        db.session.add(engineer)
        db.session.commit()

        history = EngineerHistory(engineer_id=engineer.id,
                                  payment_start_day=date(2016, 1, 1),
                                  payment_end_day=date(2099, 12, 31),
                                  payment_per_month=600000,
                                  payment_rule=Rule.fixed,
                                  payment_site=engineer.company.payment_site,
                                  payment_tax=engineer.company.payment_tax,
                                  created_at=datetime.today(),
                                  created_user='******',
                                  updated_at=datetime.today(),
                                  updated_user='******')
        db.session.add(history)
        db.session.commit()

        result = self.app.post('/project/contract/create?project_id=' +
                               str(project.id),
                               data={
                                   'detail_type':
                                   DetailType.engineer,
                                   'engineer_id':
                                   engineer.id,
                                   'billing_money':
                                   '100000000',
                                   'billing_start_day':
                                   date(2017, 1, 1).strftime('%Y/%m'),
                                   'billing_end_day':
                                   date(2017, 3, 1).strftime('%Y/%m'),
                                   'billing_per_month':
                                   '100000',
                                   'billing_rule':
                                   Rule.fixed.value,
                                   'billing_fraction_rule':
                                   '',
                               })
        self.assertEqual(result.status_code, 302)
        ok_('/project/contract/detail/' in result.headers['Location'])
        project_detail_id = result.headers['Location'].split('/')[-1]

        result = self.app.post('/project/contract/' + str(project.id),
                               data={
                                   'status':
                                   Status.done.value,
                                   'recorded_department_id':
                                   project.recorded_department_id,
                                   'estimation_no':
                                   project.estimation_no,
                                   'project_name':
                                   project.project_name,
                                   'end_user_company_id':
                                   str(project.end_user_company_id),
                                   'client_company_id':
                                   str(project.client_company_id),
                                   'start_date':
                                   project.start_date.strftime('%Y/%m/%d'),
                                   'end_date':
                                   project.end_date.strftime('%Y/%m/%d'),
                                   'contract_form':
                                   project.contract_form.value,
                                   'billing_timing':
                                   project.billing_timing.value
                               })
        self.assertEqual(result.status_code, 302)
        ok_('/project/contract' in result.headers['Location'])

        project_detail = self.project_detail_repository.find_by_id(
            project_detail_id)
        project_result_id = project_detail.project_results[0].id

        # 実績を保存する。
        result = self.app.post('/project/result/detail/' +
                               str(project_result_id),
                               data={
                                   'work_time': '160.0',
                                   'billing_confirmation_money': ''
                               })
        self.assertEqual(result.status_code, 302)
        ok_('/project/result/detail/' +
            str(project_result_id) in result.headers['Location'])

        # 請求のレコード数が増えていないことを確認。
        after = len(self.project_billing_repository.find_all())
        self.assertEqual(before, after)