Proporcional taxes in pays complements

This commit is contained in:
el Mau 2023-01-04 18:29:30 -06:00
parent 0c8d6d3cea
commit d57ded161c
1 changed files with 17 additions and 10 deletions

View File

@ -7467,7 +7467,6 @@ class CfdiPagos(BaseModel):
return data
def _get_taxes_by_pay(self, pay, taxes_pay):
# ~ print(pay['ImpPagado']
invoice = Facturas.get(Facturas.uuid==pay['IdDocumento'])
impuestos = {}
traslados = []
@ -7476,6 +7475,11 @@ class CfdiPagos(BaseModel):
where = (FacturasImpuestos.factura==invoice)
taxes = FacturasImpuestos.select().where(where)
tax_proporcion = pay['ImpPagado'] / invoice.total
# ~ print('Total', invoice.total)
# ~ print('Pagado', pay['ImpPagado'])
# ~ print('proporcion', tax_proporcion)
for tax in taxes:
if tax.impuesto.key == '000':
# ~ tasa = str(round(tax.impuesto.tasa * 100, 2))
@ -7502,12 +7506,12 @@ class CfdiPagos(BaseModel):
if tax.impuesto.factor != 'T':
tipo_factor = 'Cuota'
# ~ if tax_decimals:
# ~ xml_importe = FORMAT_TAX.format(tax.importe)
# ~ xml_tax_base = FORMAT_TAX.format(tax.base)
# ~ else:
xml_importe = FORMAT.format(tax.importe)
xml_tax_base = FORMAT.format(tax.base)
import_dr = round(tax.importe * tax_proporcion, 2)
# ~ xml_importe = FORMAT.format(tax.importe)
xml_importe = FORMAT.format(import_dr)
base_dr = round(tax.base * tax_proporcion, 2)
# ~ xml_tax_base = FORMAT.format(tax.base)
xml_tax_base = FORMAT.format(base_dr)
values = {
"BaseDR": xml_tax_base,
@ -7520,14 +7524,17 @@ class CfdiPagos(BaseModel):
if tax.impuesto.tipo == 'T':
traslados.append(values)
if tax_key in taxes_pay['traslados']:
taxes_pay['traslados'][tax_key]['ImporteP'] += tax.importe
# ~ taxes_pay['traslados'][tax_key]['ImporteP'] += tax.importe
taxes_pay['traslados'][tax_key]['ImporteP'] += import_dr
else:
values = {
"BaseP": tax.base,
# ~ "BaseP": tax.base,
"BaseP": base_dr,
"ImpuestoP": tax.impuesto.key,
"TipoFactorP": tipo_factor,
"TasaOCuotaP": str(tax.impuesto.tasa),
"ImporteP": tax.importe,
# ~ "ImporteP": tax.importe,
"ImporteP": import_dr,
}
taxes_pay['traslados'][tax_key] = values
else: