Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe committed Jul 30, 2019
1 parent 54ee96e commit 9f467b5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
6 changes: 2 additions & 4 deletions l10n_nl_tax_statement/models/l10n_nl_vat_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ def default_get(self, fields_list):
defaults = super().default_get(fields_list)
company = self.env.user.company_id
fy_dates = company.compute_fiscalyear_dates(datetime.now())
from_date = fields.Date.to_string(fy_dates['date_from'])
to_date = fields.Date.to_string(fy_dates['date_to'])
defaults.setdefault('from_date', from_date)
defaults.setdefault('to_date', to_date)
defaults.setdefault('from_date', fy_dates['date_from'])
defaults.setdefault('to_date', fy_dates['date_to'])
defaults.setdefault('name', company.name)
return defaults

Expand Down
55 changes: 27 additions & 28 deletions l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,14 @@ def test_11_wizard_execute(self):
def test_12_undeclared_invoice(self):
self.invoice_1._onchange_invoice_line_ids()
self.invoice_1.action_invoice_open()
move = self.invoice_1.move_id
move.with_context(params={
move = self.invoice_1.move_id.with_context(params={
'model': 'l10n.nl.vat.statement',
'id': self.statement_1.id
}).l10n_nl_add_move_in_statement()
})
move.l10n_nl_add_move_in_statement()
for line in self.invoice_1.move_id.line_ids:
self.assertTrue(line.l10n_nl_vat_statement_include)
move.with_context(params={
'model': 'l10n.nl.vat.statement',
'id': self.statement_1.id
}).l10n_nl_unlink_move_from_statement()
move.l10n_nl_unlink_move_from_statement()
for line in self.invoice_1.move_id.line_ids:
self.assertFalse(line.l10n_nl_vat_statement_include)

Expand Down Expand Up @@ -404,28 +401,30 @@ def test_15_invoice_basis_undeclared_invoice(self):
('name', '=', 'l10n_nl_tax_invoice_basis')
])
if has_invoice_basis:

self.statement_1.company_id.l10n_nl_tax_invoice_basis = True
self.statement_1.company_id.country_id = self.env.ref('base.nl')

invoice2 = self.invoice_1.copy()
old_date = fields.Date.from_string('2018-12-07')
invoice2.date_invoice = old_date
invoice2.action_invoice_open()

statement2 = self.env['l10n.nl.vat.statement'].create({
'name': 'Statement 2',
})
move_from_date = fields.Date.from_string('2015-07-07')
statement2.unreported_move_from_date = move_from_date
statement2.onchange_unreported_move_from_date()
statement2.statement_update()
statement2.with_context(
skip_check_config_tag_3b_omzet=True
).post()

self.assertTrue(statement2.unreported_move_ids)
self.assertEqual(len(statement2.unreported_move_ids), 1)
else:
self.statement_1.company_id.l10n_nl_tax_invoice_basis = False
self.statement_1.company_id.country_id = self.env.ref('base.nl')

invoice2 = self.invoice_1.copy()
old_date = fields.Date.from_string('2018-12-07')
invoice2.date_invoice = old_date
invoice2.action_invoice_open()

statement2 = self.env['l10n.nl.vat.statement'].create({
'name': 'Statement 2',
})
move_from_date = fields.Date.from_string('2015-07-07')
statement2.unreported_move_from_date = move_from_date
statement2.onchange_unreported_move_from_date()
statement2.unreported_move_ids.l10n_nl_add_move_in_statement()
statement2.statement_update()
self.assertTrue(statement2.unreported_move_ids)
self.assertEqual(len(statement2.unreported_move_ids), 1)

statement2.with_context(
skip_check_config_tag_3b_omzet=True
).post()

self.assertEqual(self.statement_1.btw_total, 10.5)
self.assertEqual(self.statement_1.format_btw_total, '10.50')
Expand Down

0 comments on commit 9f467b5

Please sign in to comment.