Skip to content

Commit

Permalink
Merge pull request #52 from onesteinbv/12_fix_l10n_de_tax_statement
Browse files Browse the repository at this point in the history
[12.0][FIX] l10n_de_tax_statement: format of tax lines
  • Loading branch information
tv-openbig committed Aug 21, 2019
2 parents ee6c352 + f4e7cbf commit 38d49d3
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 45 deletions.
3 changes: 1 addition & 2 deletions l10n_de_tax_statement/models/l10n_de_tax_statement.py
Expand Up @@ -74,11 +74,10 @@ class VatStatement(models.Model):

tax_total = fields.Monetary(
compute='_compute_tax_total',
string='Verbl. Ust.-Vorauszahlung (66 - 67)'
string='Verbl. Ust.-Vorauszahlung'
)
format_tax_total = fields.Char(
compute='_compute_amount_format_tax_total',
string='Verbl. Ust.-Vorauszahlung'
)
move_line_ids = fields.One2many(
'account.move.line',
Expand Down
45 changes: 45 additions & 0 deletions l10n_de_tax_statement/models/l10n_de_tax_statement_2018.py
Expand Up @@ -371,3 +371,48 @@ def _get_tags_map_2018(config):

def _totals_2018():
return ['66', '67']


def _base_display_2018():
return (
'20', '21', '22', '23', '24',
'26', '27', '28', '29', '30',
'32', '33', '34', '35', '36',
'38', '39', '40', '41', '42',
'48', '49', '50', '51', '52',
)


def _tax_display_2018():
return (
'26', '27', '28', '30',
'33', '34', '35', '36',
'48', '49', '50', '51', '52', '53', '55',
'56', '57', '58', '59',
'60', '61', '62', '64', '65', '66', '67',
)


def _group_display_2018():
return (
'17', '18', '19',
'25', '31', '37',
'47', '54', '63',
)


def _editable_display_2018():
return (
'20', '21', '22', '23', '24',
'26', '27', '28', '29', '30',
'32', '33', '34', '35', '36',
'38', '39', '40', '41', '42',
'48', '49', '50', '51', '52',
'64', '65', '67',
)


def _total_display_2018():
return (
'53', '62',
)
45 changes: 45 additions & 0 deletions l10n_de_tax_statement/models/l10n_de_tax_statement_2019.py
Expand Up @@ -348,3 +348,48 @@ def _get_tags_map_2019(config):

def _totals_2019():
return ['64', '65']


def _base_display_2019():
return (
'20', '21', '22', '23', '24',
'26', '27', '28', '29', '30',
'32', '33', '34', '35', '36',
'38', '39', '40', '41', '48',
'49', '50',
)


def _tax_display_2019():
return (
'26', '27', '28', '30',
'33', '34', '35', '36',
'48', '49', '50', '51',
'53', '54', '55', '56',
'57', '58', '59', '60',
'62', '63', '64', '65',
)


def _group_display_2019():
return (
'17', '18', '19',
'25', '31', '37',
'47', '52', '61',
)


def _editable_display_2019():
return (
'20', '21', '22', '23', '24',
'26', '27', '28', '29', '30',
'32', '33', '34', '35', '36',
'38', '39', '40', '41', '42',
'48', '49', '50', '64', '65',
)


def _total_display_2019():
return (
'51', '60',
)
70 changes: 30 additions & 40 deletions l10n_de_tax_statement/models/l10n_de_tax_statement_line.py
Expand Up @@ -7,41 +7,12 @@
from odoo.exceptions import UserError
from odoo.tools.misc import formatLang


BASE_DISPLAY = (
'20', '21', '22', '23', '24',
'26', '27', '28', '29', '30',
'32', '33', '34', '35', '36',
'38', '39', '40', '41', '42',
'48', '49', '50', '51', '52',
)

TAX_DISPLAY = (
'26', '27', '28', '30',
'33', '34', '35', '36',
'48', '49', '50', '51', '52', '53', '55',
'56', '57', '58', '59',
'60', '61', '62', '64', '65', '66', '67',
)

GROUP_DISPLAY = (
'17', '18', '19',
'25', '31', '37',
'47', '54', '63',
)

EDITABLE_DISPLAY = (
'20', '21', '22', '23', '24',
'26', '27', '28', '29', '30',
'32', '33', '34', '35', '36',
'38', '39', '40', '41', '42',
'48', '49', '50', '51', '52',
'64', '65', '67',
)

TOTAL_DISPLAY = (
'53', '62',
)
from .l10n_de_tax_statement_2018 import \
_base_display_2018, _tax_display_2018, \
_group_display_2018, _total_display_2018, _editable_display_2018
from .l10n_de_tax_statement_2019 import \
_base_display_2019, _tax_display_2019, \
_group_display_2019, _total_display_2019, _editable_display_2019


class VatStatementLine(models.Model):
Expand Down Expand Up @@ -75,26 +46,45 @@ class VatStatementLine(models.Model):
@api.depends('base', 'tax', 'code')
def _compute_amount_format(self):
for line in self:
if line.statement_id.version == '2019':
base_display = _base_display_2019()
tax_display = _tax_display_2019()
else:
base_display = _base_display_2018()
tax_display = _tax_display_2018()

base = formatLang(self.env, line.base, monetary=True)
tax = formatLang(self.env, line.tax, monetary=True)
if line.code in BASE_DISPLAY:
if line.code in base_display:
line.format_base = base
if line.code in TAX_DISPLAY:
if line.code in tax_display:
line.format_tax = tax

@api.multi
@api.depends('code')
def _compute_is_group(self):
for line in self:
line.is_group = line.code in GROUP_DISPLAY
line.is_total = line.code in TOTAL_DISPLAY
if line.statement_id.version == '2019':
group_display = _group_display_2019()
total_display = _total_display_2019()
else:
group_display = _group_display_2018()
total_display = _total_display_2018()

line.is_group = line.code in group_display
line.is_total = line.code in total_display

@api.multi
@api.depends('code')
def _compute_is_readonly(self):
for line in self:
if line.statement_id.version == '2019':
editable_display = _editable_display_2019()
else:
editable_display = _editable_display_2018()

if line.statement_id.state == 'draft':
line.is_readonly = line.code not in EDITABLE_DISPLAY
line.is_readonly = line.code not in editable_display
else:
line.is_readonly = True

Expand Down
2 changes: 1 addition & 1 deletion l10n_de_tax_statement/report/report_tax_statement.xml
Expand Up @@ -75,7 +75,7 @@
</t>
<div class="de_tax_act_as_row lines">
<!--## total tax-->
<div class="de_tax_act_as_cell left" style="width: 900px;"> &amp;nbsp; &amp;nbsp; 68 - Verbleibende Umsatzsteuer-Vorauszahlung (83)</div>
<div class="de_tax_act_as_cell left" style="width: 900px;"> &amp;nbsp; &amp;nbsp; Verbleibende Umsatzsteuer-Vorauszahlung</div>
<div class="de_tax_act_as_cell right"> </div>
<div class="de_tax_act_as_cell right"><span t-field="o.format_tax_total"/></div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions l10n_de_tax_statement/tests/test_l10n_de_tax_statement.py
Expand Up @@ -7,7 +7,7 @@

from odoo import fields
from odoo.tools import convert_file
from odoo.modules.module import get_module_resource
from odoo.modules.module import get_resource_path
from odoo.exceptions import UserError
from odoo.tests.common import TransactionCase

Expand All @@ -18,7 +18,7 @@ def _load(self, module, *args):
convert_file(
self.cr,
'l10n_de',
get_module_resource(module, *args),
get_resource_path(module, *args),
{}, 'init', False, 'test', self.registry._assertion_report)

def setUp(self):
Expand Down

0 comments on commit 38d49d3

Please sign in to comment.