Пример #1
0
    def __init__(self, school_id, program_id, existing_annex: Contract = None):
        self.program_id = program_id
        self.program = DatabaseManager.get_program(program_id)
        self.school = DatabaseManager.get_school(school_id)
        if not existing_annex:
            self.contract = DatabaseManager.get_contract(
                school_id, self.program_id)
            self.contract_no = "{0}_{1}".format(
                self.contract.contract_no,
                DatabaseManager.get_next_annex_no(school_id, self.program_id))
            self.contract_year = self.contract.contract_year
            self.contract_date = None
            self.validity_date = None
            self.fruitVeg_products = None
            self.dairy_products = None
        else:
            self.contract = existing_annex
            self.contract_no = existing_annex.contract_no
            self.contract_year = existing_annex.contract_year
            self.contract_date = existing_annex.contract_date
            self.validity_date = existing_annex.validity_date
            self.fruitVeg_products = existing_annex.fruitVeg_products
            self.dairy_products = existing_annex.dairy_products

        output_directory = self.school.generate_directory_name(
            config_parser.get('Directories', 'annex'))
        DocumentCreator.__init__(self,
                                 config_parser.get('DocTemplates', 'annex'),
                                 output_directory)
        DatabaseManager.__init__(self)
    def _generate_5a(self):
        DocumentCreator.__init__(self, self.template_document_va,
                                 self.output_directory)

        self.document.merge_rows('date_vegFruit',
                                 self.records_to_merge_vegFruit)
        self.document.merge_rows('date_milk', self.records_to_merge_milk)
        data_to_merge = dict()
        data_to_merge.update(self.default_data.get())
        data_to_merge['weeks'] = DatabaseManager.str_from_weeks(
            DatabaseManager.get_weeks(self.program_id), self.summary.weeks)
        data_to_merge['sum_vegFruit'] = str(self.sum_product_vegFruit)
        data_to_merge['sum_kids_vegFruit'] = str(self.sum_product_vegFruit)
        data_to_merge['sum_milk'] = str(self.sum_product_milk)
        data_to_merge['sum_kids_milk'] = str(self.sum_product_milk)

        self.document.merge(**data_to_merge)

        doc_5a_name = "Ewidencja_VA_Wniosek_{}_{}.docx".format(
            self.summary.no, self.summary.year)
        doc_5a_name_copy = path.join(
            self.main_app_dir,
            "{0}_EwidencjaVa_{1}_{2}.docx".format(self.school.nick,
                                                  self.summary.no,
                                                  self.summary.year))
        DocumentCreator.generate(self, doc_5a_name, False)
        if path.exists(doc_5a_name_copy):
            remove(doc_5a_name_copy)
        copyfile(path.join(self.output_directory, doc_5a_name),
                 doc_5a_name_copy)
Пример #3
0
 def __init__(self, program_id):
     self.date = datetime.today().strftime('%d-%m-%Y')
     self.program = DatabaseManager.get_program(program_id)
     self.contracts = DatabaseManager.get_contracts(program_id)
     self.program_semester = self.program.get_current_semester()
     self.year = self.program.school_year
     self.records_to_merge = []
     output_directory = config_parser.get('Directories', 'current_program')
     DocumentCreator.__init__(self,
                              config_parser.get('DocTemplates', 'register'),
                              output_directory)
Пример #4
0
 def __init__(self, program_id, weeks: Set[int], no=None):
     self.summary: Summary = None
     self.program_id = program_id
     self.weeks = weeks
     if no:
         self.summary = DatabaseManager.get_summary(self.program_id, no)
         self.summary.weeks = weeks
         DatabaseManager.modify()
     self.school_no = 0
     output_directory = config_parser.get('Directories', 'current_program')
     DocumentCreator.__init__(self, config_parser.get('DocTemplates', 'summary'), output_directory)
     DatabaseManager.__init__(self)
Пример #5
0
    def __init__(self, school, program_id, ommit_representat=True):
        self.main_contract_dir = config_parser.get('Directories',
                                                   'contract_all')
        if not path.exists(self.main_contract_dir):
            makedirs(self.main_contract_dir)

        self.program = DatabaseManager.get_program(program_id)
        self.school = school
        self.contract_no = None
        self.contract_year = None
        self.contract_date = None
        self.ommit_representat = ommit_representat
        output_directory = self.school.generate_directory_name(
            config_parser.get('Directories', 'contract'))
        DocumentCreator.__init__(self,
                                 config_parser.get('DocTemplates', 'contract'),
                                 output_directory)
        DatabaseManager.__init__(self)
    def _generate_5(self):
        DocumentCreator.__init__(self, self.template_document_v,
                                 self.output_directory)
        data_to_merge = dict()
        data_to_merge['application_no'] = self.summary.get_application_no()

        data_to_merge.update({
            k: ApplicationCreator.convert_to_str(v)
            for k, v in self.default_data.get().items()
        })
        data_to_merge.update({
            k: ApplicationCreator.convert_to_str(v)
            for k, v in self.common_data.get().items()
        })
        data_to_merge.update({
            k: ApplicationCreator.convert_to_str(v)
            for k, v in self.frutiVeg.get().items()
        })
        data_to_merge.update({
            k: ApplicationCreator.convert_to_str(v)
            for k, v in self.dairySummary.get().items()
        })
        data_to_merge.update({
            k: ApplicationCreator.convert_to_str(v)
            for k, v in self.product_data.items()
        })

        self.document.merge(**data_to_merge)

        doc_5_name = "Oswiadczenie_V_Wniosek_{}_{}.docx".format(
            self.summary.no, self.summary.year)
        doc_5_name_copy = path.join(
            self.main_app_dir,
            "{0}_OswiadczenieV_{1}_{2}.docx".format(self.school.nick,
                                                    self.summary.no,
                                                    self.summary.year))
        DocumentCreator.generate(self, doc_5_name, False)
        if path.exists(doc_5_name_copy):
            remove(doc_5_name_copy)
        copyfile(path.join(self.output_directory, doc_5_name), doc_5_name_copy)
Пример #7
0
 def __init__(self,
              program_id,
              current_date,
              school_id,
              product_id,
              generation_date=""):
     self.program_id = program_id
     self.date = DateConverter.to_date(current_date,
                                       pattern=DATABASE_DATE_PATTERN)
     self.state = RecordState.NOT_DELIVERED
     self.contract = DatabaseManager.get_current_contract(
         school_id, self.program_id, self.date)
     self.product = DatabaseManager.get_product(product_id)
     self.doc_data = dict()
     self.generation_date = DateConverter.to_date(
         generation_date) if generation_date else datetime.date.today()
     output_directory = self.contract.school.generate_directory_name(
         config_parser.get('Directories', 'record'))
     DocumentCreator.__init__(self,
                              config_parser.get('DocTemplates', 'record'),
                              output_directory)
     DatabaseManager.__init__(self)
     self._prepare_data_for_doc()