##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields, api
from odoo.exceptions import UserError

class AccountPaymentGroup(models.Model):

    _inherit = "account.payment.group"

    financing_surcharge = fields.Monetary(compute='_computed_financing_surcharge')

    @api.depends('payment_ids.net_amount')
    def _computed_financing_surcharge(self):
        for rec in self:
            rec.financing_surcharge = sum(
                rec.payment_ids.filtered('financing_plan_id').mapped(lambda x: x.amount - x.net_amount))

    def post(self):
        if self.payment_ids.mapped('financing_plan_id'):
            if not self.company_id.product_surcharge_id:
                raise UserError(
                    "To validate payment with finacing plan is necessary to have a product surcharge in the "
                    "company of the payment. Please check this in the Account Config")
            journal = self.env['account.journal'].search([
                ('type', '=', 'sale'),
                ('company_id', '=', self.company_id.id)], limit=1)
            wiz = self.env['account.payment.group.invoice.wizard'].with_context(active_id=self.id, internal_type='debit_note').create({
                'journal_id': journal.id,
                'product_id': self.company_id.product_surcharge_id.id,
                'amount_total': self.financing_surcharge,
                })
            wiz.change_payment_group()
            wiz.confirm()
        super().post()

@@ -837,14 +837,17 @@
     
-if not
+product =
  sel
@@ -879,16 +879,43 @@
 harge_id
+%0A            if not product
 :%0A      
@@ -1303,16 +1303,111 @@
 imit=1)%0A
+            taxes = product.taxes_id.filtered(lambda t: t.company_id.id == self.company_id.id)%0A
         
@@ -1478,16 +1478,33 @@
 context(
+%0A                
 active_i
@@ -1567,16 +1567,20 @@
         
+    
 'journal
@@ -1613,16 +1613,20 @@
         
+    
 'product
@@ -1635,105 +1635,285 @@
 d': 
-self.company_id.product_surcharge_id.id,%0A                'amount_total': self.financing_surcharge
+product.id,%0A                    'tax_ids': %5B(6, 0, taxes.ids)%5D,%0A                    'amount_total': taxes.with_context(%0A                        force_price_include=True).compute_all(%0A                        self.financing_surcharge, currency=self.currency_id)%5B'total_excluded'%5D
 ,%0A  

set the price with taxes in the Debit note.