Пример #1
0
    def test_write_estimated_content_rows_if_blanket(self):
        # set_up
        self.estimated_report.project.contract_form = Contract.blanket

        # テスト対象のメソッドを実行
        self.estimated_report.write_estimated_content_rows()

        # 指定のセルに値が入っていることを確認。
        defined_name_range = self.estimated_report.excel.get_defined_name_range(
            "estimation_no")
        self.assertEqual(self.estimated_report.ws[defined_name_range].value,
                         self.estimated_report.project.estimation_no)
        defined_name_range = self.estimated_report.excel.get_defined_name_range(
            "printed_date")
        self.assertIsNotNone(
            self.estimated_report.ws[defined_name_range].value)
        defined_name_range = self.estimated_report.excel.get_defined_name_range(
            "client_company_name")
        self.assertEqual(
            self.estimated_report.ws[defined_name_range].value,
            self.estimated_report.project.client_company.company_name)
        defined_name_range = self.estimated_report.excel.get_defined_name_range(
            "project_name")
        self.assertEqual(self.estimated_report.ws[defined_name_range].value,
                         self.estimated_report.project.project_name)
        start_date = datetime(self.estimated_report.project.start_date.year,
                              self.estimated_report.project.start_date.month,
                              self.estimated_report.project.start_date.day)
        defined_name_range = self.estimated_report.excel.get_defined_name_range(
            "start_date")
        self.assertEqual(self.estimated_report.ws[defined_name_range].value,
                         strjpftime(start_date, '  %O%E年%m月%d日'))
        end_date = datetime(self.estimated_report.project.end_date.year,
                            self.estimated_report.project.end_date.month,
                            self.estimated_report.project.end_date.day)
        defined_name_range = self.estimated_report.excel.get_defined_name_range(
            "end_date")
        self.assertEqual(self.estimated_report.ws[defined_name_range].value,
                         strjpftime(end_date, '  %O%E年%m月%d日'))
        defined_name_range = self.estimated_report.excel.get_defined_name_range(
            "billing_timing")
        self.assertEqual(
            self.estimated_report.ws[defined_name_range].value,
            self.estimated_report.project.billing_timing.name_for_report)
        defined_name_range = self.estimated_report.excel.get_defined_name_range(
            "contract_form")
        self.assertEqual(self.estimated_report.ws[defined_name_range].value,
                         self.estimated_report.project.contract_form.name)
Пример #2
0
 def write_estimated_content_rows(self):
     # 結合しているセルの罫線が消えるため、罫線を引き直す。
     for rows in self.ws[self.excel.get_defined_name_range(
             "estimated_content")]:
         for cell in rows:
             cell.border = Border(outline=True, bottom=Side(style='dashed'))
     # 値を代入
     self.ws[self.excel.get_defined_name_range(
         "estimation_no")].value = self.project.estimation_no
     self.ws[self.excel.get_defined_name_range(
         "printed_date")].value = datetime.today().date()
     if self.project.client_company:
         self.ws[self.excel.get_defined_name_range("client_company_name")].value = \
             self.project.client_company.company_name
     self.ws[self.excel.get_defined_name_range(
         "project_name")].value = self.project.project_name
     # start_date、end_dateをdatetime型に変更
     start_date = datetime(self.project.start_date.year,
                           self.project.start_date.month,
                           self.project.start_date.day)
     end_date = datetime(self.project.end_date.year,
                         self.project.end_date.month,
                         self.project.end_date.day)
     locale.setlocale(locale.LC_ALL, '')
     self.ws[self.excel.get_defined_name_range(
         "start_date")].value = strjpftime(start_date, '  %O%E年%m月%d日')
     self.ws[self.excel.get_defined_name_range(
         "end_date")].value = strjpftime(end_date, '  %O%E年%m月%d日')
     if self.project.billing_timing:
         self.ws[self.excel.get_defined_name_range("billing_timing")].value = \
             self.project.billing_timing.name_for_report
     if self.project.contract_form:
         self.ws[self.excel.get_defined_name_range(
             "contract_form")].value = self.project.contract_form.name
     # 表示形式
     self.ws[self.excel.get_defined_name_range(
         "printed_date")].number_format = 'yyyy年m月d日'
     # 請負ではない場合、「瑕疵担保期間」を非表示にする。
     if self.project.contract_form != Contract.blanket:
         self.ws.row_dimensions[19].hidden = True
         # 書式が崩れるので修正
         self.ws['J18'].border = Border(bottom=Side(style='medium'))
         self.ws['L18'].border = Border(bottom=Side(style='medium'))
 def write_bp_order_original(self):
     # 値を代入
     engineer_history = self.engineer_history_repository.get_history_by_date(
         self.project_detail.engineer.id,
         self.project_detail.billing_start_day)
     self.ws[self.excel.get_defined_name_range(
         "bp_order_no")].value = self.project_detail.bp_order_no
     self.ws[self.excel.get_defined_name_range(
         "printed_date")].value = self.project_detail.billing_start_day
     self.ws[self.excel.get_defined_name_range("bp_company_name")].value = \
         self.project_detail.engineer.company.company_name
     if self.project_detail.engineer.company.contract_date:
         self.ws[self.excel.get_defined_name_range("contract_date")].value = \
             strjpftime(datetime(
                 self.project_detail.engineer.company.contract_date.year,
                 self.project_detail.engineer.company.contract_date.month,
                 self.project_detail.engineer.company.contract_date.day
             ), '%O%E年%m月%d日')
     self.ws[self.excel.get_defined_name_range("project_name_for_bp")].value = \
         self.project_detail.project.project_name_for_bp
     self.ws[self.excel.get_defined_name_range(
         "start_date")].value = self.project_detail.billing_start_day
     self.ws[self.excel.get_defined_name_range(
         "end_date")].value = self.project_detail.billing_end_day
     if engineer_history:
         self.ws[self.excel.get_defined_name_range(
             "payment_per_month"
         )].value = engineer_history.payment_per_month
         self.ws[self.excel.get_defined_name_range("payment_detail")].value = \
             self.get_payment_detail_text(engineer_history)
         self.ws[self.excel.get_defined_name_range(
             "payment_condition"
         )].value = engineer_history.payment_condition
         self.ws[self.excel.get_defined_name_range(
             "remarks")].value = engineer_history.remarks
     return self
Пример #4
0
 def test_not_excepted_time(self):
     exception_time = datetime.datetime(1868, 9, 7)
     strjpftime(exception_time)
Пример #5
0
    def test_excepted_time(self):
        last_meiji_time = datetime.datetime(1912, 7, 29)
        eq_(strjpftime(last_meiji_time), u"M45.07.29")
        eq_(strjpftime(last_meiji_time, u"%O%E年"), u"明治45年")

        first_taisho_time = datetime.datetime(1912, 7, 30)
        eq_(strjpftime(first_taisho_time), u"T1.07.30")
        eq_(strjpftime(first_taisho_time, u"%O%E年"), u"大正元年")

        last_taisho_time = datetime.datetime(1926, 12, 24)
        eq_(strjpftime(last_taisho_time), u"T15.12.24")
        eq_(strjpftime(last_taisho_time, u"%O%E年"), u"大正15年")

        first_showa_time = datetime.datetime(1926, 12, 25)
        eq_(strjpftime(first_showa_time), u"S1.12.25")
        eq_(strjpftime(first_showa_time, u"%O%E年"), u"昭和元年")

        last_showa_time = datetime.datetime(1989, 1, 7)
        eq_(strjpftime(last_showa_time), u"S64.01.07")
        eq_(strjpftime(last_showa_time, u"%O%E年"), u"昭和64年")


        first_heisei_time = datetime.datetime(1989, 1, 8)
        eq_(strjpftime(first_heisei_time), u"H1.01.08")
        eq_(strjpftime(first_heisei_time, u"%O%E年"), u"平成元年")

        heisei_time = datetime.datetime(2015, 8, 5)
        eq_(strjpftime(heisei_time), u"H27.08.05")
        eq_(strjpftime(heisei_time, u"%O%E年"), u"平成27年")
Пример #6
0
    def test_expected_time(self):
        last_meiji_time = datetime.datetime(1912, 7, 29)
        eq_(strjpftime(last_meiji_time), "M45.07.29")
        eq_(strjpftime(last_meiji_time, "%O%E年"), "明治45年")

        first_taisho_time = datetime.datetime(1912, 7, 30)
        eq_(strjpftime(first_taisho_time), "T1.07.30")
        eq_(strjpftime(first_taisho_time, "%O%E年"), "大正元年")

        last_taisho_time = datetime.datetime(1926, 12, 24)
        eq_(strjpftime(last_taisho_time), "T15.12.24")
        eq_(strjpftime(last_taisho_time, "%O%E年"), "大正15年")

        first_showa_time = datetime.datetime(1926, 12, 25)
        eq_(strjpftime(first_showa_time), "S1.12.25")
        eq_(strjpftime(first_showa_time, "%O%E年"), "昭和元年")

        last_showa_time = datetime.datetime(1989, 1, 7)
        eq_(strjpftime(last_showa_time), "S64.01.07")
        eq_(strjpftime(last_showa_time, "%O%E年"), "昭和64年")

        first_heisei_time = datetime.datetime(1989, 1, 8)
        eq_(strjpftime(first_heisei_time), "H1.01.08")
        eq_(strjpftime(first_heisei_time, "%O%E年"), "平成元年")

        heisei_time = datetime.datetime(2015, 8, 5)
        eq_(strjpftime(heisei_time), "H27.08.05")
        eq_(strjpftime(heisei_time, "%O%E年"), "平成27年")
Пример #7
0
 def test_not_Expected_time(self):
     exception_time = datetime.datetime(1868, 9, 7)
     strjpftime(exception_time)