Ejemplo n.º 1
0
 def create_file(self):
     records = []
     record = Record(aeat347.PRESENTER_HEADER_RECORD)
     record.fiscalyear = str(self.fiscalyear_code)
     record.nif = self.company_vat
     record.presenter_name = self.company.party.name
     record.support_type = self.support_type
     record.contact_phone = self.contact_phone
     record.contact_name = self.contact_name
     record.declaration_number = int('347{}{:0>6}'.format(
         self.fiscalyear_code,
         self.auto_sequence()))
     record.previous_declaration_number = self.previous_number
     record.party_count = len(self.parties)
     record.party_amount = self.party_amount
     record.property_count = len(self.properties)
     record.property_amount = self.property_amount or Decimal('0.0')
     record.representative_nif = self.representative_vat
     records.append(record)
     for line in itertools.chain(self.parties, self.properties):
         record = line.get_record()
         record.fiscalyear = str(self.fiscalyear_code)
         record.nif = self.company_vat
         records.append(record)
     data = retrofix_write(records)
     data = remove_accents(data).upper()
     if isinstance(data, str):
         data = data.encode('iso-8859-1')
     self.file_ = self.__class__.file_.cast(data)
     self.save()