Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] account_statement_import_sheet_file: Reset fields based on the selected 'amount_type' value when its change #757

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,17 @@ def _decode_column_delimiter_character(self, delimiter):

def _get_column_delimiter_character(self):
return self._decode_column_delimiter_character(self.delimiter)

@api.onchange("amount_type")
def _onchange_amount_type(self):
if self.amount_type == "simple_value":
self.debit_credit_column = False
self.amount_debit_column = False
self.amount_credit_column = False
elif self.amount_type == "absolute_value":
self.amount_column = False
self.amount_debit_column = False
self.amount_credit_column = False
elif self.amount_type == "distinct_credit_debit":
self.amount_column = False
self.debit_credit_column = False
Original file line number Diff line number Diff line change
Expand Up @@ -769,3 +769,37 @@ def test_skip_empty_lines(self):
self.assertEqual(statement.balance_start, 0.0)
self.assertEqual(statement.balance_end_real, 2291.5)
self.assertEqual(statement.balance_end, 2291.5)

def test_onchange_amount_type_simple_value(self):
"""Test that fields are reset when 'amount_type'
is set to 'simple_value'."""
self.sample_statement_map.amount_column = "Amount"
self.sample_statement_map.amount_type = "simple_value"
self.sample_statement_map._onchange_amount_type()
self.assertFalse(self.sample_statement_map.debit_credit_column)
self.assertFalse(self.sample_statement_map.amount_debit_column)
self.assertFalse(self.sample_statement_map.amount_credit_column)
self.assertEqual(self.sample_statement_map.amount_column, "Amount")

def test_onchange_amount_type_absolute_value(self):
"""Test that fields are reset when 'amount_type'
is set to 'absolute_value'."""
self.sample_statement_map.debit_credit_column = "Amount"
self.sample_statement_map.amount_type = "absolute_value"
self.sample_statement_map._onchange_amount_type()
self.assertFalse(self.sample_statement_map.amount_column)
self.assertFalse(self.sample_statement_map.amount_debit_column)
self.assertFalse(self.sample_statement_map.amount_credit_column)
self.assertEqual(self.sample_statement_map.debit_credit_column, "Amount")

def test_onchange_amount_type_distinct_credit_debit(self):
"""Test that fields are reset when 'amount_type'
is set to 'distinct_credit_debit'."""
self.sample_statement_map.amount_debit_column = "Debit"
self.sample_statement_map.amount_credit_column = "Credit"
self.sample_statement_map.amount_type = "distinct_credit_debit"
self.sample_statement_map._onchange_amount_type()
self.assertFalse(self.sample_statement_map.amount_column)
self.assertFalse(self.sample_statement_map.debit_credit_column)
self.assertEqual(self.sample_statement_map.amount_debit_column, "Debit")
self.assertEqual(self.sample_statement_map.amount_credit_column, "Credit")
Loading