import asyncio
from unittest.mock import AsyncMock, MagicMock

from httpx import Response

from bb_integrations_lib.gravitate.sd_api import GravitateSDAPI
from bb_integrations_lib.pipelines.shared.allocation_matcher.matcher import AllocationMatcher
from egg import Egg, hatch_eggs

mock_bols_and_drops_response = [
    {
        "order_number": "1103",
        "order_id": "6953f4eda8bb5f01056eaca6",
        "po": None,
        "carrier": "",
        "carrier_id": None,
        "manager": None,
        "manager_id": None,
        "last_movement_update": "2025-12-30T18:32:27.749000",
        "order_date": "2025-12-30T15:51:09Z",
        "status": "complete",
        "type": "regular",
        "drops": [
            {
                "compartment_indexes": [0],
                "before_stick_inches": 22,
                "before_stick_time": "2025-12-30T18:28:44.281000Z",
                "after_stick_inches": 47,
                "after_stick_time": "2025-12-30T18:28:52.122000Z",
                "drop_id": "6953f4eda8bb5f01056eac9e",
                "location": "1082",
                "location_id": "69090f2e5a7ba1bea579a965",
                "location_source_id": None,
                "location_source_system": "",
                "product": "87OCT 10%ETH - SUNOCO",
                "product_id": "6908f4469257414108faf071",
                "product_source_id": "FO-87-E10 | SUN",
                "product_source_system": "PDI",
                "tank_id": 1,
                "tank_source_id": None,
                "tank_source_system": None,
                "volume": 3998,
                "driver_id": "690912c7cca24d51e38ca2ea",
                "driver_username": "rstewart7468",
                "driver_extra_data": {"source_id": "1182", "source_system_id": "PDI"},
                "driver_name": "Joel Stewart",
                "driver_date": "2025-12-30T00:00:00",
                "driver_shift": "am",
                "driver_shift_id": "6952ab2e05e52270b51f3d0c",
                "tractor_number": "202",
                "trailer_number": "1609",
                "blend_codes": [],
                "site_counterparty_id": "6908f1eab4fcf6a36e6660e1",
                "site_counterparty_name": "Bazco",
                "freight_customer_id": None,
                "freight_customer_name": None,
            },
            {
                "compartment_indexes": [1],
                "before_stick_inches": 31,
                "before_stick_time": "2025-12-30T18:30:30.745000Z",
                "after_stick_inches": 78,
                "after_stick_time": "2025-12-30T18:30:34.427000Z",
                "drop_id": "6953f4eda8bb5f01056eac9f",
                "location": "1083",
                "location_id": "69090f2e5a7ba1bea579a969",
                "location_source_id": None,
                "location_source_system": "",
                "product": "87OCT 10%ETH - SUNOCO",
                "product_id": "6908f4469257414108faf071",
                "product_source_id": "FO-87-E10 | SUN",
                "product_source_system": "PDI",
                "tank_id": 3,
                "tank_source_id": None,
                "tank_source_system": None,
                "volume": 6001,
                "driver_id": "690912c7cca24d51e38ca2ea",
                "driver_username": "rstewart7468",
                "driver_extra_data": {"source_id": "1182", "source_system_id": "PDI"},
                "driver_name": "Joel Stewart",
                "driver_date": "2025-12-30T00:00:00",
                "driver_shift": "am",
                "driver_shift_id": "6952ab2e05e52270b51f3d0c",
                "tractor_number": "202",
                "trailer_number": "1609",
                "blend_codes": [],
                "site_counterparty_id": "6908f1eab4fcf6a36e6660e1",
                "site_counterparty_name": "Bazco",
                "freight_customer_id": None,
                "freight_customer_name": None,
            },
            {
                "compartment_indexes": [2],
                "before_stick_inches": 15,
                "before_stick_time": "2025-12-30T18:30:53.323000Z",
                "after_stick_inches": 26,
                "after_stick_time": "2025-12-30T18:30:57.401000Z",
                "drop_id": "6953f4eda8bb5f01056eaca0",
                "location": "1083",
                "location_id": "69090f2e5a7ba1bea579a969",
                "location_source_id": None,
                "location_source_system": "",
                "product": "93OCT 10%ETH - SUNOCO",
                "product_id": "6908f409b4fcf6a36e6660f3",
                "product_source_id": "FO-93-E10 | SUN",
                "product_source_system": "PDI",
                "tank_id": 1,
                "tank_source_id": None,
                "tank_source_system": None,
                "volume": 1003,
                "driver_id": "690912c7cca24d51e38ca2ea",
                "driver_username": "rstewart7468",
                "driver_extra_data": {"source_id": "1182", "source_system_id": "PDI"},
                "driver_name": "Joel Stewart",
                "driver_date": "2025-12-30T00:00:00",
                "driver_shift": "am",
                "driver_shift_id": "6952ab2e05e52270b51f3d0c",
                "tractor_number": "202",
                "trailer_number": "1609",
                "blend_codes": [],
                "site_counterparty_id": "6908f1eab4fcf6a36e6660e1",
                "site_counterparty_name": "Bazco",
                "freight_customer_id": None,
                "freight_customer_name": None,
            },
        ],
        "bols": [
            {
                "bol_number": "334618136",
                "bol_id": "6954191e8c10fc0f85cbda35",
                "date": "2025-12-30T18:23:06.337000Z",
                "details": [
                    {
                        "compartment_index": None,
                        "load_number": None,
                        "product": "87OCT 10%ETH - CITGO",
                        "product_id": "6908f409b4fcf6a36e6660f1",
                        "product_source_id": "FO-87-E10 | CIT",
                        "product_source_system": "PDI",
                        "net_volume": 10097,
                        "gross_volume": 9999,
                        "supplier": "Citgo Branded",
                        "supplier_id": "6908f1eab4fcf6a36e6660c8",
                        "supplier_source_id": "5002",
                        "supplier_source_system": "",
                        "contract": "",
                        "price_details": {
                            "price": None,
                            "price_id": None,
                            "curve_id": None,
                            "date": "2025-12-30T18:23:06.337000",
                            "counterparty_id": "6",
                        },
                    },
                    {
                        "compartment_index": None,
                        "load_number": None,
                        "product": "93OCT 10%ETH - CITGO",
                        "product_id": "6908f409b4fcf6a36e6660f2",
                        "product_source_id": "FO-93-E10 | CIT",
                        "product_source_system": "PDI",
                        "net_volume": 1026,
                        "gross_volume": 1003,
                        "supplier": "Citgo Branded",
                        "supplier_id": "6908f1eab4fcf6a36e6660c8",
                        "supplier_source_id": "5002",
                        "supplier_source_system": "",
                        "contract": "",
                        "price_details": {
                            "price": None,
                            "price_id": None,
                            "curve_id": None,
                            "date": "2025-12-30T18:23:06.337000",
                            "counterparty_id": "6",
                        },
                    },
                ],
                "load_or_drop": "Load",
                "location": "MARATHON -Detroit",
                "location_id": "69090ecad6ff2d863efaf07b",
                "location_source_id": "T-38-MI-3015",
                "location_source_system": "PDI",
                "driver_id": "690912c7cca24d51e38ca2ea",
                "driver_username": "rstewart7468",
                "driver_extra_data": {"source_id": "1182", "source_system_id": "PDI"},
                "driver_name": "Joel Stewart",
                "driver_date": "2025-12-30T00:00:00",
                "driver_shift": "am",
                "driver_shift_id": "6952ab2e05e52270b51f3d0c",
                "tractor_number": "202",
                "trailer_number": "1609",
            }
        ],
        "costs": [
            {
                "cost_type": "freight",
                "carrier": "missing",
                "carrier_source_id": "",
                "carrier_source_system": "",
                "per_unit_price": 0.034100000000000005,
                "cost_amount": 375.1,
            }
        ],
        "validation_bypass_on": None,
        "has_additives": False,
        "estimated_freight": {
            "id": "6953f4eda8bb5f01056eaca4",
            "parent": None,
            "created_at": "2025-12-30T15:51:09.909000",
            "type": "freight",
            "status": "open",
            "reversed": False,
            "transactions": [
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 31-35",
                    "rate": 0.0341,
                    "amount": 4000,
                    "total": 136.4,
                    "uom": "gallons",
                    "errors": [],
                    "id": "6953f4eda8bb5f01056eaca1",
                    "product_group": "Gasoline",
                    "product_id": "6908f4469257414108faf071",
                    "product_name": "87OCT 10%ETH - SUNOCO",
                    "origin": "MARATHON -Detroit",
                    "origin_id": "69090ecad6ff2d863efaf07b",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1082",
                    "destination_id": "69090f2e5a7ba1bea579a967",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05,
                        },
                        {
                            "origin": "MARATHON -Detroit",
                            "origin_id": "69090ecad6ff2d863efaf07b",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 14.37,
                        },
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {"mileage": 30},
                    "gross_volume": None,
                    "net_volume": None,
                    "bol_date": None,
                    "bol_number": None,
                    "bol_number_override": None,
                    "delivery_date": None,
                },
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 31-35",
                    "rate": 0.0341,
                    "amount": 6000,
                    "total": 204.6,
                    "uom": "gallons",
                    "errors": [],
                    "id": "6953f4eda8bb5f01056eaca2",
                    "product_group": "Gasoline",
                    "product_id": "6908f4469257414108faf071",
                    "product_name": "87OCT 10%ETH - SUNOCO",
                    "origin": "MARATHON -Detroit",
                    "origin_id": "69090ecad6ff2d863efaf07b",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1083",
                    "destination_id": "69090f2e5a7ba1bea579a96b",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05,
                        },
                        {
                            "origin": "MARATHON -Detroit",
                            "origin_id": "69090ecad6ff2d863efaf07b",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 14.37,
                        },
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {"mileage": 30},
                    "gross_volume": None,
                    "net_volume": None,
                    "bol_date": None,
                    "bol_number": None,
                    "bol_number_override": None,
                    "delivery_date": None,
                },
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 31-35",
                    "rate": 0.0341,
                    "amount": 1000,
                    "total": 34.1,
                    "uom": "gallons",
                    "errors": [],
                    "id": "6953f4eda8bb5f01056eaca3",
                    "product_group": "Gasoline",
                    "product_id": "6908f409b4fcf6a36e6660f3",
                    "product_name": "93OCT 10%ETH - SUNOCO",
                    "origin": "MARATHON -Detroit",
                    "origin_id": "69090ecad6ff2d863efaf07b",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1083",
                    "destination_id": "69090f2e5a7ba1bea579a96b",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05,
                        },
                        {
                            "origin": "MARATHON -Detroit",
                            "origin_id": "69090ecad6ff2d863efaf07b",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 14.37,
                        },
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {"mileage": 30},
                    "gross_volume": None,
                    "net_volume": None,
                    "bol_date": None,
                    "bol_number": None,
                    "bol_number_override": None,
                    "delivery_date": None,
                },
            ],
            "counterparty_id": "6908f1eab4fcf6a36e6660e1",
            "book_type": "Cost",
            "effective_date_used": "2025-12-30T00:00:00",
            "invoice_group_id": None,
            "invoice_number": None,
            "accessorial_invoice_number": None,
            "new_version_available": False,
            "new_version_total": None,
            "error": None,
        },
        "actual_freight": {
            "id": "69541abb8c10fc0f85cbda90",
            "parent": None,
            "created_at": "2025-12-30T18:32:27.707000",
            "type": "freight",
            "status": "open",
            "reversed": False,
            "transactions": [
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 31-35",
                    "rate": 0.0341,
                    "amount": 4037,
                    "total": 137.66,
                    "uom": "gallons",
                    "errors": [],
                    "id": "69541abb8c10fc0f85cbda8d",
                    "product_group": "Gasoline",
                    "product_id": "6908f4469257414108faf071",
                    "product_name": "87OCT 10%ETH - SUNOCO",
                    "origin": "MARATHON -Detroit",
                    "origin_id": "69090ecad6ff2d863efaf07b",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1082",
                    "destination_id": "69090f2e5a7ba1bea579a965",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05,
                        },
                        {
                            "origin": "MARATHON -Detroit",
                            "origin_id": "69090ecad6ff2d863efaf07b",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 14.37,
                        },
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {"mileage": 30},
                    "gross_volume": 3998,
                    "net_volume": 4037,
                    "bol_date": "2025-12-30T18:23:06.337000",
                    "bol_number": "334618136",
                    "bol_number_override": None,
                    "delivery_date": "2025-12-30T18:28:52.122000",
                },
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 31-35",
                    "rate": 0.0341,
                    "amount": 1026,
                    "total": 34.99,
                    "uom": "gallons",
                    "errors": [],
                    "id": "69541abb8c10fc0f85cbda8e",
                    "product_group": "Gasoline",
                    "product_id": "6908f409b4fcf6a36e6660f3",
                    "product_name": "93OCT 10%ETH - SUNOCO",
                    "origin": "MARATHON -Detroit",
                    "origin_id": "69090ecad6ff2d863efaf07b",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1083",
                    "destination_id": "69090f2e5a7ba1bea579a969",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05,
                        },
                        {
                            "origin": "MARATHON -Detroit",
                            "origin_id": "69090ecad6ff2d863efaf07b",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 14.37,
                        },
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {"mileage": 30},
                    "gross_volume": 1003,
                    "net_volume": 1026,
                    "bol_date": "2025-12-30T18:23:06.337000",
                    "bol_number": "334618136",
                    "bol_number_override": None,
                    "delivery_date": "2025-12-30T18:30:57.401000",
                },
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 31-35",
                    "rate": 0.0341,
                    "amount": 6060,
                    "total": 206.65,
                    "uom": "gallons",
                    "errors": [],
                    "id": "69541abb8c10fc0f85cbda8f",
                    "product_group": "Gasoline",
                    "product_id": "6908f4469257414108faf071",
                    "product_name": "87OCT 10%ETH - SUNOCO",
                    "origin": "MARATHON -Detroit",
                    "origin_id": "69090ecad6ff2d863efaf07b",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1083",
                    "destination_id": "69090f2e5a7ba1bea579a969",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05,
                        },
                        {
                            "origin": "MARATHON -Detroit",
                            "origin_id": "69090ecad6ff2d863efaf07b",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 14.37,
                        },
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {"mileage": 30},
                    "gross_volume": 6001,
                    "net_volume": 6060,
                    "bol_date": "2025-12-30T18:23:06.337000",
                    "bol_number": "334618136",
                    "bol_number_override": None,
                    "delivery_date": "2025-12-30T18:30:34.427000",
                },
            ],
            "counterparty_id": "6908f1eab4fcf6a36e6660e1",
            "book_type": "Cost",
            "effective_date_used": "2025-12-30T00:00:00",
            "invoice_group_id": None,
            "invoice_number": None,
            "accessorial_invoice_number": None,
            "new_version_available": False,
            "new_version_total": None,
            "error": None,
        },
        "allocated_bol_error": None,
        "allocated_bol_issue": None,
        "allocated_bols": [
            {
                "bol_number": "334618136",
                "bol_id": "6954191e8c10fc0f85cbda35",
                "bol_terminal_id": "69090ecad6ff2d863efaf07b",
                "bol_terminal": "MARATHON -Detroit",
                "bol_product": "87OCT 10%ETH - CITGO",
                "bol_product_id": "6908f409b4fcf6a36e6660f1",
                "bol_supplier": "Citgo Branded",
                "bol_supplier_id": "6908f1eab4fcf6a36e6660c8",
                "bol_net_volume_original": 10097,
                "bol_gross_volume_original": 9999,
                "store_number": "1082",
                "store_id": "69090f2e5a7ba1bea579a967",
                "location_id": "69090f2e5a7ba1bea579a965",
                "store_tank": 1,
                "store_product": "87OCT 10%ETH - SUNOCO",
                "store_product_id": "6908f4469257414108faf071",
                "store_timezone": "America/New_York",
                "bol_net_volume_allocated": 4037,
                "bol_gross_volume_allocated": 3998,
                "driver_schedule": "6952ab2e05e52270b51f3d0c",
                "bol_date": "2025-12-30T18:23:06.337000",
                "delivered_date": "2025-12-30T18:28:52.122000",
                "price": {
                    "contract": "",
                    "price_type": "rack",
                    "price_id": "6953080ab9ee7ece772690e7",
                    "curve_id": "6945cec2f88ce49ef5fc504a",
                    "price": 1.6712,
                    "date": "2025-12-30T18:23:06.337000",
                    "expired": False,
                },
            },
            {
                "bol_number": "334618136",
                "bol_id": "6954191e8c10fc0f85cbda35",
                "bol_terminal_id": "69090ecad6ff2d863efaf07b",
                "bol_terminal": "MARATHON -Detroit",
                "bol_product": "87OCT 10%ETH - CITGO",
                "bol_product_id": "6908f409b4fcf6a36e6660f1",
                "bol_supplier": "Citgo Branded",
                "bol_supplier_id": "6908f1eab4fcf6a36e6660c8",
                "bol_net_volume_original": 10097,
                "bol_gross_volume_original": 9999,
                "store_number": "1083",
                "store_id": "69090f2e5a7ba1bea579a96b",
                "location_id": "69090f2e5a7ba1bea579a969",
                "store_tank": 3,
                "store_product": "87OCT 10%ETH - SUNOCO",
                "store_product_id": "6908f4469257414108faf071",
                "store_timezone": "America/New_York",
                "bol_net_volume_allocated": 6060,
                "bol_gross_volume_allocated": 6001,
                "driver_schedule": "6952ab2e05e52270b51f3d0c",
                "bol_date": "2025-12-30T18:23:06.337000",
                "delivered_date": "2025-12-30T18:30:34.427000",
                "price": {
                    "contract": "",
                    "price_type": "rack",
                    "price_id": "6953080ab9ee7ece772690e7",
                    "curve_id": "6945cec2f88ce49ef5fc504a",
                    "price": 1.6712,
                    "date": "2025-12-30T18:23:06.337000",
                    "expired": False,
                },
            },
            {
                "bol_number": "334618136",
                "bol_id": "6954191e8c10fc0f85cbda35",
                "bol_terminal_id": "69090ecad6ff2d863efaf07b",
                "bol_terminal": "MARATHON -Detroit",
                "bol_product": "93OCT 10%ETH - CITGO",
                "bol_product_id": "6908f409b4fcf6a36e6660f2",
                "bol_supplier": "Citgo Branded",
                "bol_supplier_id": "6908f1eab4fcf6a36e6660c8",
                "bol_net_volume_original": 1026,
                "bol_gross_volume_original": 1003,
                "store_number": "1083",
                "store_id": "69090f2e5a7ba1bea579a96b",
                "location_id": "69090f2e5a7ba1bea579a969",
                "store_tank": 1,
                "store_product": "93OCT 10%ETH - SUNOCO",
                "store_product_id": "6908f409b4fcf6a36e6660f3",
                "store_timezone": "America/New_York",
                "bol_net_volume_allocated": 1026,
                "bol_gross_volume_allocated": 1003,
                "driver_schedule": "6952ab2e05e52270b51f3d0c",
                "bol_date": "2025-12-30T18:23:06.337000",
                "delivered_date": "2025-12-30T18:30:57.401000",
                "price": {
                    "contract": "",
                    "price_type": "rack",
                    "price_id": "6953080ab9ee7ece772690ea",
                    "curve_id": "6945cec2f88ce49ef5fc5050",
                    "price": 2.6813,
                    "date": "2025-12-30T18:23:06.337000",
                    "expired": False,
                },
            },
        ],
        "last_change_date": "2025-12-30T18:32:27.749000",
        "reference_order_number": None,
    },
    {
        "order_number": "1196",
        "order_id": "69581c65ee5aaa626ed7ddee",
        "po": None,
        "carrier": "",
        "carrier_id": None,
        "manager": None,
        "manager_id": None,
        "last_movement_update": "2026-01-02T19:29:59.497000",
        "order_date": "2026-01-02T19:28:37Z",
        "status": "complete",
        "type": "regular",
        "drops": [
            {
                "compartment_indexes": [
                    0
                ],
                "before_stick_inches": None,
                "before_stick_time": "2026-01-02T18:29:00Z",
                "after_stick_inches": None,
                "after_stick_time": "2026-01-02T18:29:00Z",
                "drop_id": "69581c65ee5aaa626ed7dde6",
                "location": "1082",
                "location_id": "69090f2e5a7ba1bea579a965",
                "location_source_id": None,
                "location_source_system": "",
                "product": "87OCT 10%ETH - SUNOCO",
                "product_id": "6908f4469257414108faf071",
                "product_source_id": "FO-87-E10 | SUN",
                "product_source_system": "PDI",
                "tank_id": 1,
                "tank_source_id": None,
                "tank_source_system": None,
                "volume": 4000,
                "driver_id": None,
                "driver_username": None,
                "driver_extra_data": None,
                "driver_name": None,
                "driver_date": None,
                "driver_shift": None,
                "driver_shift_id": None,
                "tractor_number": None,
                "trailer_number": None,
                "blend_codes": [],
                "site_counterparty_id": "6908f1eab4fcf6a36e6660e1",
                "site_counterparty_name": "Bazco",
                "freight_customer_id": None,
                "freight_customer_name": None
            },
            {
                "compartment_indexes": [
                    1
                ],
                "before_stick_inches": None,
                "before_stick_time": "2026-01-02T18:29:00Z",
                "after_stick_inches": None,
                "after_stick_time": "2026-01-02T18:29:00Z",
                "drop_id": "69581c65ee5aaa626ed7dde7",
                "location": "1083",
                "location_id": "69090f2e5a7ba1bea579a969",
                "location_source_id": None,
                "location_source_system": "",
                "product": "87OCT 10%ETH - SUNOCO",
                "product_id": "6908f4469257414108faf071",
                "product_source_id": "FO-87-E10 | SUN",
                "product_source_system": "PDI",
                "tank_id": 3,
                "tank_source_id": None,
                "tank_source_system": None,
                "volume": 6000,
                "driver_id": None,
                "driver_username": None,
                "driver_extra_data": None,
                "driver_name": None,
                "driver_date": None,
                "driver_shift": None,
                "driver_shift_id": None,
                "tractor_number": None,
                "trailer_number": None,
                "blend_codes": [],
                "site_counterparty_id": "6908f1eab4fcf6a36e6660e1",
                "site_counterparty_name": "Bazco",
                "freight_customer_id": None,
                "freight_customer_name": None
            },
            {
                "compartment_indexes": [
                    2
                ],
                "before_stick_inches": None,
                "before_stick_time": "2026-01-02T18:29:00Z",
                "after_stick_inches": None,
                "after_stick_time": "2026-01-02T18:29:00Z",
                "drop_id": "69581c65ee5aaa626ed7dde8",
                "location": "1083",
                "location_id": "69090f2e5a7ba1bea579a969",
                "location_source_id": None,
                "location_source_system": "",
                "product": "93OCT 10%ETH - SUNOCO",
                "product_id": "6908f409b4fcf6a36e6660f3",
                "product_source_id": "FO-93-E10 | SUN",
                "product_source_system": "PDI",
                "tank_id": 1,
                "tank_source_id": None,
                "tank_source_system": None,
                "volume": 1000,
                "driver_id": None,
                "driver_username": None,
                "driver_extra_data": None,
                "driver_name": None,
                "driver_date": None,
                "driver_shift": None,
                "driver_shift_id": None,
                "tractor_number": None,
                "trailer_number": None,
                "blend_codes": [],
                "site_counterparty_id": "6908f1eab4fcf6a36e6660e1",
                "site_counterparty_name": "Bazco",
                "freight_customer_id": None,
                "freight_customer_name": None
            }
        ],
        "bols": [
            {
                "bol_number": "243242",
                "bol_id": "69581c9d37fc1998fed7e946",
                "date": "2026-01-02T18:28:00Z",
                "details": [
                    {
                        "compartment_index": None,
                        "load_number": None,
                        "product": "87OCT 10%ETH - SUNOCO",
                        "product_id": "6908f4469257414108faf071",
                        "product_source_id": "FO-87-E10 | SUN",
                        "product_source_system": "PDI",
                        "net_volume": 10000,
                        "gross_volume": 9999,
                        "supplier": "Sunoco",
                        "supplier_id": "6908f1eab4fcf6a36e6660d9",
                        "supplier_source_id": "5008",
                        "supplier_source_system": "",
                        "contract": "",
                        "price_details": {
                            "price": None,
                            "price_id": None,
                            "curve_id": None,
                            "date": "2026-01-02T18:28:00",
                            "counterparty_id": "6"
                        }
                    },
                    {
                        "compartment_index": None,
                        "load_number": None,
                        "product": "93OCT 10%ETH - SUNOCO",
                        "product_id": "6908f409b4fcf6a36e6660f3",
                        "product_source_id": "FO-93-E10 | SUN",
                        "product_source_system": "PDI",
                        "net_volume": 1026,
                        "gross_volume": 1003,
                        "supplier": "Sunoco",
                        "supplier_id": "6908f1eab4fcf6a36e6660d9",
                        "supplier_source_id": "5008",
                        "supplier_source_system": "",
                        "contract": "",
                        "price_details": {
                            "price": None,
                            "price_id": None,
                            "curve_id": None,
                            "date": "2026-01-02T18:28:00",
                            "counterparty_id": "6"
                        }
                    }
                ],
                "load_or_drop": "Load",
                "location": "SUNOCO -RIVER ROUGE",
                "location_id": "69090ecad6ff2d863efaf084",
                "location_source_id": "T-38-MI-3030",
                "location_source_system": "PDI",
                "driver_id": None,
                "driver_username": None,
                "driver_extra_data": None,
                "driver_name": None,
                "driver_date": None,
                "driver_shift": None,
                "driver_shift_id": None,
                "tractor_number": None,
                "trailer_number": None
            }
        ],
        "costs": [
            {
                "cost_type": "freight",
                "carrier": "missing",
                "carrier_source_id": "",
                "carrier_source_system": "",
                "per_unit_price": 0.0324,
                "cost_amount": 356.4
            }
        ],
        "validation_bypass_on": "2026-01-02T19:29:59.303000",
        "has_additives": False,
        "estimated_freight": {
            "id": "69581c65ee5aaa626ed7ddec",
            "parent": None,
            "created_at": "2026-01-02T19:28:37.447000",
            "type": "freight",
            "status": "open",
            "reversed": False,
            "transactions": [
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 26-30",
                    "rate": 0.0324,
                    "amount": 4000,
                    "total": 129.6,
                    "uom": "gallons",
                    "errors": [],
                    "id": "69581c65ee5aaa626ed7dde9",
                    "product_group": "Gasoline",
                    "product_id": "6908f4469257414108faf071",
                    "product_name": "87OCT 10%ETH - SUNOCO",
                    "origin": "SUNOCO -RIVER ROUGE",
                    "origin_id": "69090ecad6ff2d863efaf084",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1082",
                    "destination_id": "69090f2e5a7ba1bea579a967",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "SUNOCO -RIVER ROUGE",
                            "origin_id": "69090ecad6ff2d863efaf084",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 13.6
                        },
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05
                        }
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {
                        "mileage": 30
                    },
                    "gross_volume": None,
                    "net_volume": None,
                    "bol_date": None,
                    "bol_number": None,
                    "bol_number_override": None,
                    "delivery_date": None
                },
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 26-30",
                    "rate": 0.0324,
                    "amount": 6000,
                    "total": 194.4,
                    "uom": "gallons",
                    "errors": [],
                    "id": "69581c65ee5aaa626ed7ddea",
                    "product_group": "Gasoline",
                    "product_id": "6908f4469257414108faf071",
                    "product_name": "87OCT 10%ETH - SUNOCO",
                    "origin": "SUNOCO -RIVER ROUGE",
                    "origin_id": "69090ecad6ff2d863efaf084",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1083",
                    "destination_id": "69090f2e5a7ba1bea579a96b",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "SUNOCO -RIVER ROUGE",
                            "origin_id": "69090ecad6ff2d863efaf084",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 13.6
                        },
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05
                        }
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {
                        "mileage": 30
                    },
                    "gross_volume": None,
                    "net_volume": None,
                    "bol_date": None,
                    "bol_number": None,
                    "bol_number_override": None,
                    "delivery_date": None
                },
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 26-30",
                    "rate": 0.0324,
                    "amount": 1000,
                    "total": 32.4,
                    "uom": "gallons",
                    "errors": [],
                    "id": "69581c65ee5aaa626ed7ddeb",
                    "product_group": "Gasoline",
                    "product_id": "6908f409b4fcf6a36e6660f3",
                    "product_name": "93OCT 10%ETH - SUNOCO",
                    "origin": "SUNOCO -RIVER ROUGE",
                    "origin_id": "69090ecad6ff2d863efaf084",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1083",
                    "destination_id": "69090f2e5a7ba1bea579a96b",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "SUNOCO -RIVER ROUGE",
                            "origin_id": "69090ecad6ff2d863efaf084",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 13.6
                        },
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05
                        }
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {
                        "mileage": 30
                    },
                    "gross_volume": None,
                    "net_volume": None,
                    "bol_date": None,
                    "bol_number": None,
                    "bol_number_override": None,
                    "delivery_date": None
                }
            ],
            "counterparty_id": "6908f1eab4fcf6a36e6660e1",
            "book_type": "Cost",
            "effective_date_used": "2026-01-03T00:00:00",
            "invoice_group_id": None,
            "invoice_number": None,
            "accessorial_invoice_number": None,
            "new_version_available": False,
            "new_version_total": None,
            "error": None
        },
        "actual_freight": {
            "id": "69581cb74309aa3937d7df5b",
            "parent": None,
            "created_at": "2026-01-02T19:29:59.488000",
            "type": "freight",
            "status": "open",
            "reversed": False,
            "transactions": [
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 26-30",
                    "rate": 0.0324,
                    "amount": 4000,
                    "total": 129.6,
                    "uom": "gallons",
                    "errors": [],
                    "id": "69581cb74309aa3937d7df56",
                    "product_group": "Gasoline",
                    "product_id": "6908f4469257414108faf071",
                    "product_name": "87OCT 10%ETH - SUNOCO",
                    "origin": "SUNOCO -RIVER ROUGE",
                    "origin_id": "69090ecad6ff2d863efaf084",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1082",
                    "destination_id": "69090f2e5a7ba1bea579a965",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "SUNOCO -RIVER ROUGE",
                            "origin_id": "69090ecad6ff2d863efaf084",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 13.6
                        },
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05
                        }
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {
                        "mileage": 30
                    },
                    "gross_volume": 4000,
                    "net_volume": 4000,
                    "bol_date": "2026-01-02T18:28:00",
                    "bol_number": "243242",
                    "bol_number_override": None,
                    "delivery_date": "2026-01-02T18:29:00"
                },
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 26-30",
                    "rate": 0.0324,
                    "amount": 1026,
                    "total": 33.24,
                    "uom": "gallons",
                    "errors": [],
                    "id": "69581cb74309aa3937d7df58",
                    "product_group": "Gasoline",
                    "product_id": "6908f409b4fcf6a36e6660f3",
                    "product_name": "93OCT 10%ETH - SUNOCO",
                    "origin": "SUNOCO -RIVER ROUGE",
                    "origin_id": "69090ecad6ff2d863efaf084",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1083",
                    "destination_id": "69090f2e5a7ba1bea579a969",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "SUNOCO -RIVER ROUGE",
                            "origin_id": "69090ecad6ff2d863efaf084",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 13.6
                        },
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05
                        }
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {
                        "mileage": 30
                    },
                    "gross_volume": 1003,
                    "net_volume": 1026,
                    "bol_date": "2026-01-02T18:28:00",
                    "bol_number": "243242",
                    "bol_number_override": None,
                    "delivery_date": "2026-01-02T18:29:00"
                },
                {
                    "model_type": "base",
                    "type": "Base Freight",
                    "subtype": "Band 26-30",
                    "rate": 0.0324,
                    "amount": 6000,
                    "total": 194.4,
                    "uom": "gallons",
                    "errors": [],
                    "id": "69581cb74309aa3937d7df5a",
                    "product_group": "Gasoline",
                    "product_id": "6908f4469257414108faf071",
                    "product_name": "87OCT 10%ETH - SUNOCO",
                    "origin": "SUNOCO -RIVER ROUGE",
                    "origin_id": "69090ecad6ff2d863efaf084",
                    "origin_override": None,
                    "origin_id_override": None,
                    "destination": "1083",
                    "destination_id": "69090f2e5a7ba1bea579a969",
                    "destination_override": None,
                    "destination_id_override": None,
                    "legs": [
                        {
                            "origin": "SUNOCO -RIVER ROUGE",
                            "origin_id": "69090ecad6ff2d863efaf084",
                            "destination": "1082",
                            "destination_id": "69090f2e5a7ba1bea579a965",
                            "distance": 13.6
                        },
                        {
                            "origin": "1082",
                            "origin_id": "69090f2e5a7ba1bea579a965",
                            "destination": "1083",
                            "destination_id": "69090f2e5a7ba1bea579a969",
                            "distance": 16.05
                        }
                    ],
                    "use_surcharge": True,
                    "manual": False,
                    "has_dependency": False,
                    "created_date": None,
                    "requires_approval": False,
                    "requires_approval_reason_code": False,
                    "is_approved": False,
                    "approved_by": None,
                    "approved_date": None,
                    "approved_reason_code": None,
                    "amount_override": None,
                    "rate_override": None,
                    "product_id_override": None,
                    "product_name_override": None,
                    "product_group_override": None,
                    "subtype_override": None,
                    "uom_override": None,
                    "total_override": None,
                    "override_by": None,
                    "override_date": None,
                    "exclude_from_invoice": False,
                    "credit_rebill_metadata": None,
                    "extra_data": {
                        "mileage": 30
                    },
                    "gross_volume": 5999,
                    "net_volume": 6000,
                    "bol_date": "2026-01-02T18:28:00",
                    "bol_number": "243242",
                    "bol_number_override": None,
                    "delivery_date": "2026-01-02T18:29:00"
                }
            ],
            "counterparty_id": "6908f1eab4fcf6a36e6660e1",
            "book_type": "Cost",
            "effective_date_used": "2026-01-02T00:00:00",
            "invoice_group_id": None,
            "invoice_number": None,
            "accessorial_invoice_number": None,
            "new_version_available": False,
            "new_version_total": None,
            "error": None
        },
        "allocated_bol_error": None,
        "allocated_bol_issue": None,
        "allocated_bols": [
            {
                "bol_number": "243242",
                "bol_id": "69581c9d37fc1998fed7e946",
                "bol_terminal_id": "69090ecad6ff2d863efaf084",
                "bol_terminal": "SUNOCO -RIVER ROUGE",
                "bol_product": "87OCT 10%ETH - SUNOCO",
                "bol_product_id": "6908f4469257414108faf071",
                "bol_supplier": "Sunoco",
                "bol_supplier_id": "6908f1eab4fcf6a36e6660d9",
                "bol_net_volume_original": 10000,
                "bol_gross_volume_original": 9999,
                "store_number": "1082",
                "store_id": "69090f2e5a7ba1bea579a967",
                "location_id": "69090f2e5a7ba1bea579a965",
                "store_tank": 1,
                "store_product": "87OCT 10%ETH - SUNOCO",
                "store_product_id": "6908f4469257414108faf071",
                "store_timezone": "America/New_York",
                "bol_net_volume_allocated": 4000,
                "bol_gross_volume_allocated": 4000,
                "driver_schedule": None,
                "bol_date": "2026-01-02T18:28:00",
                "delivered_date": "2026-01-02T18:29:00",
                "price": {
                    "contract": "",
                    "price_type": "rack",
                    "price_id": "6955ab1fb816b69ba5c18eca",
                    "curve_id": "6945cec2f88ce49ef5fc509c",
                    "price": 1.7556,
                    "date": "2026-01-02T18:28:00",
                    "expired": True
                }
            },
            {
                "bol_number": "243242",
                "bol_id": "69581c9d37fc1998fed7e946",
                "bol_terminal_id": "69090ecad6ff2d863efaf084",
                "bol_terminal": "SUNOCO -RIVER ROUGE",
                "bol_product": "87OCT 10%ETH - SUNOCO",
                "bol_product_id": "6908f4469257414108faf071",
                "bol_supplier": "Sunoco",
                "bol_supplier_id": "6908f1eab4fcf6a36e6660d9",
                "bol_net_volume_original": 10000,
                "bol_gross_volume_original": 9999,
                "store_number": "1083",
                "store_id": "69090f2e5a7ba1bea579a96b",
                "location_id": "69090f2e5a7ba1bea579a969",
                "store_tank": 3,
                "store_product": "87OCT 10%ETH - SUNOCO",
                "store_product_id": "6908f4469257414108faf071",
                "store_timezone": "America/New_York",
                "bol_net_volume_allocated": 6000,
                "bol_gross_volume_allocated": 5999,
                "driver_schedule": None,
                "bol_date": "2026-01-02T18:28:00",
                "delivered_date": "2026-01-02T18:29:00",
                "price": {
                    "contract": "",
                    "price_type": "rack",
                    "price_id": "6955ab1fb816b69ba5c18eca",
                    "curve_id": "6945cec2f88ce49ef5fc509c",
                    "price": 1.7556,
                    "date": "2026-01-02T18:28:00",
                    "expired": True
                }
            },
            {
                "bol_number": "243242",
                "bol_id": "69581c9d37fc1998fed7e946",
                "bol_terminal_id": "69090ecad6ff2d863efaf084",
                "bol_terminal": "SUNOCO -RIVER ROUGE",
                "bol_product": "93OCT 10%ETH - SUNOCO",
                "bol_product_id": "6908f409b4fcf6a36e6660f3",
                "bol_supplier": "Sunoco",
                "bol_supplier_id": "6908f1eab4fcf6a36e6660d9",
                "bol_net_volume_original": 1026,
                "bol_gross_volume_original": 1003,
                "store_number": "1083",
                "store_id": "69090f2e5a7ba1bea579a96b",
                "location_id": "69090f2e5a7ba1bea579a969",
                "store_tank": 1,
                "store_product": "93OCT 10%ETH - SUNOCO",
                "store_product_id": "6908f409b4fcf6a36e6660f3",
                "store_timezone": "America/New_York",
                "bol_net_volume_allocated": 1026,
                "bol_gross_volume_allocated": 1003,
                "driver_schedule": None,
                "bol_date": "2026-01-02T18:28:00",
                "delivered_date": "2026-01-02T18:29:00",
                "price": {
                    "contract": "",
                    "price_type": "rack",
                    "price_id": "6955ab1fb816b69ba5c18ea9",
                    "curve_id": "6945cec2f88ce49ef5fc505a",
                    "price": 2.8061,
                    "date": "2026-01-02T18:28:00",
                    "expired": True
                }
            }
        ],
        "last_change_date": "2026-01-02T19:29:59.497000",
        "reference_order_number": None
    }
]

mock_get_orders_response = [
    {
        "type": "regular",
        "order_id": "6953f4eda8bb5f01056eaca6",
        "drivers": [
            {
                "driver_id": "690912c7cca24d51e38ca2ea",
                "driver_schedule_id": "6952ab2e05e52270b51f3d0c",
                "name": "Joel Stewart",
                "username": "rstewart7468"
            }
        ],
        "order_number": 1103,
        "order_date": "2025-12-30T15:51:09Z",
        "order_state": "complete",
        "carrier_window_start": None,
        "carrier_window_end": None,
        "carrier_window_start_local": None,
        "carrier_window_end_local": None,
        "carrier_notify_state": "none",
        "load_window_start": "2025-12-29T23:00:00Z",
        "load_window_end": "2026-01-04T23:00:00Z",
        "dispatch_window_start": "2025-12-25T23:29:00Z",
        "dispatch_window_end": "2025-12-25T23:29:00Z",
        "hauler_counterparty_id": "None",
        "hauler_counterparty_name": "",
        "hauler_counterparty_source_id": None,
        "hauler_counterparty_source_system": "",
        "hauled_by_updated_by": "JBerninger",
        "hauled_by_updated": "2025-12-30T15:51:33.218000",
        "loads": [
            {
                "location_id": "69090ecad6ff2d863efaf07b",
                "location_name": "MARATHON -Detroit",
                "location_source_id": "T-38-MI-3015",
                "location_source_system": "PDI",
                "location_type": "Terminal",
                "details": [
                    {
                        "detail_id": "6953f4eda8bb5f01056eac9c",
                        "counterparty_id": "6908f1eab4fcf6a36e6660c8",
                        "counterparty_name": "Citgo Branded",
                        "counterparty_source_id": "5002",
                        "counterparty_source_system": None,
                        "price_type": "rack",
                        "contract": "",
                        "product_id": "6908f409b4fcf6a36e6660f1",
                        "product_name": "87OCT 10%ETH - CITGO",
                        "product_source_id": "FO-87-E10 | CIT",
                        "product_source_system": "PDI",
                        "drop_product_id": "6908f4469257414108faf071",
                        "drop_product_name": "87OCT 10%ETH - SUNOCO",
                        "drop_product_source_id": "FO-87-E10 | SUN",
                        "drop_product_source_system": "PDI",
                        "quantity": 4000,
                        "compartment_index": 0,
                        "blend_code": None,
                        "product_codes": [],
                        "load_number": None
                    },
                    {
                        "detail_id": "6953f4eda8bb5f01056eac9c",
                        "counterparty_id": "6908f1eab4fcf6a36e6660c8",
                        "counterparty_name": "Citgo Branded",
                        "counterparty_source_id": "5002",
                        "counterparty_source_system": None,
                        "price_type": "rack",
                        "contract": "",
                        "product_id": "6908f409b4fcf6a36e6660f1",
                        "product_name": "87OCT 10%ETH - CITGO",
                        "product_source_id": "FO-87-E10 | CIT",
                        "product_source_system": "PDI",
                        "drop_product_id": "6908f4469257414108faf071",
                        "drop_product_name": "87OCT 10%ETH - SUNOCO",
                        "drop_product_source_id": "FO-87-E10 | SUN",
                        "drop_product_source_system": "PDI",
                        "quantity": 6000,
                        "compartment_index": 1,
                        "blend_code": None,
                        "product_codes": [],
                        "load_number": None
                    },
                    {
                        "detail_id": "6953f4eda8bb5f01056eac9d",
                        "counterparty_id": "6908f1eab4fcf6a36e6660c8",
                        "counterparty_name": "Citgo Branded",
                        "counterparty_source_id": "5002",
                        "counterparty_source_system": None,
                        "price_type": "rack",
                        "contract": "",
                        "product_id": "6908f409b4fcf6a36e6660f2",
                        "product_name": "93OCT 10%ETH - CITGO",
                        "product_source_id": "FO-93-E10 | CIT",
                        "product_source_system": "PDI",
                        "drop_product_id": "6908f409b4fcf6a36e6660f3",
                        "drop_product_name": "93OCT 10%ETH - SUNOCO",
                        "drop_product_source_id": "FO-93-E10 | SUN",
                        "drop_product_source_system": "PDI",
                        "quantity": 1000,
                        "compartment_index": 2,
                        "blend_code": None,
                        "product_codes": [],
                        "load_number": None
                    }
                ],
                "eta": "2025-12-30T18:22:55.199000",
                "status": "complete"
            }
        ],
        "drops": [
            {
                "location_id": "69090f2e5a7ba1bea579a965",
                "location_name": "1082",
                "location_source_id": None,
                "location_source_system": "",
                "location_type": "Store",
                "details": [
                    {
                        "detail_id": "6953f4eda8bb5f01056eac9e",
                        "counterparty_id": "",
                        "counterparty_name": "",
                        "counterparty_source_id": None,
                        "counterparty_source_system": None,
                        "product_id": "6908f4469257414108faf071",
                        "product_name": "87OCT 10%ETH - SUNOCO",
                        "product_source_id": "FO-87-E10 | SUN",
                        "product_source_system": "PDI",
                        "quantity": 4000,
                        "tank_id": 1,
                        "sources": [
                            {
                                "compartment_index": 0,
                                "volume": 4000
                            }
                        ],
                        "destination_codes": [],
                        "blend_codes": []
                    }
                ],
                "eta": "2025-12-30T18:26:36.339000",
                "status": "complete"
            },
            {
                "location_id": "69090f2e5a7ba1bea579a969",
                "location_name": "1083",
                "location_source_id": None,
                "location_source_system": "",
                "location_type": "Store",
                "details": [
                    {
                        "detail_id": "6953f4eda8bb5f01056eac9f",
                        "counterparty_id": "",
                        "counterparty_name": "",
                        "counterparty_source_id": None,
                        "counterparty_source_system": None,
                        "product_id": "6908f4469257414108faf071",
                        "product_name": "87OCT 10%ETH - SUNOCO",
                        "product_source_id": "FO-87-E10 | SUN",
                        "product_source_system": "PDI",
                        "quantity": 6000,
                        "tank_id": 3,
                        "sources": [
                            {
                                "compartment_index": 1,
                                "volume": 6000
                            }
                        ],
                        "destination_codes": [],
                        "blend_codes": []
                    },
                    {
                        "detail_id": "6953f4eda8bb5f01056eaca0",
                        "counterparty_id": "",
                        "counterparty_name": "",
                        "counterparty_source_id": None,
                        "counterparty_source_system": None,
                        "product_id": "6908f409b4fcf6a36e6660f3",
                        "product_name": "93OCT 10%ETH - SUNOCO",
                        "product_source_id": "FO-93-E10 | SUN",
                        "product_source_system": "PDI",
                        "quantity": 1000,
                        "tank_id": 1,
                        "sources": [
                            {
                                "compartment_index": 2,
                                "volume": 1000
                            }
                        ],
                        "destination_codes": [],
                        "blend_codes": []
                    }
                ],
                "eta": "2025-12-30T18:30:06.668000",
                "status": "complete"
            }
        ],
        "detours": [],
        "trip_status": "complete",
        "last_change_date": "2025-12-30T18:32:27.749000",
        "market": "Michigan",
        "supply_option": {
            "option": "recommended",
            "carrier_id": None,
            "carrier": None,
            "loaded_miles": 30.42233356032,
            "freight": 0.034100000000000005,
            "freight_cost": 0,
            "stops": 3,
            "prices": [
                {
                    "product_name": "87OCT 10%ETH - SUNOCO",
                    "volume": 10000,
                    "components": [
                        {
                            "timezone_data": None,
                            "curve_id": "6945cec2f88ce49ef5fc504a",
                            "price_id": "6953080ab9ee7ece772690e7",
                            "terminal_id": "69090ecad6ff2d863efaf07b",
                            "terminal": "MARATHON -Detroit",
                            "supplier_id": "6908f1eab4fcf6a36e6660c8",
                            "supplier": "Citgo Branded",
                            "price_type": "rack",
                            "product_id": "6908f409b4fcf6a36e6660f1",
                            "product": "87OCT 10%ETH - CITGO",
                            "supply_owner_id": "6908f1eab4fcf6a36e6660e1",
                            "supply_owner": "Bazco",
                            "price": 1.6712,
                            "contract": "",
                            "volume": 10000,
                            "effective_from": "2025-12-29T23:00:00Z",
                            "effective_to": "2026-01-04T23:00:00Z",
                            "group_id": None,
                            "group_effective_cutover": None,
                            "group_effective_cutover_timezone": None,
                            "group_identifier": None,
                            "group_name": None,
                            "min_constraint": None,
                            "max_constraint": None,
                            "load_number": None,
                            "load_numbers": [],
                            "directive_info": None
                        }
                    ],
                    "product_total": 16712,
                    "blend_code": None
                },
                {
                    "product_name": "93OCT 10%ETH - SUNOCO",
                    "volume": 1000,
                    "components": [
                        {
                            "timezone_data": None,
                            "curve_id": "6945cec2f88ce49ef5fc5050",
                            "price_id": "6953080ab9ee7ece772690ea",
                            "terminal_id": "69090ecad6ff2d863efaf07b",
                            "terminal": "MARATHON -Detroit",
                            "supplier_id": "6908f1eab4fcf6a36e6660c8",
                            "supplier": "Citgo Branded",
                            "price_type": "rack",
                            "product_id": "6908f409b4fcf6a36e6660f2",
                            "product": "93OCT 10%ETH - CITGO",
                            "supply_owner_id": "6908f1eab4fcf6a36e6660e1",
                            "supply_owner": "Bazco",
                            "price": 2.6813,
                            "contract": "",
                            "volume": 1000,
                            "effective_from": "2025-12-29T23:00:00Z",
                            "effective_to": "2026-01-04T23:00:00Z",
                            "group_id": None,
                            "group_effective_cutover": None,
                            "group_effective_cutover_timezone": None,
                            "group_identifier": None,
                            "group_name": None,
                            "min_constraint": None,
                            "max_constraint": None,
                            "load_number": None,
                            "load_numbers": [],
                            "directive_info": None
                        }
                    ],
                    "product_total": 2681.2999999999997,
                    "blend_code": None
                }
            ],
            "product_total": 19393.3,
            "landed_cost": 19768.399999999998,
            "supply_owner_map": {
                "definitions": [
                    {
                        "location_name": "1082",
                        "product": "87OCT 10%ETH - SUNOCO",
                        "supply_owner_id": "6908f1eab4fcf6a36e6660e1"
                    },
                    {
                        "location_name": "1083",
                        "product": "87OCT 10%ETH - SUNOCO",
                        "supply_owner_id": "6908f1eab4fcf6a36e6660e1"
                    },
                    {
                        "location_name": "1083",
                        "product": "93OCT 10%ETH - SUNOCO",
                        "supply_owner_id": "6908f1eab4fcf6a36e6660e1"
                    }
                ]
            },
            "freight_customer_id": "6908f1eab4fcf6a36e6660e1",
            "delivered": False,
            "out_of_network": False,
            "estimated_freight": {
                "id": "6953f4eda8bb5f01056eaca4",
                "parent": None,
                "created_at": "2025-12-30T15:51:09.909000",
                "type": "freight",
                "status": "open",
                "reversed": False,
                "transactions": [
                    {
                        "model_type": "base",
                        "type": "Base Freight",
                        "subtype": "Band 31-35",
                        "rate": 0.0341,
                        "amount": 4000,
                        "total": 136.4,
                        "uom": "gallons",
                        "errors": [],
                        "id": "6953f4eda8bb5f01056eaca1",
                        "product_group": "Gasoline",
                        "product_id": "6908f4469257414108faf071",
                        "product_name": "87OCT 10%ETH - SUNOCO",
                        "origin": "MARATHON -Detroit",
                        "origin_id": "69090ecad6ff2d863efaf07b",
                        "origin_override": None,
                        "origin_id_override": None,
                        "destination": "1082",
                        "destination_id": "69090f2e5a7ba1bea579a967",
                        "destination_override": None,
                        "destination_id_override": None,
                        "legs": [
                            {
                                "origin": "1082",
                                "origin_id": "69090f2e5a7ba1bea579a965",
                                "destination": "1083",
                                "destination_id": "69090f2e5a7ba1bea579a969",
                                "distance": 16.05
                            },
                            {
                                "origin": "MARATHON -Detroit",
                                "origin_id": "69090ecad6ff2d863efaf07b",
                                "destination": "1082",
                                "destination_id": "69090f2e5a7ba1bea579a965",
                                "distance": 14.37
                            }
                        ],
                        "use_surcharge": True,
                        "manual": False,
                        "has_dependency": False,
                        "created_date": None,
                        "requires_approval": False,
                        "requires_approval_reason_code": False,
                        "is_approved": False,
                        "approved_by": None,
                        "approved_date": None,
                        "approved_reason_code": None,
                        "amount_override": None,
                        "rate_override": None,
                        "product_id_override": None,
                        "product_name_override": None,
                        "product_group_override": None,
                        "subtype_override": None,
                        "uom_override": None,
                        "total_override": None,
                        "override_by": None,
                        "override_date": None,
                        "exclude_from_invoice": False,
                        "credit_rebill_metadata": None,
                        "extra_data": {
                            "mileage": 30
                        },
                        "gross_volume": None,
                        "net_volume": None,
                        "bol_date": None,
                        "bol_number": None,
                        "bol_number_override": None,
                        "delivery_date": None
                    },
                    {
                        "model_type": "base",
                        "type": "Base Freight",
                        "subtype": "Band 31-35",
                        "rate": 0.0341,
                        "amount": 6000,
                        "total": 204.6,
                        "uom": "gallons",
                        "errors": [],
                        "id": "6953f4eda8bb5f01056eaca2",
                        "product_group": "Gasoline",
                        "product_id": "6908f4469257414108faf071",
                        "product_name": "87OCT 10%ETH - SUNOCO",
                        "origin": "MARATHON -Detroit",
                        "origin_id": "69090ecad6ff2d863efaf07b",
                        "origin_override": None,
                        "origin_id_override": None,
                        "destination": "1083",
                        "destination_id": "69090f2e5a7ba1bea579a96b",
                        "destination_override": None,
                        "destination_id_override": None,
                        "legs": [
                            {
                                "origin": "1082",
                                "origin_id": "69090f2e5a7ba1bea579a965",
                                "destination": "1083",
                                "destination_id": "69090f2e5a7ba1bea579a969",
                                "distance": 16.05
                            },
                            {
                                "origin": "MARATHON -Detroit",
                                "origin_id": "69090ecad6ff2d863efaf07b",
                                "destination": "1082",
                                "destination_id": "69090f2e5a7ba1bea579a965",
                                "distance": 14.37
                            }
                        ],
                        "use_surcharge": True,
                        "manual": False,
                        "has_dependency": False,
                        "created_date": None,
                        "requires_approval": False,
                        "requires_approval_reason_code": False,
                        "is_approved": False,
                        "approved_by": None,
                        "approved_date": None,
                        "approved_reason_code": None,
                        "amount_override": None,
                        "rate_override": None,
                        "product_id_override": None,
                        "product_name_override": None,
                        "product_group_override": None,
                        "subtype_override": None,
                        "uom_override": None,
                        "total_override": None,
                        "override_by": None,
                        "override_date": None,
                        "exclude_from_invoice": False,
                        "credit_rebill_metadata": None,
                        "extra_data": {
                            "mileage": 30
                        },
                        "gross_volume": None,
                        "net_volume": None,
                        "bol_date": None,
                        "bol_number": None,
                        "bol_number_override": None,
                        "delivery_date": None
                    },
                    {
                        "model_type": "base",
                        "type": "Base Freight",
                        "subtype": "Band 31-35",
                        "rate": 0.0341,
                        "amount": 1000,
                        "total": 34.1,
                        "uom": "gallons",
                        "errors": [],
                        "id": "6953f4eda8bb5f01056eaca3",
                        "product_group": "Gasoline",
                        "product_id": "6908f409b4fcf6a36e6660f3",
                        "product_name": "93OCT 10%ETH - SUNOCO",
                        "origin": "MARATHON -Detroit",
                        "origin_id": "69090ecad6ff2d863efaf07b",
                        "origin_override": None,
                        "origin_id_override": None,
                        "destination": "1083",
                        "destination_id": "69090f2e5a7ba1bea579a96b",
                        "destination_override": None,
                        "destination_id_override": None,
                        "legs": [
                            {
                                "origin": "1082",
                                "origin_id": "69090f2e5a7ba1bea579a965",
                                "destination": "1083",
                                "destination_id": "69090f2e5a7ba1bea579a969",
                                "distance": 16.05
                            },
                            {
                                "origin": "MARATHON -Detroit",
                                "origin_id": "69090ecad6ff2d863efaf07b",
                                "destination": "1082",
                                "destination_id": "69090f2e5a7ba1bea579a965",
                                "distance": 14.37
                            }
                        ],
                        "use_surcharge": True,
                        "manual": False,
                        "has_dependency": False,
                        "created_date": None,
                        "requires_approval": False,
                        "requires_approval_reason_code": False,
                        "is_approved": False,
                        "approved_by": None,
                        "approved_date": None,
                        "approved_reason_code": None,
                        "amount_override": None,
                        "rate_override": None,
                        "product_id_override": None,
                        "product_name_override": None,
                        "product_group_override": None,
                        "subtype_override": None,
                        "uom_override": None,
                        "total_override": None,
                        "override_by": None,
                        "override_date": None,
                        "exclude_from_invoice": False,
                        "credit_rebill_metadata": None,
                        "extra_data": {
                            "mileage": 30
                        },
                        "gross_volume": None,
                        "net_volume": None,
                        "bol_date": None,
                        "bol_number": None,
                        "bol_number_override": None,
                        "delivery_date": None
                    }
                ],
                "counterparty_id": "6908f1eab4fcf6a36e6660e1",
                "book_type": "Cost",
                "effective_date_used": "2025-12-30T00:00:00",
                "invoice_group_id": None,
                "invoice_number": None,
                "accessorial_invoice_number": None,
                "new_version_available": False,
                "new_version_total": None,
                "error": None
            },
            "legs": [
                {
                    "origin": "1082",
                    "origin_id": "69090f2e5a7ba1bea579a965",
                    "destination": "1083",
                    "destination_id": "69090f2e5a7ba1bea579a969",
                    "distance": 16.05
                },
                {
                    "origin": "MARATHON -Detroit",
                    "origin_id": "69090ecad6ff2d863efaf07b",
                    "destination": "1082",
                    "destination_id": "69090f2e5a7ba1bea579a965",
                    "distance": 14.37
                }
            ],
            "freight_distance": 30.42,
            "supply_owner_id": "6908f1eab4fcf6a36e6660e1"
        },
        "created_by": "JBerninger",
        "note": None,
        "estimated_load_minutes": 44,
        "total_miles": 35.91836175356,
        "loaded_miles": 30.42233356032,
        "unloaded_miles": 5.49602819324,
        "reference_order_number": None,
        "extra_data": {},
        "tractor": "202",
        "trailer": "1609",
        "po_number": None
    },
    {
        "type": "regular",
        "order_id": "69581c65ee5aaa626ed7ddee",
        "drivers": [],
        "order_number": 1196,
        "order_date": "2026-01-02T19:28:37Z",
        "order_state": "complete",
        "carrier_window_start": None,
        "carrier_window_end": None,
        "carrier_window_start_local": None,
        "carrier_window_end_local": None,
        "carrier_notify_state": "none",
        "load_window_start": "2025-12-31T23:00:00Z",
        "load_window_end": "2026-01-06T23:00:00Z",
        "dispatch_window_start": "2026-01-03T06:00:00Z",
        "dispatch_window_end": "2026-01-03T12:00:00Z",
        "hauler_counterparty_id": "None",
        "hauler_counterparty_name": "",
        "hauler_counterparty_source_id": None,
        "hauler_counterparty_source_system": "",
        "hauled_by_updated_by": None,
        "hauled_by_updated": None,
        "loads": [
            {
                "location_id": "69090ecad6ff2d863efaf084",
                "location_name": "SUNOCO -RIVER ROUGE",
                "location_source_id": "T-38-MI-3030",
                "location_source_system": "PDI",
                "location_type": "Terminal",
                "details": [
                    {
                        "detail_id": "69581c65ee5aaa626ed7dde4",
                        "counterparty_id": "6908f1eab4fcf6a36e6660d9",
                        "counterparty_name": "Sunoco",
                        "counterparty_source_id": "5008",
                        "counterparty_source_system": None,
                        "price_type": "rack",
                        "contract": "",
                        "product_id": "6908f4469257414108faf071",
                        "product_name": "87OCT 10%ETH - SUNOCO",
                        "product_source_id": "FO-87-E10 | SUN",
                        "product_source_system": "PDI",
                        "drop_product_id": "6908f4469257414108faf071",
                        "drop_product_name": "87OCT 10%ETH - SUNOCO",
                        "drop_product_source_id": "FO-87-E10 | SUN",
                        "drop_product_source_system": "PDI",
                        "quantity": 4000,
                        "compartment_index": 0,
                        "blend_code": None,
                        "product_codes": [],
                        "load_number": None
                    },
                    {
                        "detail_id": "69581c65ee5aaa626ed7dde4",
                        "counterparty_id": "6908f1eab4fcf6a36e6660d9",
                        "counterparty_name": "Sunoco",
                        "counterparty_source_id": "5008",
                        "counterparty_source_system": None,
                        "price_type": "rack",
                        "contract": "",
                        "product_id": "6908f4469257414108faf071",
                        "product_name": "87OCT 10%ETH - SUNOCO",
                        "product_source_id": "FO-87-E10 | SUN",
                        "product_source_system": "PDI",
                        "drop_product_id": "6908f4469257414108faf071",
                        "drop_product_name": "87OCT 10%ETH - SUNOCO",
                        "drop_product_source_id": "FO-87-E10 | SUN",
                        "drop_product_source_system": "PDI",
                        "quantity": 6000,
                        "compartment_index": 1,
                        "blend_code": None,
                        "product_codes": [],
                        "load_number": None
                    },
                    {
                        "detail_id": "69581c65ee5aaa626ed7dde5",
                        "counterparty_id": "6908f1eab4fcf6a36e6660d9",
                        "counterparty_name": "Sunoco",
                        "counterparty_source_id": "5008",
                        "counterparty_source_system": None,
                        "price_type": "rack",
                        "contract": "",
                        "product_id": "6908f409b4fcf6a36e6660f3",
                        "product_name": "93OCT 10%ETH - SUNOCO",
                        "product_source_id": "FO-93-E10 | SUN",
                        "product_source_system": "PDI",
                        "drop_product_id": "6908f409b4fcf6a36e6660f3",
                        "drop_product_name": "93OCT 10%ETH - SUNOCO",
                        "drop_product_source_id": "FO-93-E10 | SUN",
                        "drop_product_source_system": "PDI",
                        "quantity": 1000,
                        "compartment_index": 2,
                        "blend_code": None,
                        "product_codes": [],
                        "load_number": None
                    }
                ],
                "eta": None,
                "status": "unset"
            }
        ],
        "drops": [
            {
                "location_id": "69090f2e5a7ba1bea579a965",
                "location_name": "1082",
                "location_source_id": None,
                "location_source_system": "",
                "location_type": "Store",
                "details": [
                    {
                        "detail_id": "69581c65ee5aaa626ed7dde6",
                        "counterparty_id": "",
                        "counterparty_name": "",
                        "counterparty_source_id": None,
                        "counterparty_source_system": None,
                        "product_id": "6908f4469257414108faf071",
                        "product_name": "87OCT 10%ETH - SUNOCO",
                        "product_source_id": "FO-87-E10 | SUN",
                        "product_source_system": "PDI",
                        "quantity": 4000,
                        "tank_id": 1,
                        "sources": [
                            {
                                "compartment_index": 0,
                                "volume": 4000
                            }
                        ],
                        "destination_codes": [],
                        "blend_codes": []
                    }
                ],
                "eta": None,
                "status": "unset"
            },
            {
                "location_id": "69090f2e5a7ba1bea579a969",
                "location_name": "1083",
                "location_source_id": None,
                "location_source_system": "",
                "location_type": "Store",
                "details": [
                    {
                        "detail_id": "69581c65ee5aaa626ed7dde7",
                        "counterparty_id": "",
                        "counterparty_name": "",
                        "counterparty_source_id": None,
                        "counterparty_source_system": None,
                        "product_id": "6908f4469257414108faf071",
                        "product_name": "87OCT 10%ETH - SUNOCO",
                        "product_source_id": "FO-87-E10 | SUN",
                        "product_source_system": "PDI",
                        "quantity": 6000,
                        "tank_id": 3,
                        "sources": [
                            {
                                "compartment_index": 1,
                                "volume": 6000
                            }
                        ],
                        "destination_codes": [],
                        "blend_codes": []
                    },
                    {
                        "detail_id": "69581c65ee5aaa626ed7dde8",
                        "counterparty_id": "",
                        "counterparty_name": "",
                        "counterparty_source_id": None,
                        "counterparty_source_system": None,
                        "product_id": "6908f409b4fcf6a36e6660f3",
                        "product_name": "93OCT 10%ETH - SUNOCO",
                        "product_source_id": "FO-93-E10 | SUN",
                        "product_source_system": "PDI",
                        "quantity": 1000,
                        "tank_id": 1,
                        "sources": [
                            {
                                "compartment_index": 2,
                                "volume": 1000
                            }
                        ],
                        "destination_codes": [],
                        "blend_codes": []
                    }
                ],
                "eta": None,
                "status": "unset"
            }
        ],
        "detours": [],
        "trip_status": "complete",
        "last_change_date": "2026-01-02T19:29:59.497000",
        "market": "Michigan",
        "supply_option": {
            "option": "recommended",
            "carrier_id": None,
            "carrier": None,
            "loaded_miles": 29.655561509392,
            "freight": 0.0324,
            "freight_cost": 0,
            "stops": 3,
            "prices": [
                {
                    "product_name": "87OCT 10%ETH - SUNOCO",
                    "volume": 10000,
                    "components": [
                        {
                            "timezone_data": None,
                            "curve_id": "6945cec2f88ce49ef5fc509c",
                            "price_id": "6955ab1fb816b69ba5c18eca",
                            "terminal_id": "69090ecad6ff2d863efaf084",
                            "terminal": "SUNOCO -RIVER ROUGE",
                            "supplier_id": "6908f1eab4fcf6a36e6660d9",
                            "supplier": "Sunoco",
                            "price_type": "rack",
                            "product_id": "6908f4469257414108faf071",
                            "product": "87OCT 10%ETH - SUNOCO",
                            "supply_owner_id": "6908f1eab4fcf6a36e6660e1",
                            "supply_owner": "Bazco",
                            "price": 1.7556,
                            "contract": "",
                            "volume": 10000,
                            "effective_from": "2025-12-31T23:00:00Z",
                            "effective_to": "2026-01-06T23:00:00Z",
                            "group_id": None,
                            "group_effective_cutover": None,
                            "group_effective_cutover_timezone": None,
                            "group_identifier": None,
                            "group_name": None,
                            "min_constraint": None,
                            "max_constraint": None,
                            "load_number": None,
                            "load_numbers": [],
                            "directive_info": None
                        }
                    ],
                    "product_total": 17556,
                    "blend_code": None
                },
                {
                    "product_name": "93OCT 10%ETH - SUNOCO",
                    "volume": 1000,
                    "components": [
                        {
                            "timezone_data": None,
                            "curve_id": "6945cec2f88ce49ef5fc505a",
                            "price_id": "6955ab1fb816b69ba5c18ea9",
                            "terminal_id": "69090ecad6ff2d863efaf084",
                            "terminal": "SUNOCO -RIVER ROUGE",
                            "supplier_id": "6908f1eab4fcf6a36e6660d9",
                            "supplier": "Sunoco",
                            "price_type": "rack",
                            "product_id": "6908f409b4fcf6a36e6660f3",
                            "product": "93OCT 10%ETH - SUNOCO",
                            "supply_owner_id": "6908f1eab4fcf6a36e6660e1",
                            "supply_owner": "Bazco",
                            "price": 2.8061,
                            "contract": "",
                            "volume": 1000,
                            "effective_from": "2025-12-31T23:00:00Z",
                            "effective_to": "2026-01-06T23:00:00Z",
                            "group_id": None,
                            "group_effective_cutover": None,
                            "group_effective_cutover_timezone": None,
                            "group_identifier": None,
                            "group_name": None,
                            "min_constraint": None,
                            "max_constraint": None,
                            "load_number": None,
                            "load_numbers": [],
                            "directive_info": None
                        }
                    ],
                    "product_total": 2806.1,
                    "blend_code": None
                }
            ],
            "product_total": 20362.1,
            "landed_cost": 20718.5,
            "supply_owner_map": {
                "definitions": [
                    {
                        "location_name": "1082",
                        "product": "87OCT 10%ETH - SUNOCO",
                        "supply_owner_id": "6908f1eab4fcf6a36e6660e1"
                    },
                    {
                        "location_name": "1083",
                        "product": "87OCT 10%ETH - SUNOCO",
                        "supply_owner_id": "6908f1eab4fcf6a36e6660e1"
                    },
                    {
                        "location_name": "1083",
                        "product": "93OCT 10%ETH - SUNOCO",
                        "supply_owner_id": "6908f1eab4fcf6a36e6660e1"
                    }
                ]
            },
            "freight_customer_id": "6908f1eab4fcf6a36e6660e1",
            "delivered": False,
            "out_of_network": False,
            "estimated_freight": {
                "id": "69581c65ee5aaa626ed7ddec",
                "parent": None,
                "created_at": "2026-01-02T19:28:37.447000",
                "type": "freight",
                "status": "open",
                "reversed": False,
                "transactions": [
                    {
                        "model_type": "base",
                        "type": "Base Freight",
                        "subtype": "Band 26-30",
                        "rate": 0.0324,
                        "amount": 4000,
                        "total": 129.6,
                        "uom": "gallons",
                        "errors": [],
                        "id": "69581c65ee5aaa626ed7dde9",
                        "product_group": "Gasoline",
                        "product_id": "6908f4469257414108faf071",
                        "product_name": "87OCT 10%ETH - SUNOCO",
                        "origin": "SUNOCO -RIVER ROUGE",
                        "origin_id": "69090ecad6ff2d863efaf084",
                        "origin_override": None,
                        "origin_id_override": None,
                        "destination": "1082",
                        "destination_id": "69090f2e5a7ba1bea579a967",
                        "destination_override": None,
                        "destination_id_override": None,
                        "legs": [
                            {
                                "origin": "SUNOCO -RIVER ROUGE",
                                "origin_id": "69090ecad6ff2d863efaf084",
                                "destination": "1082",
                                "destination_id": "69090f2e5a7ba1bea579a965",
                                "distance": 13.6
                            },
                            {
                                "origin": "1082",
                                "origin_id": "69090f2e5a7ba1bea579a965",
                                "destination": "1083",
                                "destination_id": "69090f2e5a7ba1bea579a969",
                                "distance": 16.05
                            }
                        ],
                        "use_surcharge": True,
                        "manual": False,
                        "has_dependency": False,
                        "created_date": None,
                        "requires_approval": False,
                        "requires_approval_reason_code": False,
                        "is_approved": False,
                        "approved_by": None,
                        "approved_date": None,
                        "approved_reason_code": None,
                        "amount_override": None,
                        "rate_override": None,
                        "product_id_override": None,
                        "product_name_override": None,
                        "product_group_override": None,
                        "subtype_override": None,
                        "uom_override": None,
                        "total_override": None,
                        "override_by": None,
                        "override_date": None,
                        "exclude_from_invoice": False,
                        "credit_rebill_metadata": None,
                        "extra_data": {
                            "mileage": 30
                        },
                        "gross_volume": None,
                        "net_volume": None,
                        "bol_date": None,
                        "bol_number": None,
                        "bol_number_override": None,
                        "delivery_date": None
                    },
                    {
                        "model_type": "base",
                        "type": "Base Freight",
                        "subtype": "Band 26-30",
                        "rate": 0.0324,
                        "amount": 6000,
                        "total": 194.4,
                        "uom": "gallons",
                        "errors": [],
                        "id": "69581c65ee5aaa626ed7ddea",
                        "product_group": "Gasoline",
                        "product_id": "6908f4469257414108faf071",
                        "product_name": "87OCT 10%ETH - SUNOCO",
                        "origin": "SUNOCO -RIVER ROUGE",
                        "origin_id": "69090ecad6ff2d863efaf084",
                        "origin_override": None,
                        "origin_id_override": None,
                        "destination": "1083",
                        "destination_id": "69090f2e5a7ba1bea579a96b",
                        "destination_override": None,
                        "destination_id_override": None,
                        "legs": [
                            {
                                "origin": "SUNOCO -RIVER ROUGE",
                                "origin_id": "69090ecad6ff2d863efaf084",
                                "destination": "1082",
                                "destination_id": "69090f2e5a7ba1bea579a965",
                                "distance": 13.6
                            },
                            {
                                "origin": "1082",
                                "origin_id": "69090f2e5a7ba1bea579a965",
                                "destination": "1083",
                                "destination_id": "69090f2e5a7ba1bea579a969",
                                "distance": 16.05
                            }
                        ],
                        "use_surcharge": True,
                        "manual": False,
                        "has_dependency": False,
                        "created_date": None,
                        "requires_approval": False,
                        "requires_approval_reason_code": False,
                        "is_approved": False,
                        "approved_by": None,
                        "approved_date": None,
                        "approved_reason_code": None,
                        "amount_override": None,
                        "rate_override": None,
                        "product_id_override": None,
                        "product_name_override": None,
                        "product_group_override": None,
                        "subtype_override": None,
                        "uom_override": None,
                        "total_override": None,
                        "override_by": None,
                        "override_date": None,
                        "exclude_from_invoice": False,
                        "credit_rebill_metadata": None,
                        "extra_data": {
                            "mileage": 30
                        },
                        "gross_volume": None,
                        "net_volume": None,
                        "bol_date": None,
                        "bol_number": None,
                        "bol_number_override": None,
                        "delivery_date": None
                    },
                    {
                        "model_type": "base",
                        "type": "Base Freight",
                        "subtype": "Band 26-30",
                        "rate": 0.0324,
                        "amount": 1000,
                        "total": 32.4,
                        "uom": "gallons",
                        "errors": [],
                        "id": "69581c65ee5aaa626ed7ddeb",
                        "product_group": "Gasoline",
                        "product_id": "6908f409b4fcf6a36e6660f3",
                        "product_name": "93OCT 10%ETH - SUNOCO",
                        "origin": "SUNOCO -RIVER ROUGE",
                        "origin_id": "69090ecad6ff2d863efaf084",
                        "origin_override": None,
                        "origin_id_override": None,
                        "destination": "1083",
                        "destination_id": "69090f2e5a7ba1bea579a96b",
                        "destination_override": None,
                        "destination_id_override": None,
                        "legs": [
                            {
                                "origin": "SUNOCO -RIVER ROUGE",
                                "origin_id": "69090ecad6ff2d863efaf084",
                                "destination": "1082",
                                "destination_id": "69090f2e5a7ba1bea579a965",
                                "distance": 13.6
                            },
                            {
                                "origin": "1082",
                                "origin_id": "69090f2e5a7ba1bea579a965",
                                "destination": "1083",
                                "destination_id": "69090f2e5a7ba1bea579a969",
                                "distance": 16.05
                            }
                        ],
                        "use_surcharge": True,
                        "manual": False,
                        "has_dependency": False,
                        "created_date": None,
                        "requires_approval": False,
                        "requires_approval_reason_code": False,
                        "is_approved": False,
                        "approved_by": None,
                        "approved_date": None,
                        "approved_reason_code": None,
                        "amount_override": None,
                        "rate_override": None,
                        "product_id_override": None,
                        "product_name_override": None,
                        "product_group_override": None,
                        "subtype_override": None,
                        "uom_override": None,
                        "total_override": None,
                        "override_by": None,
                        "override_date": None,
                        "exclude_from_invoice": False,
                        "credit_rebill_metadata": None,
                        "extra_data": {
                            "mileage": 30
                        },
                        "gross_volume": None,
                        "net_volume": None,
                        "bol_date": None,
                        "bol_number": None,
                        "bol_number_override": None,
                        "delivery_date": None
                    }
                ],
                "counterparty_id": "6908f1eab4fcf6a36e6660e1",
                "book_type": "Cost",
                "effective_date_used": "2026-01-03T00:00:00",
                "invoice_group_id": None,
                "invoice_number": None,
                "accessorial_invoice_number": None,
                "new_version_available": False,
                "new_version_total": None,
                "error": None
            },
            "legs": [
                {
                    "origin": "SUNOCO -RIVER ROUGE",
                    "origin_id": "69090ecad6ff2d863efaf084",
                    "destination": "1082",
                    "destination_id": "69090f2e5a7ba1bea579a965",
                    "distance": 13.6
                },
                {
                    "origin": "1082",
                    "origin_id": "69090f2e5a7ba1bea579a965",
                    "destination": "1083",
                    "destination_id": "69090f2e5a7ba1bea579a969",
                    "distance": 16.05
                }
            ],
            "freight_distance": 29.65,
            "supply_owner_id": "6908f1eab4fcf6a36e6660e1"
        },
        "created_by": "felipe.bucheli",
        "note": None,
        "estimated_load_minutes": 43,
        "total_miles": 29.655561509392,
        "loaded_miles": 29.655561509392,
        "unloaded_miles": 0,
        "reference_order_number": None,
        "extra_data": {},
        "tractor": None,
        "trailer": None,
        "po_number": None
    }
]


def create_mock_sd_client() -> GravitateSDAPI:
    mock = MagicMock(spec=GravitateSDAPI)
    mock.get_bols_and_drops = AsyncMock(return_value=_mock_response(mock_bols_and_drops_response))
    mock.get_orders = AsyncMock(return_value=_mock_response(mock_get_orders_response))
    return mock


def _mock_response(json_data) -> MagicMock:
    """Create a mock httpx Response."""
    response = MagicMock(spec=Response)
    response.status_code = 200
    response.json.return_value = json_data
    response.raise_for_status = MagicMock()
    return response


if __name__ == "__main__":
    @hatch_eggs
    async def main(sd_client:GravitateSDAPI = Egg(create_mock_sd_client)):
        results = await AllocationMatcher.match_order_numbers([1103, 1196], sd_client)
        print(f"Matched {len(results)} allocations:\n")
        for r in results:
            print(f'Order Number: {r.order_number}')
            print(f"Store {r.allocated_bol.store_number}, Tank {r.allocated_bol.store_tank}")
            print(f"  Product: {r.allocated_bol.store_product}")
            print(f"  Planned: {r.planned_quantity} gal")
            print(f"  Actual:  {r.actual_quantity} gal")
            print(f"  Variance: {r.variance:+d} gal ({r.variance_pct:.2f}%)")
            print()


    asyncio.run(main())
