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

[17.0][IMP] l10n_es_vat_book + l10n_es_aeat: Drill through on tax summary #3926

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions l10n_es_aeat/models/l10n_es_aeat_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,12 @@
rcontext
)
return result

@api.model
def _view_move_lines(self, amls):
res = self.env.ref("account.action_account_moves_all_a").sudo().read()[0]
view = self.env.ref("l10n_es_aeat.view_move_line_tree")
res["context"] = {"create": 0}
res["views"] = [(view.id, "tree")]
res["domain"] = [("id", "in", amls.ids)]
return res

Check warning on line 506 in l10n_es_aeat/models/l10n_es_aeat_report.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_aeat/models/l10n_es_aeat_report.py#L501-L506

Added lines #L501 - L506 were not covered by tests
6 changes: 1 addition & 5 deletions l10n_es_aeat/models/l10n_es_aeat_tax_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,4 @@
model = fields.Char(index=True, readonly=True, required=True, string="Model name")

def get_calculated_move_lines(self):
res = self.env.ref("account.action_account_moves_all_a").sudo().read()[0]
view = self.env.ref("l10n_es_aeat.view_move_line_tree")
res["views"] = [(view.id, "tree")]
res["domain"] = [("id", "in", self.move_line_ids.ids)]
return res
return self.env["l10n.es.aeat.report"]._view_move_lines(self.move_line_ids)

Check warning on line 37 in l10n_es_aeat/models/l10n_es_aeat_tax_line.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_aeat/models/l10n_es_aeat_tax_line.py#L37

Added line #L37 was not covered by tests
20 changes: 17 additions & 3 deletions l10n_es_vat_book/models/l10n_es_vat_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@
"tax_id": tax_line.tax_id.id,
"vat_book_id": self.id,
"special_tax_group": tax_line.special_tax_group,
"base_move_line_ids": tax_line.base_move_line_ids.ids,
"move_line_ids": tax_line.move_line_ids.ids,
}
tax_summary_data_recs[tax_line.tax_id][
"base_amount"
Expand All @@ -158,6 +160,12 @@
tax_summary_data_recs[tax_line.tax_id][
"total_amount"
] += tax_line.total_amount
tax_summary_data_recs[tax_line.tax_id][
"base_move_line_ids"
] += tax_line.base_move_line_ids.ids
tax_summary_data_recs[tax_line.tax_id][
"move_line_ids"
] += tax_line.move_line_ids.ids
return tax_summary_data_recs

@api.model
Expand Down Expand Up @@ -249,13 +257,19 @@
balance if move_line.tax_ids and not move_line.tax_line_id else 0.0
)
fee_amount_untaxed = balance if move_line.tax_line_id else 0.0
return {
vals = {
"tax_id": move_line.tax_line_id.id,
"base_amount": base_amount_untaxed,
"tax_amount": fee_amount_untaxed,
"move_line_ids": [(4, move_line.id)],
"base_move_line_ids": [],
"move_line_ids": [],
"special_tax_group": False,
}
if move_line.tax_ids:
vals["base_move_line_ids"].append((4, move_line.id))
elif move_line.tax_line_id:
vals["move_line_ids"].append((4, move_line.id))
return vals

def upsert_book_line_tax(self, move_line, vat_book_line, implied_taxes):
vals = self._prepare_book_line_tax_vals(move_line, vat_book_line)
Expand All @@ -279,7 +293,7 @@
tax_lines[key]["tax_id"] = tax.id
else:
tax_lines[key]["base_amount"] += vals["base_amount"]
tax_lines[key]["move_line_ids"] += vals["move_line_ids"]
tax_lines[key]["base_move_line_ids"] += vals["base_move_line_ids"]

Check warning on line 296 in l10n_es_vat_book/models/l10n_es_vat_book.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_vat_book/models/l10n_es_vat_book.py#L296

Added line #L296 was not covered by tests
# For later matching special taxes
tax_lines[key]["other_tax_ids"] = (move_line.tax_ids - tax).ids

Expand Down
6 changes: 5 additions & 1 deletion l10n_es_vat_book/models/l10n_es_vat_book_line_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ class L10nEsVatBookLineTax(models.Model):
compute="_compute_total_amount",
store=True,
)

base_move_line_ids = fields.Many2many(
comodel_name="account.move.line",
string="Move Lines (Base)",
relation="account_move_line_l10n_es_vat_book_line_tax_base_rel",
)
move_line_ids = fields.Many2many(
comodel_name="account.move.line", string="Move Lines"
)
Expand Down
14 changes: 14 additions & 0 deletions l10n_es_vat_book/models/l10n_es_vat_book_tax_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,17 @@
required=True,
ondelete="cascade",
)
base_move_line_ids = fields.Many2many(
comodel_name="account.move.line",
string="Journal items (Base)",
relation="account_move_line_l10n_es_vat_book_tax_summary_base_rel",
)
move_line_ids = fields.Many2many(
comodel_name="account.move.line", string="Journal items"
)

def view_move_lines_base(self):
return self.env["l10n.es.aeat.report"]._view_move_lines(self.base_move_line_ids)

Check warning on line 33 in l10n_es_vat_book/models/l10n_es_vat_book_tax_summary.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_vat_book/models/l10n_es_vat_book_tax_summary.py#L33

Added line #L33 was not covered by tests

def view_move_lines_tax(self):
return self.env["l10n.es.aeat.report"]._view_move_lines(self.move_line_ids)

Check warning on line 36 in l10n_es_vat_book/models/l10n_es_vat_book_tax_summary.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_vat_book/models/l10n_es_vat_book_tax_summary.py#L36

Added line #L36 was not covered by tests
17 changes: 17 additions & 0 deletions l10n_es_vat_book/views/l10n_es_vat_book_tax_summary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,25 @@
<tree decoration-muted="special_tax_group">
<field name="special_tax_group" />
<field name="base_amount" />
<!-- We don't add a visibility condition, as that would mean to have
a field determining if there are moves or not, which can drain the
performance -->
<button
name="view_move_lines_base"
type="object"
aria-label="Show journal items"
title="Show journal items"
icon="fa-search-plus"
/>
<field name="tax_id" />
<field name="tax_amount" />
<button
name="view_move_lines_tax"
type="object"
aria-label="Show journal items"
title="Show journal items"
icon="fa-search-plus"
/>
<field name="total_amount" />
</tree>
</field>
Expand Down
Loading