From 1ac16a5c47b114c2c8eda3c71f29a42be52bfeb8 Mon Sep 17 00:00:00 2001
From: "jesus.lomas" <jesus.lomas@openpyme.mx>
Date: Tue, 10 Sep 2024 18:00:59 -0600
Subject: [PATCH 1/3] feat(se realizan cambios tipocambio): se realizaron
 cambios al tipo de cambio

Se modifico en campo tipocambio para obtener el valor de la moneda ya sea diferente de MXN
---
 l10n_mx_facturae/models/account_move.py     | 4 +++-
 l10n_mx_facturae/models/account_payment.py  | 2 +-
 l10n_mx_facturae/templates/account_move.xml | 5 +++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/l10n_mx_facturae/models/account_move.py b/l10n_mx_facturae/models/account_move.py
index e4265bd6c7..dd0dd7131f 100644
--- a/l10n_mx_facturae/models/account_move.py
+++ b/l10n_mx_facturae/models/account_move.py
@@ -67,14 +67,16 @@ class AccountMove(models.Model):
             "total_retenciones": 0.0,
             "total_locales": 0.0,
         }
-
         for line in self.invoice_line_ids:
             for tax in line.export_invoice_line_for_xml().taxes:
                 # Mimic logic from compute function in account.invoice.tax
                 # object to group taxes from invoice lines and be able to get
                 # the same result for display on CFDI
                 grouping_dict = self._get_tax_grouping_key_from_tax_line(line)
+                grouping_dict['tipo_impuesto'] = tax.group
+                grouping_dict['tipo_operacion'] = 'traslado'
                 grouping_key = "-".join(str(v) for v in grouping_dict.values())
+
                 if grouping_key not in tax_grouped:
                     tax_grouped[grouping_key] = tax
                 else:
diff --git a/l10n_mx_facturae/models/account_payment.py b/l10n_mx_facturae/models/account_payment.py
index e4406af49d..8341d419bd 100644
--- a/l10n_mx_facturae/models/account_payment.py
+++ b/l10n_mx_facturae/models/account_payment.py
@@ -301,7 +301,7 @@ class AccountPayment(models.Model):
                 precision_digits=6
             )
 
-        return value
+        return "{:.6f}".format(value)
 
     def impuestos_dr(self, invoice, tax_type="traslados"):
         """Computes move lines for on payment taxes related to given invoice"""
diff --git a/l10n_mx_facturae/templates/account_move.xml b/l10n_mx_facturae/templates/account_move.xml
index cc81104eb4..88b1a257cf 100644
--- a/l10n_mx_facturae/templates/account_move.xml
+++ b/l10n_mx_facturae/templates/account_move.xml
@@ -99,8 +99,9 @@
                         t-attf-Impuesto="{{ tax.xml_name }}"
                         t-attf-Importe="{{ tax.xml_amount }}" />
                 </cfdi:Retenciones>
-                <cfdi:Traslados t-if="taxes['traslados']">
-                    <cfdi:Traslado t-foreach="taxes['traslados']" t-as="tax"
+                    <cfdi:Traslados t-if="line.impuestos['traslados']">
+                        <t t-set="impuestos" t-value="line.impuestos"/>
+                        <cfdi:Traslado t-foreach="impuestos['traslados']" t-as="tax"
                         t-att-Base="format_float(tax.base, o.currency_id.decimal_places)"
                         t-attf-Impuesto="{{ tax.xml_name }}"
                         t-attf-TipoFactor="{{ tax.type }}"
-- 
GitLab


From d24cd76f6010ff5aa52513cd0ade7b6be581d036 Mon Sep 17 00:00:00 2001
From: "jesus.lomas" <jesus.lomas@openpyme.mx>
Date: Thu, 10 Oct 2024 16:18:53 -0600
Subject: [PATCH 2/3] =?UTF-8?q?feat(cambios=20a=20la=20funci=C3=B3n=20impu?=
 =?UTF-8?q?estos):=20se=20realizaron=20cambios=20a=20la=20funci=C3=B3n=20i?=
 =?UTF-8?q?mpuestos?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Se hicieron cambios a la función impuestos para que se visualizaran los impuestos de traslados que
son (IVA, IEPS, etc.) en el XML que se genera al timbrar la factura.
---
 l10n_mx_facturae/models/account_move.py    | 8 ++++----
 l10n_mx_facturae/models/account_payment.py | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/l10n_mx_facturae/models/account_move.py b/l10n_mx_facturae/models/account_move.py
index dd0dd7131f..4faaff9983 100644
--- a/l10n_mx_facturae/models/account_move.py
+++ b/l10n_mx_facturae/models/account_move.py
@@ -67,16 +67,16 @@ class AccountMove(models.Model):
             "total_retenciones": 0.0,
             "total_locales": 0.0,
         }
+
+        tax_repartion_lines = self.line_ids.filtered('tax_repartition_line_id')
         for line in self.invoice_line_ids:
             for tax in line.export_invoice_line_for_xml().taxes:
                 # Mimic logic from compute function in account.invoice.tax
                 # object to group taxes from invoice lines and be able to get
                 # the same result for display on CFDI
-                grouping_dict = self._get_tax_grouping_key_from_tax_line(line)
-                grouping_dict['tipo_impuesto'] = tax.group
-                grouping_dict['tipo_operacion'] = 'traslado'
+                tax_line = tax_repartion_lines.filtered(lambda l: l.tax_line_id.id == tax.id)
+                grouping_dict = self._get_tax_grouping_key_from_tax_line(tax_line)
                 grouping_key = "-".join(str(v) for v in grouping_dict.values())
-
                 if grouping_key not in tax_grouped:
                     tax_grouped[grouping_key] = tax
                 else:
diff --git a/l10n_mx_facturae/models/account_payment.py b/l10n_mx_facturae/models/account_payment.py
index 8341d419bd..e4406af49d 100644
--- a/l10n_mx_facturae/models/account_payment.py
+++ b/l10n_mx_facturae/models/account_payment.py
@@ -301,7 +301,7 @@ class AccountPayment(models.Model):
                 precision_digits=6
             )
 
-        return "{:.6f}".format(value)
+        return value
 
     def impuestos_dr(self, invoice, tax_type="traslados"):
         """Computes move lines for on payment taxes related to given invoice"""
-- 
GitLab


From 1ecc60df203674c88f3468aadfeaaf6e7d21951f Mon Sep 17 00:00:00 2001
From: "jesus.lomas" <jesus.lomas@openpyme.mx>
Date: Fri, 6 Dec 2024 14:06:14 -0600
Subject: [PATCH 3/3] feat(account.move): timbra correctamente la factura
 cuando hay varios impuestos

---
 l10n_mx_facturae/templates/account_move.xml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/l10n_mx_facturae/templates/account_move.xml b/l10n_mx_facturae/templates/account_move.xml
index 88b1a257cf..a0322166ac 100644
--- a/l10n_mx_facturae/templates/account_move.xml
+++ b/l10n_mx_facturae/templates/account_move.xml
@@ -99,9 +99,9 @@
                         t-attf-Impuesto="{{ tax.xml_name }}"
                         t-attf-Importe="{{ tax.xml_amount }}" />
                 </cfdi:Retenciones>
-                    <cfdi:Traslados t-if="line.impuestos['traslados']">
-                        <t t-set="impuestos" t-value="line.impuestos"/>
-                        <cfdi:Traslado t-foreach="impuestos['traslados']" t-as="tax"
+                <cfdi:Traslados t-if="line.impuestos['traslados']">
+                    <t t-set="impuestos" t-value="line.impuestos"/>
+                    <cfdi:Traslado t-foreach="impuestos['traslados']" t-as="tax"
                         t-att-Base="format_float(tax.base, o.currency_id.decimal_places)"
                         t-attf-Impuesto="{{ tax.xml_name }}"
                         t-attf-TipoFactor="{{ tax.type }}"
-- 
GitLab