"""Pruebas del cálculo de peso/volumen (P/Vol) aéreo."""

from decimal import Decimal

from api.v1.modules.crm.common.pricing import air_chargeable_kg, air_volumetric_kg


def test_air_volumetric_doc_example():
    # 3 pallets 120×120×100 cm → (120*120*100*3)/6000 = 720 (ejemplo del documento)
    assert air_volumetric_kg(120, 120, 100, 3) == Decimal(720)


def test_air_volumetric_zero_without_dimensions():
    assert air_volumetric_kg(None, 120, 100, 3) == Decimal(0)
    assert air_volumetric_kg(0, 120, 100, 3) == Decimal(0)


def test_air_qty_defaults_to_one():
    assert air_volumetric_kg(100, 100, 100, 0) == air_volumetric_kg(100, 100, 100, 1)


def test_air_chargeable_takes_gross_when_larger():
    # bruto 800 > volumétrico 720 → se cobra 800
    assert air_chargeable_kg(800, 120, 120, 100, 3) == Decimal(800)


def test_air_chargeable_takes_volumetric_when_larger():
    # bruto 200 < volumétrico 720 → se cobra 720
    assert air_chargeable_kg(200, 120, 120, 100, 3) == Decimal(720)
