Skip to content
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
2 changes: 1 addition & 1 deletion l10n_ve_accountant/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "binaural-dev",
"website": "https://binauraldev.com/",
"category": "Accounting/Localizations/Account Chart",
"version": "1.0",
"version": "1.5",
"depends": [
"base",
"web",
Expand Down
43 changes: 40 additions & 3 deletions l10n_ve_accountant/models/account_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def _get_tax_totals_summary(
res = super()._get_tax_totals_summary(
base_lines, currency, company, cash_rounding
)
#only ves
ves_currency = self.env.ref('base.VEF')
# Obtener el registro de factura desde el contexto si está disponible
active_model = self.env.context.get('active_model')
active_id = self.env.context.get('active_id')
if not active_model or not active_id:
return res
record = self.env[active_model].browse(active_id)


# FIXME: Evaluar escenarios en los que hay descuentos.
res_without_discount = res.copy()
foreign_lines = []
Expand Down Expand Up @@ -60,11 +60,12 @@ def _get_tax_totals_summary(
company,
cash_rounding
)
#amounts in foreign currency
res['foreign_currency_id'] = foreign_res['currency_id']
res['ves_currency_id'] = self.env.ref('base.VEF').id
res['base_amount_foreign_currency'] = foreign_res['base_amount_currency']
res['tax_amount_foreign_currency'] = foreign_res['tax_amount_currency']
res['total_amount_foreign_currency'] = foreign_res['total_amount_currency']

# Moneda Base
res['formatted_base_amount_currency'] = formatLang(
env=self.env,
Expand All @@ -81,6 +82,24 @@ def _get_tax_totals_summary(
value=res.get('total_amount_currency', 0.0),
currency_obj=currency_id
)

#only VES amounts
res['formatted_base_amount_currency_ves'] = formatLang(
env=self.env,
value=res.get('base_amount', 0.0),
currency_obj=ves_currency
)
res['formatted_tax_amount_currency_ves'] = formatLang(
env=self.env,
value=res.get('tax_amount', 0.0),
currency_obj=ves_currency
)
res['formatted_total_amount_currency_ves'] = formatLang(
env=self.env,
value=res.get('total_amount', 0.0),
currency_obj=ves_currency
)

# Foraneos
res['formatted_base_amount_foreign_currency'] = formatLang(
env=self.env,
Expand Down Expand Up @@ -157,6 +176,23 @@ def _get_tax_totals_summary(
value=res_tax_group.get('display_base_amount_currency', 0.0),
currency_obj=currency_id
)
#ONLY VES
res_tax_group['formatted_base_amount_currency_ves'] = formatLang(
env=self.env,
value=res_tax_group.get('base_amount', 0.0),
currency_obj=ves_currency
)

res_tax_group['formatted_tax_amount_currency_ves'] = formatLang(
env=self.env,
value=res_tax_group.get('tax_amount', 0.0),
currency_obj=ves_currency
)
res_tax_group['formatted_total_amount_currency_ves'] = formatLang(
env=self.env,
value=res_tax_group.get('total_amount', 0.0),
currency_obj=ves_currency
)
# Foranea
res_tax_group['formatted_base_amount_foreign_currency'] = formatLang(
env=self.env,
Expand All @@ -173,6 +209,7 @@ def _get_tax_totals_summary(
value=res_tax_group.get('display_base_amount_foreign_currency', 0.0),
currency_obj=foreign_currency_id
)
_logger.warning("TOTALES FINALES CON MONEDAS: %s", res)
return res

@api.model
Expand Down
29 changes: 26 additions & 3 deletions l10n_ve_accountant/static/src/components/tax_totals/tax_totals.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** @odoo-module **/

import { formatFloat, formatMonetary } from "@web/views/fields/formatters";
import { parseFloat } from "@web/views/fields/parsers";
import { formatMonetary } from "@web/views/fields/formatters";
import { standardFieldProps } from "@web/views/fields/standard_field_props";
import { registry } from "@web/core/registry";

Expand All @@ -10,23 +9,33 @@ import { patch } from "@web/core/utils/patch";
const { Component, onPatched, onWillUpdateProps, useRef, toRaw, useState } = owl;

patch(TaxTotalsComponent.prototype, {


formatData(props) {
let totals = JSON.parse(JSON.stringify(toRaw(props.record.data[this.props.name])));
if (!totals) {
return;
}
const foreignCurrencyFmtOpts = { currencyId: props.record.data.foreign_currency_id && props.record.data.foreign_currency_id[0] };
totals.formatted_total_amount_currency_ves = totals.formatted_total_amount_currency_ves
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line assigns a property to itself, which has no effect. Either remove this line or implement the intended formatting logic.

Suggested change
totals.formatted_total_amount_currency_ves = totals.formatted_total_amount_currency_ves
totals.formatted_total_amount_currency_ves = formatMonetary(totals.total_amount_currency_ves, currencyFmtOpts);

Copilot uses AI. Check for mistakes.
const foreignCurrencyFmtOpts = { currencyId: props.record.data.foreign_currency_id };
const currencyFmtOpts = { currencyId: props.record.data.currency_id && props.record.data.currency_id[0] };
if (totals.subtotals && Array.isArray(totals.subtotals)) {
for (let subtotal of totals.subtotals) {
subtotal.formatted_base_amount_foreign_currency = formatMonetary(subtotal.base_amount_foreign_currency, foreignCurrencyFmtOpts);
subtotal.formatted_base_amount_currency = formatMonetary(subtotal.base_amount_currency, currencyFmtOpts);
// Solo VEES
subtotal.formatted_base_amount_currency_ves = totals.formatted_base_amount_currency_ves

if (subtotal.tax_groups && Array.isArray(subtotal.tax_groups)) {
for (let taxGroup of subtotal.tax_groups) {
taxGroup.formatted_tax_amount_foreign_currency = formatMonetary(taxGroup.tax_amount_foreign_currency, foreignCurrencyFmtOpts);
taxGroup.formatted_base_amount_foreign_currency = formatMonetary(taxGroup.base_amount_foreign_currency, foreignCurrencyFmtOpts);

taxGroup.formatted_tax_amount_currency = formatMonetary(taxGroup.tax_amount_currency, currencyFmtOpts);

taxGroup.formatted_base_amount_currency = formatMonetary(taxGroup.base_amount_currency, currencyFmtOpts);
// Solo VEES
taxGroup.formatted_tax_amount_currency_ves = taxGroup.formatted_tax_amount_currency_ves;
}
}
}
Expand All @@ -35,11 +44,21 @@ patch(TaxTotalsComponent.prototype, {
totals.formatted_total_amount_currency = formatMonetary(totals.total_amount_currency, currencyFmtOpts);
this.totals = totals;
return totals;
},

formatMonetaryForeign(value) {
const currency = this.props.record.data.foreign_currency_id;
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If foreign_currency_id is null or undefined, accessing currency.id will cause a runtime error. Add a null check before accessing the id property.

Suggested change
const currency = this.props.record.data.foreign_currency_id;
const currency = this.props.record.data.foreign_currency_id;
if (!currency || !currency.id) {
// Si no hay moneda extranjera, retornar el valor original o una cadena vacía
return "";
}

Copilot uses AI. Check for mistakes.
let res = formatMonetary(value, {currencyId: currency.id});
return res;
}


});

export class TaxTotalsComponents extends TaxTotalsComponent {
}
TaxTotalsComponents.template = "l10n_ve_tax.TaxForeignTotalsField";
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template property is assigned twice consecutively. The first assignment on line 56 is immediately overwritten by line 57, making it ineffective. Remove line 56 if only the VES template should be used, or clarify the intended logic.

Suggested change
TaxTotalsComponents.template = "l10n_ve_tax.TaxForeignTotalsField";

Copilot uses AI. Check for mistakes.
TaxTotalsComponents.template = "l10n_ve_tax.TaxVesTotalsField";
TaxTotalsComponents.props = {
...standardFieldProps,
};
Expand All @@ -53,3 +72,7 @@ const fieldsRegistry = registry.category("fields");
if (!fieldsRegistry.contains("account-tax-foreign-totals-field")) {
fieldsRegistry.add("account-tax-foreign-totals-field", taxTotalsComponent);
}

if (!fieldsRegistry.contains("account-tax-ves-totals-field")) {
fieldsRegistry.add("account-tax-ves-totals-field", taxTotalsComponent);
}
70 changes: 61 additions & 9 deletions l10n_ve_accountant/static/src/components/tax_totals/tax_totals.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<templates xml:space="preserve">

<!-- Tax Group Component normal -->
<t
t-name="l10n_ve_accountant.TaxGroupComponent"
t-inherit="account.TaxGroupComponent"
Expand All @@ -19,13 +19,13 @@

<td class="o_tax_group">
<span class="o_tax_group_amount_value o_list_monetary">
<t t-out="props.taxGroup.formatted_base_amount_currency" style="white-space: nowrap;"/>
<t t-out="formatMonetary(props.taxGroup.base_amount_currency)" style="white-space: nowrap;"/>
</span>
</td>
</tr>
</xpath>
</t>

<!-- Discounts -->
<t t-name="l10n_ve_tax.TaxTotalsField" t-inherit="account.TaxTotalsField" t-inherit-mode="extension" owl="1">
<xpath expr="//table[1]/tbody[1]/t[1]" position="before">
<tr t-if="totals.discount_amount and totals.show_discount">
Expand Down Expand Up @@ -54,18 +54,21 @@
</tr>
</xpath>
</t>

<!-- Foreign Currency Totals-->
<t t-name="l10n_ve_tax.TaxForeignTotalsField" owl="1">
<table t-if="totals" class="oe_right">
<table class="oe_right">
<tbody>
<h1>
<span t-out="totals.currency_id.symbol"/>
</h1>
Comment on lines +61 to +63
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The <h1> element is incorrectly placed inside a <tbody> element. Table body elements should only contain <tr> elements. Consider moving this to a table header (<thead>) or using a different approach to display the currency symbol.

Suggested change
<h1>
<span t-out="totals.currency_id.symbol"/>
</h1>
<tr>
<td colspan="2" style="text-align: center;">
<span style="font-size: 2em; font-weight: bold;" t-out="totals.currency_id.symbol"/>
</td>
</tr>

Copilot uses AI. Check for mistakes.
<t t-foreach="totals.subtotals" t-as="subtotal" t-key="subtotal.name">
<tr>
<td class="o_td_label">
<label class="o_form_label o_tax_total_label" t-esc="subtotal.name"/>
</td>
<td class="o_list_monetary">
<span style="white-space: nowrap; font-weight: bold;"
t-out="subtotal.formatted_base_amount_foreign_currency"/>
t-out="formatMonetaryForeign(subtotal.base_amount_foreign_currency)"/>
</td>
</tr>
<t t-foreach="subtotal.tax_groups" t-as="taxGroup" t-key="taxGroup.id">
Expand All @@ -75,7 +78,7 @@
</td>
<td>
<span class="o_tax_group_amount_value o_list_monetary"
t-out="taxGroup.formatted_base_amount_foreign_currency"
t-out="formatMonetaryForeign(taxGroup.base_amount_foreign_currency)"
style="white-space: nowrap;"/>
</td>
</tr>
Expand All @@ -85,7 +88,7 @@
</td>
<td class="o_list_monetary">
<span style="white-space: nowrap;"
t-out="taxGroup.formatted_tax_amount_foreign_currency"/>
t-out="formatMonetaryForeign(taxGroup.tax_amount_foreign_currency)"/>
</td>
</tr>
</t>
Expand All @@ -96,10 +99,59 @@
</td>
<td class="o_list_monetary">
<span style="font-size: 1.3em; font-weight: bold; white-space: nowrap;"
t-out="totals.formatted_total_amount_foreign_currency"/>
t-out="formatMonetaryForeign(totals.total_amount_foreign_currency)"/>
</td>
</tr>
</tbody>
</table>
</t>
<!-- VES ONLY FIELDS -->
<t t-name="l10n_ve_tax.TaxVesTotalsField" owl="1">
<table class="oe_right">
<tbody>
<t t-foreach="totals.subtotals" t-as="subtotal" t-key="subtotal.name">
<tr>
<td class="o_td_label">
<label class="o_form_label o_tax_total_label" t-esc="subtotal.name"/>
</td>
<td class="o_list_monetary">
<span style="white-space: nowrap; font-weight: bold;"
t-out="subtotal.formatted_base_amount_currency_ves"/>
</td>
</tr>
<t t-foreach="subtotal.tax_groups" t-as="taxGroup" t-key="taxGroup.id">
<tr>
<td class="o_td_label">
<label class="o_form_label o_tax_total_label" t-esc="'Total G ' + taxGroup.group_name"/>
</td>
<td>
<span class="o_tax_group_amount_value o_list_monetary"
t-out="taxGroup.formatted_base_amount_currency_ves"
style="white-space: nowrap;"/>
</td>
</tr>
<tr>
<td class="o_td_label">
<label class="o_form_label o_tax_total_label" t-esc="taxGroup.group_name"/>
</td>
<td class="o_list_monetary">
<span style="white-space: nowrap;"
t-out="taxGroup.formatted_tax_amount_currency_ves"/>
</td>
</tr>
</t>
</t>
<tr>
<td class="o_td_label">
<label class="o_form_label o_tax_total_label">Total</label>
</td>
<td class="o_list_monetary">
<span style="font-size: 1.3em; font-weight: bold; white-space: nowrap;"
t-out="totals.formatted_total_amount_currency_ves"/>
</td>
</tr>
</tbody>
</table>
</t>

</templates>
17 changes: 17 additions & 0 deletions l10n_ve_accountant/views/account_move.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,27 @@
</group>
</page>
</xpath>
<!-- ONLY VES SQUARE -->
<xpath expr="//page[@name='invoice_tab']"
position="inside">
<group colspan="2" class="oe_subtotal_footer oe_right">
<group class="oe_subtotal_footer oe_right"
invisible="move_type not in ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt') or payment_state == 'invoicing_legacy'">
<field name="tax_totals"
widget="account-tax-ves-totals-field"
nolabel="1"
readonly="state != 'draft' or (move_type not in ('in_invoice', 'in_refund') and not quick_edit_mode)" />
</group>
</group>
</xpath>

<xpath expr="//page/field[@name='invoice_line_ids']/list/field[@name='price_unit']"
position="after">
<field name="foreign_price" readonly="move_type != 'in_invoice'" />
</xpath>
<xpath expr="//page/field[@name='invoice_line_ids']/list/field[@name='price_subtotal']"
position="after">

<field name="foreign_currency_id" column_invisible="True" />
<field name="foreign_subtotal"
/>
Expand All @@ -88,11 +103,13 @@
readonly="1"
/>
</xpath>

<xpath
expr="//notebook/page/field[@name='invoice_line_ids']/list/field[@name='tax_ids']"
position="attributes">
<attribute name="readonly">1</attribute>
</xpath>

<xpath expr="//page/field[@name='journal_line_ids']/list/field[@name='balance']"
position="after">
<field name="foreign_currency_id" column_invisible="True" />
Expand Down
2 changes: 1 addition & 1 deletion l10n_ve_payment_extension/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "binaural-dev",
"website": "https://binauraldev.com/",
"category": "Accountant/Accountant",
"version": "1.0",
"version": "1.1",
"depends": [
"base",
"account",
Expand Down
20 changes: 6 additions & 14 deletions l10n_ve_payment_extension/views/account_retention_iva.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,13 @@
<field name="arch" type="xml">
<search string="IVA Retention">
<field name="number" string="Number" filter_domain="[('number','ilike',self)]" />
<field name="partner_id" string="Business Name"
filter_domain="[('partner_id','ilike',self)]" />
<field name="partner_id" string="Business Name" filter_domain="[('partner_id','ilike',self)]" />
<field name="date" string="Vocher date" filter_domain="[('date','ilike',self)]" />
<field name="date_accounting" string="Fecha Contable"
filter_domain="[('date_accounting','ilike',self)]" />
<!-- <field name="retention_line" string="Factura"
filter_domain="[('retention_line.invoice_id.name','ilike',self)]"/> -->
<group expand="0" string="Group By">
<filter name="group_state" string="State" domain="[]"
context="{'group_by':'state'}" />
<filter name="group_partner" string="Business Name" domain="[]"
context="{'group_by':'partner_id'}" />
<filter name="group_date_accounting" string="Fecha Contable" domain="[]"
context="{'group_by':'date_accounting'}" />
</group>
<field name="date_accounting" string="Fecha Contable" filter_domain="[('date_accounting','ilike',self)]" />
<!-- <field name="retention_line" string="Factura" filter_domain="[('retention_line.invoice_id.name','ilike',self)]"/> -->
<filter name="group_state" string="Group by State" context="{'group_by':'state'}" />
<filter name="group_partner" string="Group by Business Name" context="{'group_by':'partner_id'}" />
<filter name="group_date_accounting" string="Group by Fecha Contable" context="{'group_by':'date_accounting'}" />
</search>
</field>
</record>
Expand Down
Loading