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

[18.0][MIG] account_statement_import_sheet_file: Migration to 18.0 #747

Open
wants to merge 58 commits into
base: 18.0
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
629b125
[MIG] account_bank_statement_import_txt_xlsx: Migration to 14.0
primes2h Sep 9, 2021
733c2dd
Added translation using Weblate (Italian)
primes2h Nov 24, 2021
9c022da
Added translation using Weblate (Portuguese)
pedrocs-exo Nov 25, 2021
f935d0c
Translated using Weblate (Italian)
primes2h Nov 25, 2021
6630f31
[account_statement_import_txt_xlsx][imp] add migration scripts
JordiBForgeFlow Dec 6, 2021
3758742
Added translation using Weblate (Spanish (Argentina))
ibuioli Jan 7, 2022
0e14b19
Translated using Weblate (Spanish (Argentina))
ibuioli Jan 9, 2022
16e9d71
[MIG] account_statement_import_txt_xlsx: Migration to 15.0
nicomacr Oct 5, 2022
f6bd0b6
Translated using Weblate (Italian)
francesco-ooops Jan 2, 2023
6a6986a
[FIX] account_bank_statement_import_txt_xlsx: import sheet notes
Aug 11, 2021
6147da8
[IMP] account_statement_import_txt_xlsx: wizard: 2 amount columns, fo…
norlinhenrik Apr 3, 2022
35ebacb
[IMP] account_statement_import_txt_xlsx: amount_debit_column, amount_…
norlinhenrik Dec 20, 2022
6619ea2
[IMP] account_statement_import_txt_xlsx: Allow mapping with reference…
JordiBForgeFlow Dec 16, 2022
a71266a
[IMP] account_statement_import_txt_xlsx: add tests
JordiBForgeFlow Dec 18, 2022
fead3d6
[IMP] account_statement_import_txt_xlsx: Calculate final balance if n…
JordiBForgeFlow Feb 22, 2023
85e0bbc
[FIX] account_statement_import_txt_xlsx: Don't try to parse if no map…
pedrobaeza Feb 25, 2023
85de6ba
[ADD] account_statement_import_txt_xlsx: show mapping error
zaoral Nov 12, 2022
11e39e1
Translated using Weblate (Italian)
francesco-ooops May 24, 2023
91a142a
Added translation using Weblate (Spanish)
pere-aquarian Jun 23, 2023
9bb19d5
Translated using Weblate (Spanish)
pere-aquarian Jun 23, 2023
ea8bfd3
[FIX] account_statement_import_txt_xlsx: Make tests resilient
victoralmau Aug 16, 2023
d943c83
[MIG] account_statement_import_txt_xlsx: Migration to 16.0
pablohmontenegro Jun 14, 2023
7f62352
[IMP] account_bank_statement_import_txt_xlsx: CSV
zaoral Nov 15, 2022
125cd28
[UPD] Update account_statement_import_sheet_file.pot
Oct 31, 2023
90cc492
[BOT] post-merge updates
OCA-git-bot Oct 31, 2023
d08be58
Translated using Weblate (Spanish)
Ivorra78 Nov 1, 2023
4b205a6
[IMP] account_statement_import_sheet_file: add field amount_inverse_s…
JordiBForgeFlow Jan 31, 2024
d2bdba7
[UPD] Update account_statement_import_sheet_file.pot
Feb 6, 2024
93db6b0
[BOT] post-merge updates
OCA-git-bot Feb 6, 2024
65998fd
Added translation using Weblate (Turkish)
Feb 6, 2024
9314baf
Translated using Weblate (Turkish)
Feb 6, 2024
79ca9a0
Translated using Weblate (Spanish)
Ivorra78 Feb 8, 2024
0269dc0
Translated using Weblate (Italian)
mymage Mar 1, 2024
3defd2f
[IMP] account_statement_import_sheet_file: add quote as thousand sepa…
alexis-via Mar 13, 2024
628d572
Translated using Weblate (Italian)
alessandro-fiorino Mar 30, 2024
0972ae2
[UPD] Update account_statement_import_sheet_file.pot
Apr 22, 2024
f8d4174
[BOT] post-merge updates
OCA-git-bot Apr 22, 2024
2937d91
Update translation files
weblate Apr 22, 2024
7b1b6bb
Translated using Weblate (Italian)
mymage May 3, 2024
5ba2edb
[IMP][account_statement_import_sheet_file] Empty lines with spaces, o…
mileo May 10, 2024
2bbc178
Translated using Weblate (Spanish)
berisoft-arg May 12, 2024
1f392af
[REF][account_statement_import_sheet_file] Remove decimal
mileo May 12, 2024
b640a6d
[BOT] post-merge updates
OCA-git-bot May 13, 2024
84e5250
[IMP] account_statement_import_sheet_file: pre-commit execution
rov-adhoc Dec 27, 2023
ee272f0
[MIG] account_statement_import_sheet_file: Migration to 17.0
rov-adhoc Dec 27, 2023
fd16550
[UPD] Update account_statement_import_sheet_file.pot
May 21, 2024
4e1028c
[BOT] post-merge updates
OCA-git-bot May 21, 2024
a802381
Update translation files
weblate May 21, 2024
df9428e
Translated using Weblate (Italian)
mymage May 22, 2024
49b9552
Translated using Weblate (Chinese (Simplified) (zh_CN))
xtanuiha Jun 12, 2024
01c839e
Translated using Weblate (Chinese (Simplified) (zh_CN))
xtanuiha Jun 12, 2024
e240014
[IMP] account_statement_import_sheet_file: additional mapping controls
jdidderen-noviat Jun 21, 2023
f4c3f2f
[UPD] Update account_statement_import_sheet_file.pot
Dec 4, 2024
3735ddd
[BOT] post-merge updates
OCA-git-bot Dec 4, 2024
32b8778
Update translation files
weblate Dec 4, 2024
f47bfca
Translated using Weblate (Italian)
mymage Dec 5, 2024
94b6ed6
[IMP] account_statement_import_sheet_file: pre-commit execution
feg-adhoc Dec 12, 2024
4283006
[MIG] account_statement_import_sheet_file: Migration to 18.0
feg-adhoc Dec 12, 2024
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
Prev Previous commit
Next Next commit
[IMP] account_statement_import_sheet_file: add field amount_inverse_s…
…ign_column.

In some cases such as in credit card statements the amounts are expressed in the inverse sign.
By setting this flag during the upload the amounts will be inverted in sign.
JordiBForgeFlow authored and feg-adhoc committed Dec 17, 2024
commit 4b205a64f46881f90f9216f2074f2ead92b27b63
Original file line number Diff line number Diff line change
@@ -79,6 +79,13 @@ class AccountStatementImportSheetMapping(models.Model):
string="Credit amount column",
help="Credit amount of transaction in journal's currency",
)
amount_inverse_sign = fields.Boolean(
string="Inverse sign of amount",
help="In some cases such as in credit card statements the "
"amounts are expressed in the inverse sign. "
"By setting this flag during the upload the amounts "
"will be inverted in sign.",
)
balance_column = fields.Char(
help="Balance after transaction in journal's currency",
)
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

import itertools
import logging
from collections.abc import Iterable
from datetime import datetime
from decimal import Decimal
from io import StringIO
@@ -97,7 +98,11 @@ def parse(self, data_file, mapping, filename):

def _get_column_indexes(self, header, column_name, mapping):
column_indexes = []
if mapping[column_name] and "," in mapping[column_name]:
if (
mapping[column_name]
and isinstance(mapping[column_name], Iterable)
and "," in mapping[column_name]
):
# We have to concatenate the values
column_names_or_indexes = mapping[column_name].split(",")
else:
@@ -320,6 +325,18 @@ def _decimal(column_name):
else None
)

debit_column = (
self._get_values_from_column(values, columns, "amount_debit_column")
if columns["amount_debit_column"]
else None
)

credit_column = (
self._get_values_from_column(values, columns, "amount_credit_column")
if columns["amount_credit_column"]
else None
)

if currency != currency_code:
continue

@@ -342,7 +359,10 @@ def _decimal(column_name):
).copy_sign(amount)
else:
original_amount = 0.0

if mapping.amount_inverse_sign:
amount = -amount
original_amount = -original_amount
balance = -balance if balance is not None else balance
line = {
"timestamp": timestamp,
"amount": amount,
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"Date","Label","Currency","Amount","Amount Currency","Partner Name","Bank Account"
"12/15/2018","LABEL 1","USD","33.50","0.0","John Doe","123456789"
"12/15/2018","LABEL 2","EUR","-1,525.00","-1,000.00","Azure Interior",""
Original file line number Diff line number Diff line change
@@ -506,3 +506,35 @@ def test_metadata_separated_debit_credit_xlsx(self):
line4 = statement.line_ids.filtered(lambda x: x.payment_ref == "LABEL 4")
self.assertEqual(line1.amount, 50)
self.assertEqual(line4.amount, -1300)

def test_amount_inverse_sign(self):
self.sample_statement_map.amount_inverse_sign = True
journal = self.AccountJournal.create(
{
"name": "Bank",
"type": "bank",
"code": "BANK",
"currency_id": self.currency_usd.id,
"suspense_account_id": self.suspense_account.id,
}
)
filename = "fixtures/sample_statement_credit_card_inverse_sign_en.csv"
data = self._data_file(filename, "utf-8")
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
{
"statement_filename": filename,
"statement_file": data,
"sheet_mapping_id": self.sample_statement_map.id,
}
)
wizard.with_context(
account_statement_import_sheet_file_test=True
).import_file_button()
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
self.assertEqual(len(statement), 1)
self.assertEqual(len(statement.line_ids), 2)
line1 = statement.line_ids.filtered(lambda x: x.payment_ref == "LABEL 1")
self.assertEqual(line1.amount, -33.50)
line2 = statement.line_ids.filtered(lambda x: x.payment_ref == "LABEL 2")
self.assertEqual(line2.amount, 1525.00)
self.assertEqual(line2.amount_currency, 1000.00)
Original file line number Diff line number Diff line change
@@ -89,6 +89,7 @@
'invisible': [('amount_type', '=', 'distinct_credit_debit')],
}"
/>

<field
name="amount_debit_column"
attrs="{
@@ -103,6 +104,7 @@
'invisible': [('amount_type', '!=', 'distinct_credit_debit')],
}"
/>
<field name="amount_inverse_sign" />
<field name="balance_column" />
<field name="original_currency_column" />
<field name="original_amount_column" />