@@ -594,6 +594,57 @@ def test_reconcile_invoice_keep(self):
594
594
self .assertTrue (reconcile_move .reversal_move_id )
595
595
self .assertFalse (bank_stmt_line .is_reconciled )
596
596
597
+ def test_reconcile_model_with_foreign_currency (self ):
598
+ """
599
+ We want to test what happens when we select a reconcile model to fill a
600
+ bank statement with a foreign currency.
601
+ """
602
+ bank_stmt = self .acc_bank_stmt_model .create (
603
+ {
604
+ "journal_id" : self .bank_journal_usd .id ,
605
+ "date" : time .strftime ("%Y-07-15" ),
606
+ "name" : "test" ,
607
+ }
608
+ )
609
+ bank_stmt_line = self .acc_bank_stmt_line_model .create (
610
+ {
611
+ "name" : "testLine" ,
612
+ "journal_id" : self .bank_journal_usd .id ,
613
+ "statement_id" : bank_stmt .id ,
614
+ "amount" : 100 ,
615
+ "date" : time .strftime ("%Y-07-15" ),
616
+ }
617
+ )
618
+ with Form (
619
+ bank_stmt_line ,
620
+ view = "account_reconcile_oca.bank_statement_line_form_reconcile_view" ,
621
+ ) as f :
622
+ self .assertFalse (f .can_reconcile )
623
+ f .manual_model_id = self .rule
624
+ self .assertTrue (f .can_reconcile )
625
+ number_of_lines = len (bank_stmt_line .reconcile_data_info ["data" ])
626
+ bank_stmt_line .reconcile_bank_line ()
627
+ self .assertEqual (
628
+ number_of_lines , len (bank_stmt_line .reconcile_data_info ["data" ])
629
+ )
630
+ self .assertEqual (2 , len (bank_stmt_line .move_id .line_ids ))
631
+ self .assertTrue (
632
+ bank_stmt_line .move_id .line_ids .filtered (
633
+ lambda r : r .account_id == self .current_assets_account
634
+ )
635
+ )
636
+ expected_amount = bank_stmt_line ._get_reconcile_currency ()._convert (
637
+ bank_stmt_line .amount ,
638
+ bank_stmt_line .company_id .currency_id ,
639
+ bank_stmt_line .company_id ,
640
+ bank_stmt_line .date ,
641
+ )
642
+ self .assertEqual (
643
+ bank_stmt_line .move_id .line_ids [0 ].amount_currency , bank_stmt_line .amount
644
+ )
645
+ self .assertEqual (bank_stmt_line .move_id .line_ids [0 ].debit , expected_amount )
646
+ self .assertEqual (bank_stmt_line .move_id .line_ids [1 ].credit , expected_amount )
647
+
597
648
# Testing to check functionality
598
649
599
650
def test_reconcile_invoice_to_check_reconciled (self ):
0 commit comments