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_facturae: Retención de garantía #4053

Merged
merged 1 commit into from
Feb 28, 2025
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
41 changes: 41 additions & 0 deletions l10n_es_facturae/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ msgstr "Movimiento contable Facturae firmado"
msgid "Account Move Reversal"
msgstr "Revocación de movimiento en cuenta"

#. module: l10n_es_facturae
#: model_terms:ir.ui.view,arch_db:l10n_es_facturae.view_move_form
msgid "Amount"
msgstr "Importe"

#. module: l10n_es_facturae
#: model:ir.model.fields,field_description:l10n_es_facturae.field_res_partner__attach_invoice_as_annex
#: model:ir.model.fields,field_description:l10n_es_facturae.field_res_users__attach_invoice_as_annex
Expand Down Expand Up @@ -757,6 +762,11 @@ msgstr "Modos de pago"
msgid "Payment mode is required"
msgstr "El módo de pago es obligatorio"

#. module: l10n_es_facturae
#: model_terms:ir.ui.view,arch_db:l10n_es_facturae.view_move_form
msgid "Percent"
msgstr "Porcentaje"

#. module: l10n_es_facturae
#: model:ir.model.fields.selection,name:l10n_es_facturae.selection__account_move__facturae_refund_reason__11
#: model:ir.model.fields.selection,name:l10n_es_facturae.selection__account_move_reversal__refund_reason__11
Expand All @@ -783,6 +793,11 @@ msgstr "REIVA: Régimen especial de IVA para agencias de viajes"
msgid "Ra: Renta aduanas"
msgstr "Ra: Renta aduanas"

#. module: l10n_es_facturae
#: model_terms:ir.ui.view,arch_db:l10n_es_facturae.view_move_form
msgid "Reason"
msgstr "Razón"

#. module: l10n_es_facturae
#: model:ir.model.fields.selection,name:l10n_es_facturae.selection__account_move__correction_method__03
#: model:ir.model.fields.selection,name:l10n_es_facturae.selection__account_move_reversal__correction_method__03
Expand Down Expand Up @@ -922,6 +937,32 @@ msgstr "Unidad Tramitadora"
msgid "Vat must be defined for factura-e enabled partners."
msgstr "El iva debe definirse para los socios habilitados para factura-e."

#. module: l10n_es_facturae
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_bank_statement_line__facturae_withheld_amount
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_move__facturae_withheld_amount
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_payment__facturae_withheld_amount
msgid "Withheld Amount"
msgstr "Retención (importe)"

#. module: l10n_es_facturae
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_bank_statement_line__facturae_withheld_percent
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_move__facturae_withheld_percent
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_payment__facturae_withheld_percent
msgid "Withheld Percent"
msgstr "Retención (porcentaje)"

#. module: l10n_es_facturae
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_bank_statement_line__facturae_withheld_reason
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_move__facturae_withheld_reason
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_payment__facturae_withheld_reason
msgid "Withheld Reason"
msgstr "Retención (razón)"

#. module: l10n_es_facturae
#: model_terms:ir.ui.view,arch_db:l10n_es_facturae.view_move_form
msgid "Withhelds"
msgstr "Retención"

#. module: l10n_es_facturae
#. odoo-python
#: code:addons/l10n_es_facturae/models/account_move.py:0
Expand Down
41 changes: 41 additions & 0 deletions l10n_es_facturae/i18n/l10n_es_facturae.pot
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ msgstr ""
msgid "Account Move Reversal"
msgstr ""

#. module: l10n_es_facturae
#: model_terms:ir.ui.view,arch_db:l10n_es_facturae.view_move_form
msgid "Amount"
msgstr ""

#. module: l10n_es_facturae
#: model:ir.model.fields,field_description:l10n_es_facturae.field_res_partner__attach_invoice_as_annex
#: model:ir.model.fields,field_description:l10n_es_facturae.field_res_users__attach_invoice_as_annex
Expand Down Expand Up @@ -732,6 +737,11 @@ msgstr ""
msgid "Payment mode is required"
msgstr ""

#. module: l10n_es_facturae
#: model_terms:ir.ui.view,arch_db:l10n_es_facturae.view_move_form
msgid "Percent"
msgstr ""

#. module: l10n_es_facturae
#: model:ir.model.fields.selection,name:l10n_es_facturae.selection__account_move__facturae_refund_reason__11
#: model:ir.model.fields.selection,name:l10n_es_facturae.selection__account_move_reversal__refund_reason__11
Expand All @@ -758,6 +768,11 @@ msgstr ""
msgid "Ra: Renta aduanas"
msgstr ""

#. module: l10n_es_facturae
#: model_terms:ir.ui.view,arch_db:l10n_es_facturae.view_move_form
msgid "Reason"
msgstr ""

#. module: l10n_es_facturae
#: model:ir.model.fields.selection,name:l10n_es_facturae.selection__account_move__correction_method__03
#: model:ir.model.fields.selection,name:l10n_es_facturae.selection__account_move_reversal__correction_method__03
Expand Down Expand Up @@ -894,6 +909,32 @@ msgstr ""
msgid "Vat must be defined for factura-e enabled partners."
msgstr ""

#. module: l10n_es_facturae
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_bank_statement_line__facturae_withheld_amount
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_move__facturae_withheld_amount
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_payment__facturae_withheld_amount
msgid "Withheld Amount"
msgstr ""

#. module: l10n_es_facturae
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_bank_statement_line__facturae_withheld_percent
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_move__facturae_withheld_percent
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_payment__facturae_withheld_percent
msgid "Withheld Percent"
msgstr ""

#. module: l10n_es_facturae
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_bank_statement_line__facturae_withheld_reason
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_move__facturae_withheld_reason
#: model:ir.model.fields,field_description:l10n_es_facturae.field_account_payment__facturae_withheld_reason
msgid "Withheld Reason"
msgstr ""

#. module: l10n_es_facturae
#: model_terms:ir.ui.view,arch_db:l10n_es_facturae.view_move_form
msgid "Withhelds"
msgstr ""

#. module: l10n_es_facturae
#. odoo-python
#: code:addons/l10n_es_facturae/models/account_move.py:0
Expand Down
15 changes: 15 additions & 0 deletions l10n_es_facturae/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ class AccountMove(models.Model):
facturae_file_reference = fields.Char()
facturae_receiver_transaction_reference = fields.Char()
facturae_receiver_contract_reference = fields.Char()
facturae_withheld_reason = fields.Char(string="Withheld Reason")
facturae_withheld_percent = fields.Float(string="Withheld Percent")
facturae_withheld_amount = fields.Monetary(
compute="_compute_facturae_withheld_amount",
store=True,
string="Withheld Amount",
readonly=False,
)

@api.constrains("facturae_start_date", "facturae_end_date")
def _check_facturae_date(self):
Expand Down Expand Up @@ -105,6 +113,13 @@ def _compute_facturae(self):
]
)

@api.depends("amount_untaxed", "facturae_withheld_percent")
def _compute_facturae_withheld_amount(self):
for item in self.filtered("facturae"):
item.facturae_withheld_amount = (
item.amount_untaxed * item.facturae_withheld_percent
)

def get_exchange_rate(self, euro_rate, currency_rate):
if not euro_rate and not currency_rate:
return fields.Datetime.now().strftime("%Y-%m-%d")
Expand Down
26 changes: 26 additions & 0 deletions l10n_es_facturae/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ def _check_amounts(self, move, wo_discount, subtotal, base, tax, discount=0):
def _check_totals(self, move, subtotal, base, tax, total):
move.action_post()
move.name = "2999/99999"
move.facturae_withheld_reason = "WithholdingReason"
move.facturae_withheld_percent = 0.05
generated_facturae = self._create_facturae_file(move)
self.assertEqual(
generated_facturae.xpath("//InvoiceTotals/TotalGrossAmount")[0].text,
Expand All @@ -613,6 +615,30 @@ def _check_totals(self, move, subtotal, base, tax, total):
generated_facturae.xpath("//InvoiceTotals//InvoiceTotal")[0].text,
total,
)
self.assertEqual(
generated_facturae.xpath(
"//InvoiceTotals//AmountsWithheld//WithholdingReason"
)[0].text,
"WithholdingReason",
)
version = move.get_facturae_version()
self.assertEqual(
generated_facturae.xpath(
"//InvoiceTotals//AmountsWithheld//WithholdingRate"
)[0].text,
("%.4f" if version == "3_2" else "%.8f") % 5,
)
self.assertEqual(
generated_facturae.xpath(
"//InvoiceTotals//AmountsWithheld//WithholdingAmount"
)[0].text,
("%.2f" if version == "3_2" else "%.8f") % 5,
)
sign = -1 if move.move_type == "out_refund" else 1
self.assertEqual(
generated_facturae.xpath("//InvoiceTotals//TotalExecutableAmount")[0].text,
("%.2f" if version == "3_2" else "%.8f") % (float(total) - (sign * 5)),
)

def test_move_rounding(self):
self._activate_certificate(self.certificate_password)
Expand Down
10 changes: 10 additions & 0 deletions l10n_es_facturae/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
</form>
</field>
</group>
<group string="Withhelds">
<field name="facturae_withheld_reason" string="Reason" />
<field
name="facturae_withheld_percent"
widget="percentage"
class="oe_inline"
string="Percent"
/>
<field name="facturae_withheld_amount" string="Amount" />
</group>
</group>
</page>
</notebook>
Expand Down
14 changes: 12 additions & 2 deletions l10n_es_facturae/views/report_facturae.xml
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,19 @@
t-out="('%.2f' if version == '3_2' else '%.8f') % (sign * move.amount_total)"
/>
<TotalPaymentsOnAccount t-if="False" />
<AmountsWithheld t-if="False" />
<AmountsWithheld t-if="move.facturae_withheld_percent > 0.0">
<WithholdingReason
t-out="move.facturae_withheld_reason or ''"
/>
<WithholdingRate
t-out="('%.4f' if version == '3_2' else '%.8f') % (move.facturae_withheld_percent * 100)"
/>
<WithholdingAmount
t-out="('%.2f' if version == '3_2' else '%.8f') % (move.facturae_withheld_amount)"
/>
</AmountsWithheld>
<TotalExecutableAmount
t-out="('%.2f' if version == '3_2' else '%.8f') % (sign * move.amount_total)"
t-out="('%.2f' if version == '3_2' else '%.8f') % (sign * move.amount_total - (sign * move.facturae_withheld_amount))"
/>
<TotalReimbursableExpenses t-if="False" />
<t t-if="version not in ('3_2', '3_2_1')">
Expand Down