def setUp(self): self.data = read_flat("c34.txt") self.data = self.data.upper() # Presenter Header record = Record(c34.ORDERING_HEADER_RECORD) record.record_code = "03" record.operation_code = "62" record.nif = "B17616756" record.suffix = "000" record.data_number = "001" record.send_date = datetime.datetime(2012, 2, 24) record.creation_date = datetime.datetime(2012, 2, 24) record.account = "20594887510123456789" record.charge_detail = "false" self.ordering_header = record
def setUp(self): self.data = read_flat('c34.txt') self.data = self.data.upper() # Presenter Header record = Record(c34.ORDERING_HEADER_RECORD) record.record_code = '03' record.operation_code = '62' record.nif = 'B17616756' record.suffix = '000' record.data_number = '001' record.send_date = datetime.datetime(2012, 2, 24) record.creation_date = datetime.datetime(2012, 2, 24) record.account = '20594887510123456789' record.charge_detail = 'false' self.ordering_header = record
def setUp(self): self.data = read_flat('c19.txt') self.data = self.data.upper() # Presenter Header record = Record(c19.PRESENTER_HEADER_RECORD) record.record_code = '51' record.data_code = '80' record.nif = 'B65247983' record.suffix = '701' record.creation_date = datetime.datetime(2012, 2, 24) record.name = 'NAN PROJECTES DE PROGRAMARI LLIURE, S.L.' record.bank_code = '2059' record.bank_office = '0060' self.presenter_header = record
def setUp(self): self.data = read_flat("c58.txt") self.data = self.data.upper() # Presenter Header record = Record(c58.PRESENTER_HEADER_RECORD) record.record_code = "51" record.data_code = "70" record.nif = "B65247983" record.suffix = "000" record.creation_date = datetime.datetime(2012, 2, 24) record.name = "NAN PROJECTES DE PROGRAMARI LLIURE, S.L." record.bank_code = "0075" record.bank_office = "1454" self.presenter_header = record
def setUp(self): self.data = read_flat('c32.txt') self.data = self.data.upper() # Presenter Header record = Record(c32.FILE_HEADER_RECORD) record.record_code = '02' record.data_code = '65' record.file_date = datetime.datetime(2011, 07, 04) record.number = '1280' record.bank_code = '2959' record.bank_office = '0912' self.file_header = record
def setUp(self): self.data = read_flat("c32.txt") self.data = self.data.upper() # Presenter Header record = Record(c32.FILE_HEADER_RECORD) record.record_code = "02" record.data_code = "65" record.file_date = datetime.datetime(2011, 0o7, 0o4) record.number = "1280" record.bank_code = "2959" record.bank_office = "0912" self.file_header = record
def read(data): lines = data.splitlines() records = [] current_line = lines.pop(0) records.append(Record.extract(current_line, FILE_HEADER)) while len(lines) > 1: current_line = lines.pop(0) if Record.valid(current_line, SENDER_HEADER): record = Record.extract(current_line, SENDER_HEADER) elif Record.valid(current_line, INDIVIDUAL_RECORD): record = Record.extract(current_line, INDIVIDUAL_RECORD) elif Record.valid(current_line, SENDER_FOOTER): record = Record.extract(current_line, SENDER_FOOTER) else: raise BaseException('Invalid record: "%s"' % current_line) records.append(record) current_line = lines.pop(0) records.append(Record.extract(current_line, FILE_FOOTER)) return records
def get_record(self): record = Record(aeat347.PROPERTY_RECORD) record.party_nif = self.party_vat record.representative_nif = self.representative_vat record.party_name = self.party_name record.amount = self.amount record.situation = self.situation record.cadaster_number = self.cadaster_number record.road_type = self.road_type record.street = self.street record.number_type = self.number_type record.number = self.number record.number_qualifier = self.number_qualifier record.block = self.block record.doorway = self.doorway record.stair = self.stair record.floor = self.floor record.door = self.door record.complement = self.complement record.city = self.city record.municipality = self.municipality record.municipality_code = self.municipality_code record.province_code = self.province_code record.zip = self.zip return record
def get_record(self): record = Record(aeat347.PARTY_RECORD) record.party_nif = self.party_vat record.community_vat = self.community_vat or '' record.representative_nif = self.representative_vat or '' record.party_name = remove_accents(self.party_name) record.province_code = self.province_code if self.country_code == 'ES': record.country_code = '' else: record.country_code = self.country_code record.operation_key = self.operation_key record.amount = self.amount record.insurance = self.insurance record.business_premises_rent = self.business_premises_rent record.cash_amount = self.cash_amount or _ZERO record.vat_liable_property_amount = self.property_amount \ or Decimal('0.0') record.fiscalyear_cash_operation = str( self.fiscalyear_code_cash_operation or '') record.first_quarter_amount = self.first_quarter_amount record.first_quarter_property_amount = ( self.first_quarter_property_amount) record.second_quarter_amount = self.second_quarter_amount record.second_quarter_property_amount = ( self.second_quarter_property_amount) record.third_quarter_amount = self.third_quarter_amount record.third_quarter_property_amount = ( self.third_quarter_property_amount) record.fourth_quarter_amount = self.fourth_quarter_amount record.fourth_quarter_property_amount = ( self.fourth_quarter_property_amount) record.cash_vat_operation = self.cash_vat_operation record.cash_vat_criteria = (self.cash_vat_criteria or Decimal('0.0') if self.cash_vat_operation else Decimal('0.0')) record.tax_person_operation = self.tax_person_operation record.related_goods_operation = self.related_goods_operation return record
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()
def setUp(self): self.data = read_flat('c43.txt') self.data = self.data.upper() # Account Header record = Record(c43.ACCOUNT_HEADER_RECORD) record.record_code = '11' record.bank_code = '2059' record.bank_office = '0060' record.account_number = '8000314221' record.start_date = datetime.datetime(2011, 11, 11) record.end_date = datetime.datetime(2011, 11, 20) record.initial_balance = Decimal('52530.44') record.currency_code = '978' record.information_mode = '2' record.customer_name = '' self.account_header = record
def setUp(self): self.data = read_flat("115.txt") record = Record(aeat115.HEADER_RECORD) record.fiscalyear = "2015" record.period = "1T" self.header_record = record record = Record(aeat115.RECORD) record.type = "U" record.nif = "B12345678" record.name = "NAME SL" record.fiscalyear = "2015" record.period = "1T" record.number_beneficiaries = 1 record.taxable_amount = Decimal("1000.50") record.withholdings = Decimal("100.50") record.payable_amount = Decimal("100.50") record.complementary = False record.bank_account = "ES1122223333441111111111" self.record = record record = Record(aeat115.FOOTER_RECORD) record.fiscalyear = "2015" record.period = "1T" self.footer_record = record
def setUp(self): self.data = read_flat("111.txt") record = Record(aeat111.HEADER_RECORD) record.fiscalyear = "2015" record.period = "1T" self.header_record = record record = Record(aeat111.RECORD) record.type = "U" record.nif = "B12345678" record.name = "NAME SL" record.fiscalyear = "2015" record.period = "1T" record.earned_cash_income_number_beneficiaries = 4 record.earned_cash_income_taxable_amount = Decimal("9369.88") record.earned_cash_income_withholdings = Decimal("582.25") record.economic_activities_cash_income_number_beneficiaries = 6 record.economic_activities_cash_income_taxable_amount = Decimal("11871.16") record.economic_activities_cash_income_withholdings = Decimal("224.86") record.withholdings = Decimal("2000.50") record.payable_amount = Decimal("2000.50") record.complementary = False record.bank_account = "ES1122223333441111111111" self.record = record record = Record(aeat111.FOOTER_RECORD) record.fiscalyear = "2015" record.period = "1T" self.footer_record = record
def setUp(self): self.data = read_flat("c43.txt") self.data = self.data.upper() # Account Header record = Record(c43.ACCOUNT_HEADER_RECORD) record.record_code = "11" record.bank_code = "2059" record.bank_office = "0060" record.account_number = "8000314221" record.start_date = datetime.datetime(2011, 11, 11) record.end_date = datetime.datetime(2011, 11, 20) record.initial_balance = Decimal("52530.44") record.currency_code = "978" record.information_mode = "2" record.customer_name = "" self.account_header = record
def setUp(self): self.data = read_flat("130.txt") record = Record(aeat130.HEADER_RECORD) record.fiscalyear = "2015" record.period = "1T" self.header_record = record record = Record(aeat130.RECORD) record.type = "U" record.nif = "12345678A" record.surname = "SURNAME" record.name = "NAME" record.fiscalyear = "2015" record.period = "1T" record.economic_activity_income = Decimal("4177.52") record.economic_activity_deduction_expenses = Decimal("1405.97") record.economic_activity_taxable_amount = Decimal("2771.55") record.economic_activity_20_percent_taxable_amount = Decimal("554.31") record.economic_activity_withholdings_y2d = Decimal("122.85") record.economic_activity_payable_amount = Decimal("431.46") record.withholdings = Decimal("431.46") record.deduction_article_110dot3 = Decimal("100.00") record.difference = Decimal("331.46") record.amount = Decimal("331.46") record.payable_amount = Decimal("331.46") record.complementary = False record.bank_account = "ES1122223333441111111111" self.record = record record = Record(aeat130.FOOTER_RECORD) record.fiscalyear = "2015" record.period = "1T" self.footer_record = record