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

[15.0] Revert "[FIX] l10n_es_aeat_mod349: origin amount incorrect" #3727

Merged
merged 1 commit into from
Sep 19, 2024
Merged
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
41 changes: 0 additions & 41 deletions l10n_es_aeat_mod349/models/mod349.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,53 +223,12 @@ def _create_349_refund_records(self):
if original_details:
# There's at least one previous 349 declaration report
report = original_details.mapped("report_id")[:1]
partner_id = original_details.mapped("partner_id")[:1]
original_details = original_details.filtered(
lambda d: d.report_id == report
)
origin_amount = sum(original_details.mapped("amount_untaxed"))
period_type = report.period_type
year = str(report.year)

# Sum all details period origin
all_details_period = detail_obj.search(
[
("partner_id", "=", partner_id.id),
("partner_record_id.operation_key", "=", op_key),
("report_id", "=", report.id),
],
order="report_id desc",
)
origin_amount = sum(all_details_period.mapped("amount_untaxed"))

# If there are intermediate periods between the original
# period and the period where the rectification is taking
# place, it's necessary to check if there is any rectification
# of the original period in between these periods. This
# happens in this way because the right original_amount
# will be the value of the total_operation_amount
# corresponding to the last period found in between the periods
other_invoice_period = (
all_details_period.mapped("move_id") - origin_invoice
)
refund_invoice_ids = self.env["account.move"].search(
[("reversed_entry_id", "in", other_invoice_period.ids)]
)
if refund_invoice_ids:
last_refund_detail = refund_detail_obj.search(
[
("report_id.date_start", ">", report.date_end),
("report_id.date_end", "<", self.date_start),
("move_id", "in", refund_invoice_ids.ids),
],
order="date desc",
limit=1,
)
if last_refund_detail:
origin_amount = (
last_refund_detail.refund_id.total_operation_amount
)

else:
# There's no previous 349 declaration report in Odoo
original_amls = move_line_obj.search(
Expand Down
Loading