# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)

from odoo.http import request
from odoo.addons.sale.controllers.product_configurator import (
    SaleProductConfiguratorController,
)

_original_get_ptav_price_extra = (
    SaleProductConfiguratorController._get_ptav_price_extra
)


def _fi_get_ptav_price_extra(self, ptav, currency, date, product_or_template):
    extra = _original_get_ptav_price_extra(
        self, ptav, currency, date, product_or_template)
    impact = ptav.x_fi_extra_price_impact or 0.0
    if impact:
        extra += ptav.currency_id._convert(
            impact, currency, request.env.company, date.date())
    return extra


SaleProductConfiguratorController._get_ptav_price_extra = (
    _fi_get_ptav_price_extra
)
