@@ -204,13 +204,12 @@ def test_original_currency(self):
204204 line_amount_currency = float_round (line .amount_currency , precision_digits = 1 )
205205 self .assertEqual (line_amount_currency , 1000.0 )
206206
207- def test_original_currency_no_header (self ):
207+ def test_original_currency_no_header_csv (self ):
208208 no_header_statement_map = self .AccountStatementImportSheetMapping .create (
209209 {
210210 "name" : "Sample Statement" ,
211211 "float_thousands_sep" : "comma" ,
212212 "float_decimal_sep" : "dot" ,
213- "header_lines_skip_count" : 0 ,
214213 "delimiter" : "comma" ,
215214 "quotechar" : '"' ,
216215 "timestamp_format" : "%m/%d/%Y" ,
@@ -236,7 +235,57 @@ def test_original_currency_no_header(self):
236235 data = self ._data_file ("fixtures/original_currency_no_header.csv" , "utf-8" )
237236 wizard = self .AccountStatementImport .with_context (journal_id = journal .id ).create (
238237 {
239- "statement_filename" : "fixtures/original_currency.csv" ,
238+ "statement_filename" : "fixtures/original_currency_no_header.csv" ,
239+ "statement_file" : data ,
240+ "sheet_mapping_id" : no_header_statement_map .id ,
241+ }
242+ )
243+ wizard .with_context (
244+ account_statement_import_sheet_file_test = True
245+ ).import_file_button ()
246+ statement = self .AccountBankStatement .search ([("journal_id" , "=" , journal .id )])
247+ self .assertEqual (len (statement ), 1 )
248+ self .assertEqual (len (statement .line_ids ), 1 )
249+
250+ line = statement .line_ids
251+ self .assertEqual (line .currency_id , self .currency_usd )
252+ self .assertEqual (line .foreign_currency_id , self .currency_eur )
253+ self .assertEqual (line .amount_currency , 1000.0 )
254+ self .assertEqual (line .payment_ref , "Your payment INV0001" )
255+
256+ def test_original_currency_no_header_xlsx (self ):
257+ no_header_statement_map = self .AccountStatementImportSheetMapping .create (
258+ {
259+ "name" : "Sample Statement" ,
260+ "float_thousands_sep" : "comma" ,
261+ "float_decimal_sep" : "dot" ,
262+ "delimiter" : "comma" ,
263+ "quotechar" : '"' ,
264+ "timestamp_format" : "%m/%d/%Y" ,
265+ "no_header" : True ,
266+ "timestamp_column" : "0" ,
267+ "amount_column" : "3" ,
268+ "original_currency_column" : "2" ,
269+ "original_amount_column" : "4" ,
270+ "description_column" : "1,7" ,
271+ "partner_name_column" : "5" ,
272+ "bank_account_column" : "6" ,
273+ }
274+ )
275+ journal = self .AccountJournal .create (
276+ {
277+ "name" : "Bank" ,
278+ "type" : "bank" ,
279+ "code" : "BANK" ,
280+ "currency_id" : self .currency_usd .id ,
281+ "suspense_account_id" : self .suspense_account .id ,
282+ }
283+ )
284+
285+ data = self ._data_file ("fixtures/original_currency_no_header.xlsx" )
286+ wizard = self .AccountStatementImport .with_context (journal_id = journal .id ).create (
287+ {
288+ "statement_filename" : "fixtures/original_currency_no_header.xlsx" ,
240289 "statement_file" : data ,
241290 "sheet_mapping_id" : no_header_statement_map .id ,
242291 }
@@ -444,7 +493,7 @@ def test_metadata_separated_debit_credit_csv(self):
444493 statement_map = self .sample_statement_map .copy (
445494 {
446495 "footer_lines_skip_count" : 1 ,
447- "header_lines_skip_count" : 5 ,
496+ "header_lines_skip_count" : 4 ,
448497 "amount_column" : None ,
449498 "partner_name_column" : None ,
450499 "bank_account_column" : None ,
@@ -478,6 +527,58 @@ def test_metadata_separated_debit_credit_csv(self):
478527 self .assertEqual (line1 .amount , 50 )
479528 self .assertEqual (line4 .amount , - 1300 )
480529
530+ def test_metadata_separated_debit_credit_no_header_csv (self ):
531+ journal = self .AccountJournal .create (
532+ {
533+ "name" : "Bank" ,
534+ "type" : "bank" ,
535+ "code" : "BANK" ,
536+ "currency_id" : self .currency_usd .id ,
537+ "suspense_account_id" : self .suspense_account .id ,
538+ }
539+ )
540+ statement_map = self .sample_statement_map .copy (
541+ {
542+ "footer_lines_skip_count" : 1 ,
543+ "header_lines_skip_count" : 4 ,
544+ "no_header" : True ,
545+ "amount_column" : None ,
546+ "partner_name_column" : None ,
547+ "bank_account_column" : None ,
548+ "float_thousands_sep" : "none" ,
549+ "float_decimal_sep" : "comma" ,
550+ "timestamp_format" : "%m/%d/%y" ,
551+ "timestamp_column" : "0" ,
552+ "description_column" : "2" ,
553+ "original_currency_column" : None ,
554+ "original_amount_column" : None ,
555+ "amount_type" : "distinct_credit_debit" ,
556+ "amount_debit_column" : "3" ,
557+ "amount_credit_column" : "4" ,
558+ }
559+ )
560+ data = self ._data_file (
561+ "fixtures/meta_data_separated_credit_debit_no_header.csv" , "utf-8"
562+ )
563+ wizard = self .AccountStatementImport .with_context (journal_id = journal .id ).create (
564+ {
565+ "statement_filename" : "fixtures/meta_data_separated_credit_debit_no_header.csv" ,
566+ "statement_file" : data ,
567+ "sheet_mapping_id" : statement_map .id ,
568+ }
569+ )
570+ wizard .with_context (
571+ journal_id = journal .id ,
572+ account_bank_statement_import_txt_xlsx_test = True ,
573+ ).import_file_button ()
574+ statement = self .AccountBankStatement .search ([("journal_id" , "=" , journal .id )])
575+ self .assertEqual (len (statement ), 1 )
576+ self .assertEqual (len (statement .line_ids ), 4 )
577+ line1 = statement .line_ids .filtered (lambda x : x .payment_ref == "LABEL 1" )
578+ line4 = statement .line_ids .filtered (lambda x : x .payment_ref == "LABEL 4" )
579+ self .assertEqual (line1 .amount , 50 )
580+ self .assertEqual (line4 .amount , - 1300 )
581+
481582 def test_metadata_separated_debit_credit_xlsx (self ):
482583 journal = self .AccountJournal .create (
483584 {
@@ -491,7 +592,7 @@ def test_metadata_separated_debit_credit_xlsx(self):
491592 statement_map = self .sample_statement_map .copy (
492593 {
493594 "footer_lines_skip_count" : 1 ,
494- "header_lines_skip_count" : 5 ,
595+ "header_lines_skip_count" : 4 ,
495596 "amount_column" : None ,
496597 "partner_name_column" : None ,
497598 "bank_account_column" : None ,
@@ -525,6 +626,58 @@ def test_metadata_separated_debit_credit_xlsx(self):
525626 self .assertEqual (line1 .amount , 50 )
526627 self .assertEqual (line4 .amount , - 1300 )
527628
629+ def test_metadata_separated_debit_credit_no_header_xlsx (self ):
630+ journal = self .AccountJournal .create (
631+ {
632+ "name" : "Bank" ,
633+ "type" : "bank" ,
634+ "code" : "BANK" ,
635+ "currency_id" : self .currency_usd .id ,
636+ "suspense_account_id" : self .suspense_account .id ,
637+ }
638+ )
639+ statement_map = self .sample_statement_map .copy (
640+ {
641+ "footer_lines_skip_count" : 1 ,
642+ "header_lines_skip_count" : 4 ,
643+ "no_header" : True ,
644+ "amount_column" : None ,
645+ "partner_name_column" : None ,
646+ "bank_account_column" : None ,
647+ "float_thousands_sep" : "none" ,
648+ "float_decimal_sep" : "comma" ,
649+ "timestamp_format" : "%m/%d/%y" ,
650+ "timestamp_column" : "0" ,
651+ "description_column" : "2" ,
652+ "original_currency_column" : None ,
653+ "original_amount_column" : None ,
654+ "amount_type" : "distinct_credit_debit" ,
655+ "amount_debit_column" : "3" ,
656+ "amount_credit_column" : "4" ,
657+ }
658+ )
659+ data = self ._data_file (
660+ "fixtures/meta_data_separated_credit_debit_no_header.xlsx"
661+ )
662+ wizard = self .AccountStatementImport .with_context (journal_id = journal .id ).create (
663+ {
664+ "statement_filename" : "fixtures/meta_data_separated_credit_debit_no_header.xlsx" ,
665+ "statement_file" : data ,
666+ "sheet_mapping_id" : statement_map .id ,
667+ }
668+ )
669+ wizard .with_context (
670+ journal_id = journal .id ,
671+ account_bank_statement_import_txt_xlsx_test = True ,
672+ ).import_file_button ()
673+ statement = self .AccountBankStatement .search ([("journal_id" , "=" , journal .id )])
674+ self .assertEqual (len (statement ), 1 )
675+ self .assertEqual (len (statement .line_ids ), 4 )
676+ line1 = statement .line_ids .filtered (lambda x : x .payment_ref == "LABEL 1" )
677+ line4 = statement .line_ids .filtered (lambda x : x .payment_ref == "LABEL 4" )
678+ self .assertEqual (line1 .amount , 50 )
679+ self .assertEqual (line4 .amount , - 1300 )
680+
528681 def test_amount_inverse_sign (self ):
529682 self .sample_statement_map .amount_inverse_sign = True
530683 journal = self .AccountJournal .create (
@@ -568,7 +721,6 @@ def test_import_xlsx_empty_values(self):
568721 "no_header" : 0 ,
569722 "footer_lines_skip_count" : 1 ,
570723 "amount_inverse_sign" : 0 ,
571- "header_lines_skip_count" : 1 ,
572724 "quotechar" : '"' ,
573725 "float_thousands_sep" : "dot" ,
574726 "reference_column" : "REF" ,
@@ -701,21 +853,10 @@ def test_offsets(self):
701853 )
702854 file_name = "fixtures/sample_statement_offsets.xlsx"
703855 data = self ._data_file (file_name )
704- wizard = self .AccountStatementImport .with_context (journal_id = journal .id ).create (
705- {
706- "statement_filename" : file_name ,
707- "statement_file" : data ,
708- "sheet_mapping_id" : self .sample_statement_map .id ,
709- }
710- )
711- with self .assertRaises (UserError ):
712- wizard .with_context (
713- account_statement_import_txt_xlsx_test = True
714- ).import_file_button ()
715856 statement_map_offsets = self .sample_statement_map .copy (
716857 {
717858 "offset_column" : 1 ,
718- "header_lines_skip_count" : 3 ,
859+ "header_lines_skip_count" : 2 ,
719860 }
720861 )
721862 wizard = self .AccountStatementImport .with_context (journal_id = journal .id ).create (
@@ -748,17 +889,6 @@ def test_skip_empty_lines(self):
748889 file_name = "fixtures/empty_lines_statement.csv"
749890 data = self ._data_file (file_name , "utf-8" )
750891
751- wizard = self .AccountStatementImport .with_context (journal_id = journal .id ).create (
752- {
753- "statement_filename" : file_name ,
754- "statement_file" : data ,
755- "sheet_mapping_id" : self .sample_statement_map .id ,
756- }
757- )
758- with self .assertRaises (UserError ):
759- wizard .with_context (
760- account_statement_import_txt_xlsx_test = True
761- ).import_file_button ()
762892 statement_map_empty_line = self .sample_statement_map .copy (
763893 {
764894 "skip_empty_lines" : True ,
0 commit comments