Skip to content

Commit 4422b47

Browse files
committed
[FIX] account_statement_import_sheet_file: Bugs with amount_type selection
1 parent 35b0cd3 commit 4422b47

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

account_statement_import_sheet_file/models/account_statement_import_sheet_mapping.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ def _check_columns(self):
233233
if mapping.offset_column < 0:
234234
raise ValidationError(_("Offsets cannot be negative"))
235235

236+
@api.onchange("amount_type")
237+
def _clear_amount_columns(self):
238+
self.amount_column = False
239+
self.debit_credit_column = False
240+
self.amount_debit_column = False
241+
self.amount_credit_column = False
242+
236243
def _get_float_separators(self):
237244
self.ensure_one()
238245
separators = {

account_statement_import_sheet_file/models/account_statement_import_sheet_parser.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,14 @@ def _decimal(column_name, values):
314314
mapping,
315315
)
316316

317-
amount = _decimal("amount_column", values)
318-
if not amount:
317+
if mapping.amount_type == "distinct_credit_debit":
319318
amount = abs(_decimal("amount_debit_column", values) or 0)
320-
if not amount:
321-
amount = -abs(_decimal("amount_credit_column", values) or 0)
319+
if not amount:
320+
amount = -abs(_decimal("amount_credit_column", values) or 0)
321+
elif mapping.amount_type == "simple_value":
322+
amount = _decimal("amount_column", values)
323+
elif mapping.amount_type == "absolute_value":
324+
amount = abs(_decimal("debit_credit_column", values) or 0)
322325

323326
balance = (
324327
self._get_values_from_column(values, columns, "balance_column")

account_statement_import_sheet_file/views/account_statement_import_sheet_mapping.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
<field name="amount_type" />
7979
<field
8080
name="amount_column"
81-
invisible="amount_type == 'distinct_credit_debit'"
82-
required="amount_type != 'distinct_credit_debit'"
81+
invisible="amount_type != 'simple_value'"
82+
required="amount_type == 'simple_value'"
8383
/>
8484

8585
<field
@@ -92,15 +92,15 @@
9292
invisible="amount_type != 'distinct_credit_debit'"
9393
required="amount_type == 'distinct_credit_debit'"
9494
/>
95-
<field name="amount_inverse_sign" />
96-
<field name="balance_column" />
97-
<field name="original_currency_column" />
98-
<field name="original_amount_column" />
9995
<field
10096
name="debit_credit_column"
10197
invisible="amount_type != 'absolute_value'"
10298
required="amount_type == 'absolute_value'"
10399
/>
100+
<field name="amount_inverse_sign" />
101+
<field name="balance_column" />
102+
<field name="original_currency_column" />
103+
<field name="original_amount_column" />
104104
<field name="transaction_id_column" />
105105
<field name="description_column" />
106106
<field name="notes_column" />

0 commit comments

Comments
 (0)