[FIX] l10n_sa_edi: fix tax retention on invoice lines
Steps to reproduce: - Install Accounting and l10n_sa_edi - Create a retention tax: (e.g. "Retention Tax 10%") * Amount: [a negative amount] (e.g. -10.00%) * Is Retention: [checked] (in "Advanced Options" tab) - Create an invoice with the following invoice line: * Product: [any] * Price: 1000 * Taxes: "Sales Tax 15%" and "Retention Tax 10%" - Confirm the invoice - Print the invoice => On the invoice, there is a "VAT Amount" field that should show the amount coming from the taxes that are not Retention taxes as it is done in the EDI invoice (XML). However, the Retention tax is subtracted. In our example: - Tax amount for "Sales Tax 15%" is 150.00 - Tax amount for "Retention Tax 10%" is -100.00 => The "VAT Amount" field of the invoice line is 50.00. It should be 150.00 instead. Solution: Compute the "VAT Amount" field as it is done in the EDI invoice. opw-3568831 closes odoo/odoo#146394 X-original-commit: b50d20e9fc631d7aa2e64cf6749be1630354fd69 Signed-off-by: Josse Colpaert <jco@odoo.com> Signed-off-by: Anh Thao Pham (pta) <pta@odoo.com>
This commit is contained in:
@@ -202,3 +202,22 @@ class AccountMove(models.Model):
|
||||
"""
|
||||
zatca_doc_ids = self.edi_document_ids.filtered(lambda d: d.edi_format_id.code == 'sa_zatca')
|
||||
return len(zatca_doc_ids) > 0 and not any(zatca_doc_ids.filtered(lambda d: d.state == 'to_send'))
|
||||
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = 'account.move.line'
|
||||
|
||||
@api.depends('price_subtotal', 'price_total')
|
||||
def _compute_tax_amount(self):
|
||||
super()._compute_tax_amount()
|
||||
taxes_vals_by_move = {}
|
||||
for record in self:
|
||||
move = record.move_id
|
||||
if move.country_code == 'SA':
|
||||
taxes_vals = taxes_vals_by_move.get(move.id)
|
||||
if not taxes_vals:
|
||||
taxes_vals = move._prepare_invoice_aggregated_taxes(
|
||||
filter_tax_values_to_apply=lambda l, t: not self.env['account.tax'].browse(t['id']).l10n_sa_is_retention
|
||||
)
|
||||
taxes_vals_by_move[move.id] = taxes_vals
|
||||
record.l10n_gcc_invoice_tax_amount = abs(taxes_vals.get('tax_details_per_record', {}).get(record, {}).get('tax_amount_currency', 0))
|
||||
|
||||
Reference in New Issue
Block a user