Skip to content

Commit

Permalink
fixup! [ADD] l10n_de_dtvf
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Mar 17, 2023
1 parent 3b13e7d commit 7a2422e
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions l10n_de_dtvf/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
],
"data": [
"security/ir.model.access.csv",
"views/account_account.xml",
"views/l10n_de_dtvf_export.xml",
"views/res_company.xml",
],
Expand Down
1 change: 1 addition & 0 deletions l10n_de_dtvf/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import account_account
from . import l10n_de_dtvf_export
from . import res_company
6 changes: 6 additions & 0 deletions l10n_de_dtvf/models/l10n_de_dtvf_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,19 @@ def _get_data_transaction(self, move):
"payable",
) and move_line2.account_id.internal_type in ("receivable", "payable"):
move_line, move_line2 = move_line2, move_line
if move_line.account_id.datev_export_nonautomatic:
move_line, move_line2 = move_line2, move_line
data = {
"Umsatz (ohne Soll/Haben-Kz)": ("%.2f" % abs(amount)).replace(".", ","),
"Soll/Haben-Kennzeichen": move_line.debit and "S" or "H",
"Konto": move_line.account_id.code[-code_length:],
"Gegenkonto (ohne BU-Schlüssel)": move_line2.account_id.code[
-code_length:
],
"BU-Schlüssel": "40"
if move_line.account_id.datev_export_nonautomatic
or move_line2.account_id.datev_export_nonautomatic
else "",
"Buchungstext": move_line.name,
"Belegdatum": move.date.strftime("%d%m"),
"Belegfeld 1": move.name,
Expand Down
60 changes: 60 additions & 0 deletions l10n_de_dtvf/tests/test_l10n_de_dtvf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,63 @@ def test_happy_flow(self):
)
self.wizard.action_draft()
self.assertEqual(self.wizard.state, "draft")

def test_nonautomatic_flag(self):
"""Test setting BU-Schlussel 40 works as it should"""
journal = self.env["account.journal"].create(
{
"name": "Testjournal",
"type": "sale",
"code": "DTV",
}
)
account1 = self.env["account.account"].create(
{
"name": "Nonautomatic export",
"code": "424242",
"user_type_id": self.env.ref("account.data_account_type_revenue").id,
}
)
account2 = self.env["account.account"].create(
{
"name": "Receivable",
"code": "424243",
"datev_export_nonautomatic": True,
"user_type_id": self.env.ref("account.data_account_type_receivable").id,
"reconcile": True,
}
)
move = self.env["account.move"].create(
{
"journal_id": journal.id,
"line_ids": [
(
0,
0,
{
"account_id": account1.id,
"credit": 42,
},
),
(
0,
0,
{
"account_id": account2.id,
"debit": 42,
},
),
],
}
)
move.action_post()
self.wizard.journal_ids = journal
self.wizard.action_generate()
zip_buffer = io.BytesIO(base64.b64decode(self.wizard.file_data))
with zipfile.ZipFile(zip_buffer) as zip_file:
move_line_file_name = [
f for f in zip_file.namelist() if f.startswith("EXTF_Buchungsstapel")
][0]
with zip_file.open(move_line_file_name) as move_line_file:
move_line = move_line_file.readlines()[2].decode("utf8")
self.assertIn('"40"', move_line)
1 change: 1 addition & 0 deletions l10n_de_dtvf/views/l10n_de_dtvf_export.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
domain="[('date_start', '>=', fiscalyear_start), ('date_end', '<=', fiscalyear_end)]"
attrs="{'readonly': [('fiscalyear_id', '=', False)]}"
/>
<field name="journal_ids" widget="many2many_tags" />
</group>
<group name="result" states="done">
<field name="date_generated" />
Expand Down

0 comments on commit 7a2422e

Please sign in to comment.