fix: ADP portal payment uses client portion instead of full order total
When customers pay for ADP quotations through the portal, the system was charging the full order amount (ADP + client portions combined). Now correctly charges only the client portion (25% for REG clients). Changes: - Override _get_prepayment_required_amount() to return client portion - Override _has_to_be_paid() to skip payment for 100% ADP-funded orders - Add portal controller to cap payment amount at client portion - Add portal template showing ADP funding breakdown to customer
This commit is contained in:
2
fusion_claims/controllers/__init__.py
Normal file
2
fusion_claims/controllers/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import portal
|
||||
54
fusion_claims/controllers/portal.py
Normal file
54
fusion_claims/controllers/portal.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2024-2025 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Claim Assistant product family.
|
||||
|
||||
from odoo.addons.sale.controllers.portal import CustomerPortal
|
||||
|
||||
|
||||
class FusionCustomerPortal(CustomerPortal):
|
||||
|
||||
def _determine_is_down_payment(self, order_sudo, amount_selection, payment_amount):
|
||||
"""Override to use client portion for ADP down-payment comparison."""
|
||||
if (
|
||||
hasattr(order_sudo, '_is_adp_sale')
|
||||
and order_sudo._is_adp_sale()
|
||||
and order_sudo.x_fc_client_type == 'REG'
|
||||
):
|
||||
payable = order_sudo.x_fc_client_portion_total or 0
|
||||
if amount_selection == 'down_payment':
|
||||
return True
|
||||
elif amount_selection == 'full_amount':
|
||||
return False
|
||||
else:
|
||||
return (
|
||||
order_sudo.prepayment_percent < 1.0 if payment_amount is None
|
||||
else payment_amount < payable
|
||||
)
|
||||
return super()._determine_is_down_payment(order_sudo, amount_selection, payment_amount)
|
||||
|
||||
def _get_payment_values(self, order_sudo, is_down_payment=False, payment_amount=None, **kwargs):
|
||||
"""Override to cap payment amount at client portion for ADP orders."""
|
||||
values = super()._get_payment_values(
|
||||
order_sudo,
|
||||
is_down_payment=is_down_payment,
|
||||
payment_amount=payment_amount,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
if not (
|
||||
hasattr(order_sudo, '_is_adp_sale')
|
||||
and order_sudo._is_adp_sale()
|
||||
and order_sudo.x_fc_client_type == 'REG'
|
||||
):
|
||||
return values
|
||||
|
||||
client_portion = order_sudo.x_fc_client_portion_total or 0
|
||||
if client_portion <= 0:
|
||||
return values
|
||||
|
||||
current_amount = values.get('amount', 0)
|
||||
if current_amount > client_portion:
|
||||
values['amount'] = order_sudo.currency_id.round(client_portion)
|
||||
|
||||
return values
|
||||
Reference in New Issue
Block a user