diff --git a/models/ws_caea_code.py b/models/ws_caea_code.py index 0536312702f43aa4983105efe5ff39df6ddce9a7..3c1013147aa1b25f9a9421c43d68a7e4f5cd38e5 100644 --- a/models/ws_caea_code.py +++ b/models/ws_caea_code.py @@ -439,10 +439,10 @@ class WsCaeaCode(models.Model): for desc in i.no_return_agreement_ids ]) agreement_desc = desc_type_2_3 + desc_type_4_5 - desc = i.discount + desc = 0.00 precio_u_x_cant = precio_u * cant - importe_iva = (precio_u_x_cant * (1 - desc / 100) * (1 - agreement_desc / 100)) * alicuota - importe_desc = precio_u_x_cant - precio_u_x_cant * (1 - desc / 100) * (1 - agreement_desc / 100) + importe_iva = (precio_u_x_cant * 1 - i.discount / 100) * alicuota + importe_desc = precio_u_x_cant * (i.discount / 100) # Codigo de error 1120 list_tcu = [1, 2, 3, 51, 52, 53] @@ -540,8 +540,8 @@ class WsCaeaCode(models.Model): # barcode = i.product_id.barcode barcode = '7790001001054' canti_dad = i.quantity - p_unitario = i.price_unit - i_bonific = round(importe_desc, 2) + p_unitario = round(i.discount_price_unit, 2) + i_bonific = 0.00 else: barcode = '' canti_dad = '' @@ -562,6 +562,38 @@ class WsCaeaCode(models.Model): 'importeItem': valor_item, }, }) + + env_tax_caea = self.env['ws.tax.caea'] + tax = invoice.tax_line_ids.filtered(lambda x: x.tax_id.tax_group == 'vat') + code = env_tax_caea.get_cod(tax.tax_id) + commercial_bonus_amount = invoice.commercial_bonus_amount + tax_percentage = tax.percentage + agreement_descts_amount = invoice.no_return_agreement_picking + invoice.no_return_agreement_returns + invoice.trade_agreement_bonus + invoice.trade_agreement_discount + + if commercial_bonus_amount > 0: + commercial_bonus_discounts = { + 'item': { + 'descripcion': 'Bonificacion comercial', + 'codigoUnidadMedida': 99, + 'codigoCondicionIVA': code, + 'importeIVA': round(commercial_bonus_amount * (tax_percentage / 100), 2), + 'importeItem': round(commercial_bonus_amount * (1 + tax_percentage / 100), 2), + } + } + list_items.append(commercial_bonus_discounts) + + if agreement_descts_amount > 0: + agreement_descts = { + 'item': { + 'descripcion': 'Descuento negociacion', + 'codigoUnidadMedida': 99, + 'codigoCondicionIVA': code, + 'importeIVA': round(agreement_descts_amount * (tax_percentage / 100), 2), + 'importeItem': round(agreement_descts_amount * (1 + tax_percentage / 100), 2), + } + } + list_items.append(agreement_descts) + if list_items: lista_de_items = { 'arrayItems': {