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 __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)
Example #3
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 __init__(self, program_id, school, summary, date):
        self.template_document_v = config_parser.get('DocTemplates',
                                                     'application')
        self.template_document_va = config_parser.get('DocTemplates',
                                                      'application_5a')
        self.main_app_dir = path.join(
            config_parser.get('Directories', 'application_all'),
            str(summary.no))
        if not path.exists(self.main_app_dir):
            makedirs(self.main_app_dir)
        self.program_id = program_id
        self.school: School = school
        self.summary: Summary = summary

        self.default_data: DefaultData = DefaultData(self.school, date)
        self.common_data: CommonData = CommonData(self.program_id,
                                                  self.school.id,
                                                  self.summary.weeks)

        self.fruits = Fruit(self.common_data)
        self.vegs = Veg(self.common_data)
        self.dairy = Dairy(self.common_data)

        self.frutiVeg = FruitVegSummary(self.common_data)
        self.dairySummary = DairySummary(self.common_data)

        self.tmp_data_to_rename = list([
            self.default_data, self.common_data, self.fruits, self.vegs,
            self.dairy, self.frutiVeg, self.dairySummary
        ])

        self.output_directory = self.school.generate_directory_name(
            config_parser.get('Directories', 'application'))

        self.product_data = dict()
        self.inconsistent_records_error = None
        if not self.__prepare_data():
            raise Exception("Cannot prepare data")

        DatabaseManager.__init__(self)
 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()