diff --git a/fusion-plating/fusion_plating_configurator/models/fp_quote_configurator.py b/fusion-plating/fusion_plating_configurator/models/fp_quote_configurator.py index fe6c60ab..1a8ee8ab 100644 --- a/fusion-plating/fusion_plating_configurator/models/fp_quote_configurator.py +++ b/fusion-plating/fusion_plating_configurator/models/fp_quote_configurator.py @@ -3,6 +3,8 @@ # License OPL-1 (Odoo Proprietary License v1.0) # Part of the Fusion Plating product family. +import math + from odoo import api, fields, models, _ from odoo.exceptions import UserError @@ -117,7 +119,7 @@ class FpQuoteConfigurator(models.Model): 'masking_zones', 'complexity', 'substrate_material', 'quantity', 'batch_size', 'rush_order', 'shipping_fee', 'delivery_fee', - 'coating_config_id', + 'coating_config_id', 'coating_config_id.certification_level', ) def _compute_price(self): for rec in self: @@ -143,10 +145,12 @@ class FpQuoteConfigurator(models.Model): else: # flat_rate unit_price = rule.base_rate - # --- Thickness factor --- + # --- Thickness scaling --- + # thickness_factor is a per-mil multiplier. A factor of 1.0 + # means linear scaling by thickness (e.g. 3 mils = 3x price). + # A factor of 0.8 gives a volume discount (3 mils = 2.4x). thickness = rec.thickness_requested or 1.0 - if rule.thickness_factor and rule.thickness_factor != 1.0: - unit_price *= rule.thickness_factor * thickness + unit_price *= thickness * rule.thickness_factor # --- Complexity surcharge --- surcharge_pct = 0 @@ -159,8 +163,13 @@ class FpQuoteConfigurator(models.Model): # --- Masking --- masking_cost = (rec.masking_zones or 0) * rule.masking_rate_per_zone - # --- Quantity --- - subtotal = (unit_price * rec.quantity) + masking_cost + rule.setup_fee + # --- Quantity + batch setup fees --- + num_batches = ( + math.ceil(rec.quantity / rec.batch_size) if rec.batch_size + else 1 + ) + total_setup = rule.setup_fee * num_batches + subtotal = (unit_price * rec.quantity) + masking_cost + total_setup # --- Rush surcharge --- rush_amount = 0 @@ -178,40 +187,43 @@ class FpQuoteConfigurator(models.Model): rec.calculated_price = total # --- Build breakdown HTML --- + sym = rec.currency_id.symbol or '$' lines = [] + method_label = dict( + rule._fields['pricing_method'].selection + ).get(rule.pricing_method, '') lines.append( - '