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)
def generate(self, new_doc_name, gen_pdf=True): self._prepare_school_data() self.document.merge_rows('no', self.records_to_merge) self.document.merge(semester_no=self.program_semester, school_year=self.year, date=self.date) DocumentCreator.generate(self, new_doc_name, False) generated_file = path.join(self.output_directory, new_doc_name) RegisterCreator._merge_cells(generated_file, RegisterCreator.CELL_TO_MERGE_MARK) DocumentCreator.generate_pdf(generated_file, self.output_directory)
def generate(self): self.document.merge(city=self.doc_data['city'], current_date=self.doc_data['current_date'], name=self.doc_data['name'], address=self.doc_data['address'], nip=self.doc_data['nip'], regon=self.doc_data['regon'], email=self.doc_data['email'], kids_no=self.doc_data['kids_no'], product_name=self.doc_data['product_name'], record_title=self.doc_data['record_title']) DocumentCreator.generate(self, "WZ_{0}_{1}.docx".format( DateConverter.to_string(self.date), self.product.get_type_mapping()), gen_pdf=True)
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)
def generate(self): self.document.merge( city=self.school.city, date=DateConverter.to_string(self.contract_date, "%d.%m.%Y"), no=str(self.contract_no), year=str(self.contract_year), semester=self.program.get_current_semester(), name=self.school.name, address=self.school.address, nip=self.school.nip, regon=self.school.regon, representant=self.school.responsible_person if not self.ommit_representat else FILL_BY_SCHOOL, email=self.school.email, program_start_date=DateConverter.to_string(self.program.start_date, "%d.%m.%Y"), program_end_date=DateConverter.to_string(self.program.end_date, "%d.%m.%Y"), nip_additional=self.school.representative_nip if self.school.representative_nip else "-", name_additional=self.school.representative if self.school.representative else "-", regon_additional=self.school.representative_regon if self.school.representative_regon else "-", giving_weeks=ContractCreator._preapre_str_from_weeks( DatabaseManager.get_weeks(self.program.id))) doc_contract_name = "Umowa_{0}_{1}.docx".format( self.contract_no, self.contract_year) created_doc_name = DocumentCreator.generate(self, doc_contract_name) doc_contract_name_copy = path.join( self.main_contract_dir, "{0}_Umowa_{1}_{2}.docx".format(self.school.nick, self.contract_no, self.contract_year)) try: DocumentCreator.copy_to_path(created_doc_name, doc_contract_name_copy) # DocumentCreator.copy_to_path(created_doc_name.replace("docx", "pdf"), doc_contract_name_copy.replace("docx", "pdf")) #TODO problem with generating pdf numbering is wrong except: app.logger.error("Could not copy files [%s]", created_doc_name)
def generate(self): self.document.merge( city=self.school.city, current_date=self.contract_date.strftime("%d.%m.%Y"), contract_no=str(self.contract_no.split("_")[0]), contract_year=str(self.contract_year), semester_no=self.program.get_current_semester(), school_year=self.program.school_year, name=self.school.name, address=self.school.address, nip=self.school.nip, regon=self.school.regon, responsible_person=self.school.responsible_person, fruitveg_products=str(self.fruitVeg_products), dairy_products=str(self.dairy_products), validity_date=self.validity_date.strftime("%d.%m.%Y")) created_annex = DocumentCreator.generate( self, "Aneks_" + self.contract_date.strftime("%d_%m_%Y") + ".docx") new_annex_dst = path.join( config_parser.get('Directories', 'annex_all'), "{0}_Aneks_{1}_{2}.docx".format(self.school.nick, self.contract_no, self.contract_year)) DocumentCreator.copy_to_path(created_annex, new_annex_dst)
def generate(self): if not self.summary: app.logger.error("Summary does not exists") return if not self.__base_check(): app.logger.error("Summary Base Check failed") return assert(int(self.summary.get_veg_income() + self.summary.get_fruit_income()) == int(self.summary.get_fruit_veg_income())) #TODO refactor based on idea in Application Creator self.document.merge( application_no=self.summary.get_application_no(), city="Zielona Góra", wn=str(self.summary.number_of_weeks), kids_no_fruitVeg=str(self.summary.kids_no), kids_no_milk=str(self.summary.kids_no_milk), weeks=DatabaseManager.str_from_weeks(DatabaseManager.get_weeks(self.program_id), self.summary.weeks), apple=str(self.summary.get_from_fruit_list(ProductName.APPLE).amount), applewn=str(self.summary.get_from_fruit_list(ProductName.APPLE).calculate_netto()), applevat=str(self.summary.get_from_fruit_list(ProductName.APPLE).calculate_vat()), applewb=str(self.summary.get_from_fruit_list(ProductName.APPLE).calculate_brutto()), plum=str(self.summary.get_from_fruit_list(ProductName.PLUM).amount), plumwn=str(self.summary.get_from_fruit_list(ProductName.PLUM).calculate_netto()), plumvat=str(self.summary.get_from_fruit_list(ProductName.PLUM).calculate_vat()), plumwb=str(self.summary.get_from_fruit_list(ProductName.PLUM).calculate_brutto()), pear=str(self.summary.get_from_fruit_list(ProductName.PEAR).amount), pearwn=str(self.summary.get_from_fruit_list(ProductName.PEAR).calculate_netto()), pearvat=str(self.summary.get_from_fruit_list(ProductName.PEAR).calculate_vat()), pearwb=str(self.summary.get_from_fruit_list(ProductName.PEAR).calculate_brutto()), strawberry=str(self.summary.get_from_fruit_list(ProductName.STRAWBERRY).amount), strawberrywn=str(self.summary.get_from_fruit_list(ProductName.STRAWBERRY).calculate_netto()), strawberryvat=str(self.summary.get_from_fruit_list(ProductName.STRAWBERRY).calculate_vat()), strawberrywb=str(self.summary.get_from_fruit_list(ProductName.STRAWBERRY).calculate_brutto()), juice=str(self.summary.get_from_fruit_list(ProductName.JUICE).amount), juicewn=str(self.summary.get_from_fruit_list(ProductName.JUICE).calculate_netto()), juicevat=str(self.summary.get_from_fruit_list(ProductName.JUICE).calculate_vat()), juicewb=str(self.summary.get_from_fruit_list(ProductName.JUICE).calculate_brutto()), fruitall=str(self.summary.get_fruit_amount()), fruitalln="{0:.2f}".format(self.summary.get_fruit_netto()), fruitallvat="{0:.2f}".format(self.summary.get_fruit_vat()), fruitallwb="{0:.2f}".format(self.summary.get_fruit_income()), carrot=str(self.summary.get_from_fruit_list(ProductName.CARROT).amount), carrotwn=str(self.summary.get_from_fruit_list(ProductName.CARROT).calculate_netto()), carrotvat=str(self.summary.get_from_fruit_list(ProductName.CARROT).calculate_vat()), carrotwb=str(self.summary.get_from_fruit_list(ProductName.CARROT).calculate_brutto()), tomato=str(self.summary.get_from_fruit_list(ProductName.TOMATO).amount), tomatown=str(self.summary.get_from_fruit_list(ProductName.TOMATO).calculate_netto()), tomatovat=str(self.summary.get_from_fruit_list(ProductName.TOMATO).calculate_vat()), tomatowb=str(self.summary.get_from_fruit_list(ProductName.TOMATO).calculate_brutto()), pepper=str(self.summary.get_from_fruit_list(ProductName.PEPPER).amount), pepperwn=str(self.summary.get_from_fruit_list(ProductName.PEPPER).calculate_netto()), peppervat=str(self.summary.get_from_fruit_list(ProductName.PEPPER).calculate_vat()), pepperwb=str(self.summary.get_from_fruit_list(ProductName.PEPPER).calculate_brutto()), radish=str(self.summary.get_from_fruit_list(ProductName.RADISH).amount), radishwn=str(self.summary.get_from_fruit_list(ProductName.RADISH).calculate_netto()), radishvat=str(self.summary.get_from_fruit_list(ProductName.RADISH).calculate_vat()), radishwb=str(self.summary.get_from_fruit_list(ProductName.RADISH).calculate_brutto()), kohlrabi=str(self.summary.get_from_fruit_list(ProductName.KOHLRABI).amount), kohlrabiwn=str(self.summary.get_from_fruit_list(ProductName.KOHLRABI).calculate_netto()), kohlrabivat=str(self.summary.get_from_fruit_list(ProductName.KOHLRABI).calculate_vat()), kohlrabiwb=str(self.summary.get_from_fruit_list(ProductName.KOHLRABI).calculate_brutto()), veg_all=str(self.summary.get_veg_amount()), veg_alln="{0:.2f}".format(self.summary.get_veg_netto()), veg_allvat="{0:.2f}".format(self.summary.get_veg_vat()), veg_allwb="{0:.2f}".format(self.summary.get_veg_income()), fruitVeg_income="{0:.2f}".format(self.summary.fruitVeg_income), milk=str(self.summary.get_from_diary_list(ProductName.MILK).amount), milkwn=str(self.summary.get_from_diary_list(ProductName.MILK).calculate_netto()), milkvat=str(self.summary.get_from_diary_list(ProductName.MILK).calculate_vat()), milkwb=str(self.summary.get_from_diary_list(ProductName.MILK).calculate_brutto()), yoghurt=str(self.summary.get_from_diary_list(ProductName.YOGHURT).amount), yoghurtwn=str(self.summary.get_from_diary_list(ProductName.YOGHURT).calculate_netto()), yoghurtvat=str(self.summary.get_from_diary_list(ProductName.YOGHURT).calculate_vat()), yoghurtwb=str(self.summary.get_from_diary_list(ProductName.YOGHURT).calculate_brutto()), kefir=str(self.summary.get_from_diary_list(ProductName.KEFIR).amount), kefirwn=str(self.summary.get_from_diary_list(ProductName.KEFIR).calculate_netto()), kefirvat=str(self.summary.get_from_diary_list(ProductName.KEFIR).calculate_vat()), kefirwb=str(self.summary.get_from_diary_list(ProductName.KEFIR).calculate_brutto()), cheese=str(self.summary.get_from_diary_list(ProductName.CHEESE).amount), cheesewn=str(self.summary.get_from_diary_list(ProductName.CHEESE).calculate_netto()), cheesevat=str(self.summary.get_from_diary_list(ProductName.CHEESE).calculate_vat()), cheesewb=str(self.summary.get_from_diary_list(ProductName.CHEESE).calculate_brutto()), dairy_all=str(self.summary.get_dairy_amount()), dairy_wn="{0:.2f}".format(self.summary.get_dairy_netto()), dairy_vat="{0:.2f}".format(self.summary.get_dairy_vat()), dairy_wb="{0:.2f}".format(self.summary.get_dairy_income()), dairy_income="{0:.2f}".format(self.summary.milk_income), school_no_fruitVeg=str(self.summary.school_no), school_no_milk=str(self.summary.school_no_milk), app_school_no=str(self.school_no) ) DocumentCreator.generate(self, f"Wniosek_{self.summary.no}.docx", False)