Module:AutoUpdateManfPrices: Difference between revisions

From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs)
No edit summary
NewZimiaGov (talk | contribs)
No edit summary
Line 497: Line 497:
{"Baicha Aircraft Component Crate", "Baicha Heavy Industries", 0.145, "crates"},
{"Baicha Aircraft Component Crate", "Baicha Heavy Industries", 0.145, "crates"},
{"Baicha Field Maintenance Parts Pallet", "Baicha Heavy Industries", 0.420, "pallets"},
{"Baicha Field Maintenance Parts Pallet", "Baicha Heavy Industries", 0.420, "pallets"},


---------------------------------------------------------
---------------------------------------------------------
Line 513: Line 514:
{"Mechazawa Passenger Deck Module", "Mechazawa Shipbuilding Group", 0.090, "modules"},
{"Mechazawa Passenger Deck Module", "Mechazawa Shipbuilding Group", 0.090, "modules"},
{"Mechazawa Marine Engine Mount Set", "Mechazawa Shipbuilding Group", 0.160, "sets"},
{"Mechazawa Marine Engine Mount Set", "Mechazawa Shipbuilding Group", 0.160, "sets"},
---------------------------------------------------------
-- Southern Strait Partner Company
-- Thyrsa Maena Harbor Cooperative
---------------------------------------------------------
{"Saruq Ferry Mat Rolls", "Thyrsa Maena Harbor Cooperative", 0.42, "rolls"},
{"Saruq Cargo-Padding Panels", "Thyrsa Maena Harbor Cooperative", 0.55, "panels"},
{"Saruq Rope Backing Strips", "Thyrsa Maena Harbor Cooperative", 0.36, "bundles"},
{"Saruq Warehouse Thatch Sheets", "Thyrsa Maena Harbor Cooperative", 0.48, "sheets"},
{"Saruq Crate-Lining Bundles", "Thyrsa Maena Harbor Cooperative", 0.32, "bundles"},
{"Reed Cargo Sleeve Sets", "Thyrsa Maena Harbor Cooperative", 0.44, "sets"},
{"Cane-Fiber Dock Twine", "Thyrsa Maena Harbor Cooperative", 0.28, "coils"},
{"Ferry Shelter Floor Mats", "Thyrsa Maena Harbor Cooperative", 0.62, "mats"},
{"Quay Stall Reed Screens", "Thyrsa Maena Harbor Cooperative", 0.40, "screens"},
{"Low-Cost Reed Partition Panels", "Thyrsa Maena Harbor Cooperative", 0.58, "panels"},
}
}


Line 563: Line 581:
["Fanghorn Highland Gas Company"] = "Fanghorn",
["Fanghorn Highland Gas Company"] = "Fanghorn",
["Gadial Oil"] = "Storesund",
["Gadial Oil"] = "Storesund",
["Thyrsa Maena Harbor Cooperative"] = "Saruq Thyrsa",


---------------------------------------------------------
---------------------------------------------------------

Revision as of 01:52, 16 June 2026

Documentation for this module may be created at Module:AutoUpdateManfPrices/doc

---------------------------------------------------------
-- Module:AutoUpdateManfPrices
-- Generates a daily-updated manufacturing-sector product table
-- + optional single-day line graph for price differences.
--
-- CITY-SIGNAL UPGRADE (Jan 2026):
--  • Prices are influenced by:
--      - Module:BassaridiaForecast (weather + ops impacts)
--      - Module:WarLeagueDivisionOpsBVR (tempo proxy + posture)
--      - Module:HatchMinistryDailyOps (tempo proxy)
--      - Module:BassaridiaOutbreaks (public health severity)
--      - Temple Bank modeled stabilizer/friction (category-aware)
--  • City signals apply based on company HQ city mapping.
--
-- NEW (Dec 2025) features retained from original module:
--  • Condensed display (Tier I headline) + collapsible full breakdown
--  • Δ symbol column (↑ Low / ↓ High / • Standard)
--  • Modes so editors can force full expanded output when updating
--
-- Usage:
--   {{#invoke:AutoUpdateManfPrices|generateTable}}
--     - default: summary + collapsed breakdown
--   {{#invoke:AutoUpdateManfPrices|generateTable|mode=summary}}
--     - summary only
--   {{#invoke:AutoUpdateManfPrices|generateTable|mode=breakdown}}
--     - breakdown only (collapsed by default)
--   {{#invoke:AutoUpdateManfPrices|generateTable|mode=breakdown|collapse=no}}
--     - breakdown only (expanded)
--   {{#invoke:AutoUpdateManfPrices|full}}
--     - breakdown only (expanded) convenience function
--
-- Optional chart:
--   {{#invoke:AutoUpdateManfPrices|generateSingleDayLineGraph}}
---------------------------------------------------------
local p = {}

---------------------------------------------------------
-- 1) getCurrentDate
---------------------------------------------------------
local function getCurrentDate()
	local startDate = os.time({ year = 1999, month = 8, day = 6 })
	local secondsInDay = 86400
	local daysPerYear = 183
	local currentDate = os.time()
	local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay)
	local yearFraction = totalDaysElapsed / daysPerYear
	local psscYear = math.floor(yearFraction)
	local dayOfYear = math.floor((yearFraction - psscYear) * daysPerYear) + 1

	local month, dayOfMonth
	if dayOfYear <= 61 then
		month = 1
		dayOfMonth = dayOfYear
	elseif dayOfYear <= 122 then
		month = 2
		dayOfMonth = dayOfYear - 61
	else
		month = 3
		dayOfMonth = dayOfYear - 122
	end

	local dateString = string.format("%d/%d/%d [[PSSC]]", dayOfMonth, month, psscYear)
	return dateString, dayOfMonth, month, psscYear, dayOfYear
end

---------------------------------------------------------
-- 2) Product Data (UNCHANGED)
---------------------------------------------------------
local products = {
	{"Doryon Rifle 7.62×39mm", "Baratar Corporation", 3.15, "units"},
	{"Skopion Sniper Rifle 8.6mm with 5x Scope", "Baratar Corporation", 0.45, "units"},
	{"Lykastos Pistol 9mm Swampproof", "Baratar Corporation", 3.90, "units"},
	{"Kleisthenes Carbine 5.45mm Folding Stock", "Baratar Corporation", 2.25, "units"},
	{"Sphex SMG 5.7mm Short Barrel", "Baratar Corporation", 0.27, "units"},
	{"Orontes Shotgun 12-Gauge Semi-Auto", "Baratar Corporation", 1.10, "units"},
	{"Phokion Sidearm 10mm Officer Issue", "Baratar Corporation", 1.75, "units"},
	{"Aurean Carbine 6.5mm Compact", "Baratar Corporation", 2.70, "units"},
	{"Thorakitai Field Armor Composite-Plated", "Baratar Corporation", 2.40, "kits"},
	{"Cataphract Saddle Harness Reinforced", "Baratar Corporation", 1.85, "sets"},
	{"Xyston Utility Pack 14L Pilgrim Model", "Baratar Corporation", 0.95, "packs"},
	{"Mycale Boots Knee-High Water-Wicking", "Baratar Corporation", 0.75, "pairs"},
	{"Phalanx Scout Cloak Wool Camo", "Baratar Corporation", 1.05, "units"},
	{"Tagmata Bandolier with Incense Chamber", "Baratar Corporation", 0.40, "sets"},
	{"Myrmex 33cm", "Baratar Corporation", 0.15, "bundles"},
	{"Antiope Guard Sash Crimson Embroidered", "Baratar Corporation", 0.22, "bundles"},
	{"Thymiari Signal Kit Reedflare Tricolor", "Baratar Corporation", 0.65, "units"},
	{"Kapnos Horn Beacon Oil-Based Smoke", "Baratar Corporation", 0.30, "devices"},
	{"Myrrhex Grenade Mk.IV Incense Compound", "Baratar Corporation", 0.60, "cases"},
	{"Fanarion Torch Dual Beam Ritual Use", "Baratar Corporation", 0.50, "units"},
	{ "Electricity", "Roving Wind Farm Corporation", 0.064, "megawatts" },
	{ "Electricity (Off-Peak)", "Roving Wind Farm Corporation", 0.058, "megawatts" },
	{ "Electricity (Peak Dispatch)", "Roving Wind Farm Corporation", 0.072, "megawatts" },
	{ "Grid Stabilization (Frequency Response)", "Roving Wind Farm Corporation", 0.090, "contracts" },
	{ "Spinning Reserve (Wind-Backed)", "Roving Wind Farm Corporation", 0.084, "contracts" },
	{ "Renewable Energy Certificates (RECs)", "Roving Wind Farm Corporation", 0.120, "certificates" },
	{ "Microgrid Battery Buffer Service", "Roving Wind Farm Corporation", 0.110, "contracts" },
	{ "Storm Curtailment Credit (Settlement)", "Roving Wind Farm Corporation", 0.030, "credits" },
	{ "Power Quality Smoothing (Industrial)", "Roving Wind Farm Corporation", 0.095, "contracts" },
	{ "Priority Feed-In Agreement (Port Loads)", "Roving Wind Farm Corporation", 0.140, "agreements" },
	{ "Electricity", "Port of Qandra", 0.065, "megawatts" },
	{ "Electricity (Off-Peak)", "Port of Qandra", 0.060, "megawatts" },
	{ "Electricity (Peak)", "Port of Qandra", 0.074, "megawatts" },
	{ "Shore Power Hookups (Vessels)", "Port of Qandra", 0.090, "connections" },
	{ "Grid Connection Capacity (Monthly)", "Port of Qandra", 0.120, "contracts" },
	{ "Backup Generator Dispatch (Emergency)", "Port of Qandra", 0.155, "dispatches" },
	{ "Power Factor Correction Service", "Port of Qandra", 0.088, "contracts" },
	{ "Substation Switching Window", "Port of Qandra", 0.070, "windows" },
	{ "Metering & Load Audit (Industrial)", "Port of Qandra", 0.110, "audits" },
	{ "Priority Port Feed (Guaranteed)", "Port of Qandra", 0.160, "agreements" },
	{ "Electricity", "Bijarian Energy Corporation", 6.783, "megawatts" },
	{ "Electricity (Off-Peak Industrial)", "Bijarian Energy Corporation", 6.250, "megawatts" },
	{ "Electricity (Peak Industrial)", "Bijarian Energy Corporation", 7.450, "megawatts" },
	{ "High-Load Foundry Power Package", "Bijarian Energy Corporation", 8.100, "contracts" },
	{ "Grid Stabilization (Rapid Ramp)", "Bijarian Energy Corporation", 7.950, "contracts" },
	{ "Backup Generation Standby", "Bijarian Energy Corporation", 1.850, "contracts" },
	{ "Transformer Lease (Heavy Duty)", "Bijarian Energy Corporation", 2.200, "leases" },
	{ "Industrial Metering & Telemetry", "Bijarian Energy Corporation", 0.950, "installations" },
	{ "Voltage Regulation Service (Plant)", "Bijarian Energy Corporation", 1.300, "contracts" },
	{ "Emergency Blackstart Capability", "Bijarian Energy Corporation", 3.600, "dispatches" },
	{ "Purple Granite", "Thalassian Temples Granite Export Cooperative", 0.036, "blocks" },
	{ "Purple Granite (Polished Slabs)", "Thalassian Temples Granite Export Cooperative", 0.090, "slabs" },
	{ "Purple Granite (Cut Tiles)", "Thalassian Temples Granite Export Cooperative", 0.055, "crates" },
	{ "Purple Granite (Gravemarker Blanks)", "Thalassian Temples Granite Export Cooperative", 0.060, "units" },
	{ "Purple Granite (Column Drums)", "Thalassian Temples Granite Export Cooperative", 0.110, "columns" },
	{ "Purple Granite Aggregate (Temple Grade)", "Thalassian Temples Granite Export Cooperative", 0.028, "tons" },
	{ "Purple Granite Dust (Stonework)", "Thalassian Temples Granite Export Cooperative", 0.020, "tons" },
	{ "Purple Granite Inlay Pieces", "Thalassian Temples Granite Export Cooperative", 0.045, "sets" },
	{ "Purple Granite Monument Bases", "Thalassian Temples Granite Export Cooperative", 0.130, "bases" },
	{ "Purple Granite Sealstone Tablets", "Thalassian Temples Granite Export Cooperative", 0.075, "tablets" },
	{"Iron", "East Keltian Iron Company", 1.692, "tons"},
	{"Steel", "East Keltian Iron Company", 2.412, "tons"},
	{"Concrete", "East Keltian Iron Company", 6.039, "tons"},
	{ "Coal", "Mylecian Coal Ports", 0.378, "tons" },
	{ "Thermal Coal (Power Grade)", "Mylecian Coal Ports", 0.360, "tons" },
	{ "Metallurgical Coal (Coking)", "Mylecian Coal Ports", 0.520, "tons" },
	{ "Coal Briquettes (Bagged)", "Mylecian Coal Ports", 0.410, "sacks" },
	{ "Washed Coal (Low Ash)", "Mylecian Coal Ports", 0.445, "tons" },
	{ "Coal Screenings (Industrial)", "Mylecian Coal Ports", 0.310, "tons" },
	{ "Charcoal Blend (Smelter Assist)", "Mylecian Coal Ports", 0.460, "tons" },
	{ "Coal Tar (Raw)", "Mylecian Coal Ports", 0.190, "barrels" },
	{ "Coke (Basic Furnace)", "Mylecian Coal Ports", 0.580, "tons" },
	{ "Coal Handling & Bunkering Service", "Mylecian Coal Ports", 0.120, "loads" },
	{ "Diamonds", "Merchants of the Valley of Diamonds", 0.05, "carats" },
	{ "Industrial Diamond Grit", "Merchants of the Valley of Diamonds", 0.04, "carats" },
	{ "Cut Diamonds (Small Stones)", "Merchants of the Valley of Diamonds", 0.09, "carats" },
	{ "Cut Diamonds (Jeweler Grade)", "Merchants of the Valley of Diamonds", 0.14, "carats" },
	{ "Diamond Dust (Polishing)", "Merchants of the Valley of Diamonds", 0.06, "grams" },
	{ "Diamond Saw Blanks", "Merchants of the Valley of Diamonds", 0.11, "pieces" },
	{ "Diamond Drill Tips (Set)", "Merchants of the Valley of Diamonds", 0.08, "sets" },
	{ "Certified Stone Lots (Sealed)", "Merchants of the Valley of Diamonds", 0.22, "lots" },
	{ "Uncut Rough Diamonds (Sorting Batch)", "Merchants of the Valley of Diamonds", 0.07, "carats" },
	{ "Gemstone Appraisal Certificates", "Merchants of the Valley of Diamonds", 0.15, "certificates" },
	{ "Timber", "East Keltian Timber Company", 5.63, "logs" },
	{ "Conifer Lumber (Milled Planks)", "East Keltian Timber Company", 1.10, "planks" },
	{ "Hardwood Beams (Structural)", "East Keltian Timber Company", 2.40, "beams" },
	{ "Plywood Sheets (Marine Grade)", "East Keltian Timber Company", 1.75, "sheets" },
	{ "Treated Pilings (Harbor Use)", "East Keltian Timber Company", 0.95, "meters" },
	{ "Rail Ties (Creosote Treated)", "East Keltian Timber Company", 0.60, "ties" },
	{ "Wood Chips (Pulpstock)", "East Keltian Timber Company", 0.40, "tons" },
	{ "Sawdust (Bulk)", "East Keltian Timber Company", 0.18, "sacks" },
	{ "Firewood (Bundled)", "East Keltian Timber Company", 0.32, "bundles" },
	{ "Joinery-Grade Boards (Kiln-Dried)", "East Keltian Timber Company", 2.10, "crates" },
	{ "Mens' Boots", "Onceanic Boot Company", 2.00, "pairs" },
	{ "Womens' Boots", "Onceanic Boot Company", 3.00, "pairs" },
	{ "Dockside Work Boots (Reinforced)", "Onceanic Boot Company", 2.40, "pairs" },
	{ "Canal Waders (Waterproof)", "Onceanic Boot Company", 3.60, "pairs" },
	{ "Insulated Winter Boots", "Onceanic Boot Company", 3.20, "pairs" },
	{ "Riding Boots (Leather)", "Onceanic Boot Company", 2.90, "pairs" },
	{ "Desert Trek Boots (Breathable)", "Onceanic Boot Company", 2.35, "pairs" },
	{ "Sailor Deck Shoes (Non-Slip)", "Onceanic Boot Company", 1.55, "pairs" },
	{ "Boot Repair Kits (Leather & Rivet)", "Onceanic Boot Company", 0.85, "kits" },
	{ "Rubber Sole Sheets (Replacement)", "Onceanic Boot Company", 0.95, "sheets" },
	{ "Garganram Sign Plains Fertilizer", "Commune of the Garganid Apostles", 0.60, "tons" },
	{ "Garganram Sign Plains Fertilizer (Pelletized)", "Commune of the Garganid Apostles", 0.72, "tons" },
	{ "Compost Blend (Garganram Leaf)", "Commune of the Garganid Apostles", 0.48, "tons" },
	{ "Soil Amendment (Ash & Chitin Mix)", "Commune of the Garganid Apostles", 0.55, "tons" },
	{ "Microbial Inoculant (Field Culture)", "Commune of the Garganid Apostles", 0.90, "kilograms" },
	{ "Seed Starter Mix (Temple Bags)", "Commune of the Garganid Apostles", 0.35, "sacks" },
	{ "Mulch (Compressed Bales)", "Commune of the Garganid Apostles", 0.22, "bales" },
	{ "Irrigation Channel Silt (Topdressing)", "Commune of the Garganid Apostles", 0.20, "tons" },
	{ "Rock Dust (Mineral Recharge)", "Commune of the Garganid Apostles", 0.44, "tons" },
	{ "Terrace Stabilization Mat (Fiber Roll)", "Commune of the Garganid Apostles", 0.38, "rolls" },
	{"Gold Necklaces", "Shï Collective", 0.15, "pieces"},
	{"Gold Rings", "Shï Collective", 0.40, "pieces"},
	{"Gold Bracelets", "Shï Collective", 0.27, "pieces"},
	{"Gold Earrings", "Shï Collective", 0.65, "pairs"},
	{"Robes", "Order of the Sphinx", 1.30, "units"},
	{"Dresses", "Order of the Sphinx", 0.65, "units"},
	{"Tarnkappes", "Order of the Sphinx", 2.10, "cloaks"},
	{"Coats", "Order of the Sphinx", 1.05, "units"},
	{"Perfume", "Market Hanavusu", 0.32, "bottles"},
	{"Cologne", "Market Hanavusu", 0.45, "bottles"},
	{"Incense", "Market Hanavusu", 0.90, "sticks"},
	{"Candles", "Market Hanavusu", 0.73, "pieces"},
	{"Crude Oil", "Federation of North Brabipant", 1.204, "barrels"},
	{"Natural Gas", "Federation of North Brabipant", 0.872, "cubic meters"},
	{"Diesel Fuel", "Federation of North Brabipant", 0.633, "barrels"},
	{"Jet Fuel", "Federation of North Brabipant", 0.587, "barrels"},
	{"Lubricants", "Federation of North Brabipant", 0.419, "liters"},
	{"Bitumen", "Federation of North Brabipant", 0.236, "tons"},
	{"Propane", "Federation of North Brabipant", 0.482, "cubic meters"},
	{"Asphalt Base", "Federation of North Brabipant", 0.329, "tons"},
	{"Shale Oil", "Federation of North Brabipant", 0.278, "barrels"},
	{"Petroleum Coke", "Federation of North Brabipant", 0.315, "tons"},
	{"Industrial Paraffin", "Federation of North Brabipant", 0.298, "tons"},
	{"Refined Gasoline", "Federation of North Brabipant", 0.541, "barrels"},
	{ "Copper", "Copper Mines of Southern Jogi", 3.9, "tons" },
	{ "Copper Ore (Unrefined)", "Copper Mines of Southern Jogi", 2.7, "tons" },
	{ "Copper Concentrate (Washed)", "Copper Mines of Southern Jogi", 3.8, "tons" },
	{ "Copper Ingots (Refined)", "Copper Mines of Southern Jogi", 4.9, "tons" },
	{ "Copper Wire Spools", "Copper Mines of Southern Jogi", 0.96, "spools" },
	{ "Copper Sheet (Rolled)", "Copper Mines of Southern Jogi", 1.70, "sheets" },
	{ "Copper Pipe Sections", "Copper Mines of Southern Jogi", 1.35, "meters" },
	{ "Copper Scrap Bundles", "Copper Mines of Southern Jogi", 0.94, "crates" },
	{ "Bronze Blend (Cu–Sn)", "Copper Mines of Southern Jogi", 4.2, "tons" },
	{ "Cathodic Copper Plates (Industrial)", "Copper Mines of Southern Jogi", 2.1, "plates" },
	{"Gabion Cages", "Southern Strait Preservation Corporation", 0.120, "cages"},
	{"Reinforced Sea-Wall Panels", "Southern Strait Preservation Corporation", 0.84, "panels"},
	{"Pre-Cast Revetment Blocks", "Southern Strait Preservation Corporation", 0.260, "blocks"},
	{"Groyne Construction Kits", "Southern Strait Preservation Corporation", 0.47, "kits"},
	{"Wave Deflection Barriers", "Southern Strait Preservation Corporation", 0.312, "meters"},
	{"Marine-Grade Fasteners", "Southern Strait Preservation Corporation", 0.190, "kg"},
	{"Erosion Control Mesh", "Southern Strait Preservation Corporation", 0.405, "square meters"},
	{"Bio-Engineered Sediment Traps", "Southern Strait Preservation Corporation", 0.68, "units"},
	{"Concrete Armor Units", "Southern Strait Preservation Corporation", 0.785, "tons"},
	{"Tide-Resistant Fill Aggregate", "Southern Strait Preservation Corporation", 0.93, "cubic meters"},
	{"Foundation Piles (treated timber)", "Southern Strait Preservation Corporation", 0.415, "meters"},
	{"Drainage and Filter Matting", "Southern Strait Preservation Corporation", 0.102, "rolls"},
	{ "Timber", "Horned Bear Timber Company", 6.46, "logs" },
	{ "Heavy Conifer Logs (Shipyard Grade)", "Horned Bear Timber Company", 7.10, "logs" },
	{ "Milled Lumber (Harbor Planks)", "Horned Bear Timber Company", 1.30, "planks" },
	{ "Treated Dock Pilings", "Horned Bear Timber Company", 1.10, "meters" },
	{ "Boatbuilding Keel Timbers", "Horned Bear Timber Company", 2.75, "beams" },
	{ "Barrel Staves (Cooperage)", "Horned Bear Timber Company", 0.95, "crates" },
	{ "Resin-Rich Kindling Bundles", "Horned Bear Timber Company", 0.40, "bundles" },
	{ "Wood Tar (Kiln Batch)", "Horned Bear Timber Company", 0.22, "barrels" },
	{ "Sawmill Offcuts (Bulk)", "Horned Bear Timber Company", 0.30, "tons" },
	{ "Joinery Boards (Premium)", "Horned Bear Timber Company", 2.40, "crates" },
	{"VX-7 Circuit Board", "Vortelin Electronics", 0.88, "units"},
	{"HydraLink Router", "Vortelin Electronics", 1.32, "units"},
	{"Vortex Transistor Pack", "Vortelin Electronics", 0.41, "packs"},
	{"Redline Fiber Cable", "Vortelin Electronics", 0.29, "meters"},
	{"Smart Power Converters", "Vortelin Electronics", 1.74, "units"},
	{"Silicon Boards", "Vortelin Electronics", 0.62, "slabs"},
	{"Compact Signal Relay", "Vortelin Electronics", 0.55, "units"},
	{"CobraSeries Fuse Array", "Vortelin Electronics", 0.17, "units"},
	{"LumenTrack LED Driver", "Vortelin Electronics", 0.38, "units"},
	{"Verdant Power Cell", "Vortelin Electronics", 3.13, "cells"},
	{"Basic Sensor Module", "Vortelin Electronics", 0.46, "units"},
	{"Electromechanical Timer", "Vortelin Electronics", 0.63, "units"},
	{"Stabilizer Adapter", "Vortelin Electronics", 0.91, "units"},
	{"Basic Radio Kit", "Vortelin Electronics", 2.35, "kits"},
	{"Circuit Training Kit", "Vortelin Electronics", 2.70, "kits"},
	{"Torchleaf Raw Rubber", "Thyrsiad Rubber Company", 0.84, "blocks"},
	{"Refined Desert Rubber", "Thyrsiad Rubber Company", 1.27, "rolls"},
	{"Rubber Tubing", "Thyrsiad Rubber Company", 0.44, "meters"},
	{"Insulated Wire Sheath", "Thyrsiad Rubber Company", 0.38, "meters"},
	{"Anti-Vibration Mounts", "Thyrsiad Rubber Company", 0.71, "units"},
	{"Thyrsian Sole Sheets", "Thyrsiad Rubber Company", 1.12, "sheets"},
	{"High-Tensile Belting", "Thyrsiad Rubber Company", 2.15, "meters"},
	{"Waterproof Seals", "Thyrsiad Rubber Company", 0.96, "units"},
	{"Torchflex Gaskets", "Thyrsiad Rubber Company", 0.52, "units"},
	{"Elastic Fasteners", "Thyrsiad Rubber Company", 0.19, "bundles"},
	{"Vehicle Tyres", "Thyrsiad Rubber Company", 4.67, "units"},
	{"Artisan Rubber Mats", "Thyrsiad Rubber Company", 1.63, "sheets"},
	{"Industrial Hose", "Thyrsiad Rubber Company", 2.94, "meters"},
	{"Medical-Grade Latex", "Thyrsiad Rubber Company", 3.85, "liters"},
	{"Vulcanized Panels", "Thyrsiad Rubber Company", 2.30, "panels"},
	{"Crude Stygium Ore", "Stygium Mines of Acheron", 0.95, "kg"},
	{"Washed Stygium Ore", "Stygium Mines of Acheron", 1.10, "kg"},
	{"Bloom-Grade Ore (Select Vein)", "Stygium Mines of Acheron", 1.35, "kg"},
	{"Black Bloom Resin (Cold-Pressed)", "Stygium Mines of Acheron", 1.85, "kg"},
	{"Thermo-Activated Resin Slab", "Stygium Mines of Acheron", 2.10, "kg"},
	{"Pulverized Bloom Concentrate", "Stygium Mines of Acheron", 1.60, "kg"},
	{"Deep Vein Extract (Stabilized)", "Stygium Mines of Acheron", 2.75, "kg"},
	{"Bloom Dust (Industrial Grade)", "Stygium Mines of Acheron", 1.45, "kg"},
	{"Stygium Slurry (Moist)", "Stygium Mines of Acheron", 1.55, "kg"},
	{"Bloom-Rabrev Composite Ore", "Stygium Mines of Acheron", 2.40, "kg"},
	{"Resin Cake (Compressed Transport)", "Stygium Mines of Acheron", 1.70, "kg"},
	{"Bloom Suspension (Neutral Carrier)", "Stygium Mines of Acheron", 1.90, "kg"},
	{"Crystal Fracture Shards", "Stygium Mines of Acheron", 2.05, "kg"},
	{"Raw Amber", "Amber Ports of Slevik", 3.842, "kilograms"},
	{"Polished Amber", "Amber Ports of Slevik", 1.475, "kilograms"},
	{"Amber Beads", "Amber Ports of Slevik", 0.982, "strands"},
	{"Amber Necklaces", "Amber Ports of Slevik", 0.36, "pieces"},
	{"Amber Rings", "Amber Ports of Slevik", 0.72, "pieces"},
	{"Amber Bracelets", "Amber Ports of Slevik", 0.53, "pieces"},
	{"Amber Earrings", "Amber Ports of Slevik", 1.10, "pairs"},
	{"Amber Brooches", "Amber Ports of Slevik", 0.41, "pieces"},
	{"Amber Talismans", "Amber Ports of Slevik", 0.66, "pieces"},
	{"Amber Inlay", "Amber Ports of Slevik", 0.27, "tiles"},
	{"Amber Figurines", "Amber Ports of Slevik", 0.15, "statues"},
	{"Amber-Resin Oil", "Amber Ports of Slevik", 0.85, "bottles"},
	{"Eirenarch X Executive Sedan", "Eosphorus Motor Company", 0.42, "units"},
	{"Phoræ Vento Urban EV", "Eosphorus Motor Company", 0.79, "units"},
	{"Aureline Astra Family Sedan", "Eosphorus Motor Company", 0.55, "units"},
	{"Velatrix Solara Performance Coupe", "Eosphorus Motor Company", 0.21, "units"},
	{"Kybele Nomad Terrain Wagon", "Eosphorus Motor Company", 0.37, "units"},
	{"Lucernae LX Canal Convertible", "Eosphorus Motor Company", 0.12, "units"},
	{"Oros Lynceum Crossover SUV", "Eosphorus Motor Company", 0.64, "units"},
	{"Mornia Vox Micro EV", "Eosphorus Motor Company", 0.110, "units"},
	{"Aulos Estate Touring Wagon", "Eosphorus Motor Company", 0.40, "units"},
	{"Helioris Family Minivan", "Eosphorus Motor Company", 0.28, "units"},
	{"Aurelia Utility Pick-up", "Eosphorus Motor Company", 0.38, "units"},
	{"Class D-92 Morovia Standard", "Eosphorus Motor Company", 0.0175, "units"},
	{"Class LX-77 Lucernae Royal", "Eosphorus Motor Company", 0.0075, "units"},
	{"Class H-55 Historiatouria", "Eosphorus Motor Company", 0.0210, "units"},
	{"Model CV-19 Atosian Vault Hauler", "Eosphorus Motor Company", 0.0038, "units"},
	{"Model F-31 Stripping Hauler", "Eosphorus Motor Company", 0.0070, "units"},
	{"Model K-04 Courier Starline", "Eosphorus Motor Company", 0.0105, "units"},
	{"Model CT-66 Coalborn Tender", "Eosphorus Motor Company", 0.0084, "units"},
	{"Model Z-7 Secutor Diplomatic Line", "Eosphorus Motor Company", 0.0060, "units"},
	{"Model TM-5 Tetragram Enclave", "Eosphorus Motor Company", 0.0050, "units"},
	{"Model PR-1 Adlet Ironhowl", "Eosphorus Motor Company", 0.0042, "units"},
	{"Model A-03 Bannerwagon", "Eosphorus Motor Company", 0.0140, "units"},
	{"Model V-99 Thunderguard Citadel Train", "Eosphorus Motor Company", 0.00024706, "units"},
	{"Class LZ-51 Luminaria Dawnsail", "Eosphorus Motor Company", 0.0068, "units"},
	{"Class PZ-32 Pilgrim Skycaravan", "Eosphorus Motor Company", 0.0072, "units"},
	{"Class CN-40 Canyon Aurora", "Eosphorus Motor Company", 0.0045, "units"},
	{"Class HZ-44 Highland Warden", "Eosphorus Motor Company", 0.0048, "units"},
	{"Class CZ-38 Coastal Zephyr", "Eosphorus Motor Company", 0.0054, "units"},
	{"Class DZ-77 Dawn Concord Diplomatic Line", "Eosphorus Motor Company", 0.0036, "units"},
	{"Class FZ-61 Ferrum Loadbearer", "Eosphorus Motor Company", 0.0040, "units"},
    {"Class SZ-88 Somniant Bastion", "Eosphorus Motor Company", 0.0014, "units"},
	{"Class MZ-19 Courier Nimbus", "Eosphorus Motor Company", 0.0050, "units"},
	{"Kalithros Class Rifle", "Somniant Stock Fund", 0.83, "units"},
	{"Delphica Class Grenadier Rifle", "Somniant Stock Fund", 0.249, "units"},
	{"Chrysos Class Commando Rifle", "Somniant Stock Fund", 0.124, "units"},
	{"Lothaya Class Sniper Rifle", "Somniant Stock Fund", 0.0332, "units"},
	{"Erythros Class Pistol", "Somniant Stock Fund", 0.166, "units"},
	{"Bubalus XT Class Revolver", "Somniant Stock Fund", 0.95, "units"},
	{"Cathartes Class RPG", "Somniant Stock Fund", 0.03, "units"},
	{"Harpyia Class Submachine Gun", "Somniant Stock Fund", 0.125, "units"},
	{"Strix Class Combat Shotgun", "Somniant Stock Fund", 0.22, "units"},
	{"Regavis Class DMR", "Somniant Stock Fund", 0.27, "units"},
	{"Aithra Class Howitzer", "Somniant Stock Fund", 0.00170, "units"},
	{"Aetheris Class Towed Howitzer", "Somniant Stock Fund", 0.00490, "units"},
	{"Iynas Class Field Gun", "Somniant Stock Fund", 0.00420, "units"},
	{"300mm Secutor Class Coastal Guns", "Somniant Stock Fund", 0.0033, "guns"},
	{"155mm Halicarn Class Self-Propelled Howitzer", "Somniant Stock Fund", 0.0025, "units"},
	{"120mm Odiferian Class Mortar Carrier", "Somniant Stock Fund", 0.00160, "units"},
	{"Quadwalker \"Horehound\" 4170", "Somniant Stock Fund", 0.0028, "units"},
	{"Quadwalker \"Dungbeetle\" 4172", "Somniant Stock Fund", 0.0020, "units"},
	{"Quadwalker \"Killbot\" 4200", "Somniant Stock Fund", 0.0041, "units"},
	{"Quadwalker \"Oble-Lisea\" 4189", "Somniant Stock Fund", 0.0034, "units"},
	{"Nexa Class Advanced Prototype", "Somniant Stock Fund", 0.0067, "units"},
	{"Gargani Class Quadwalker", "Somniant Stock Fund", 0.0039, "units"},
	{"Makra Class Battle Tank", "Somniant Stock Fund", 0.0083, "units"},
	{"Laya Class Heavy Tank", "Somniant Stock Fund", 0.0033, "units"},
	{"Arachne Class Light Tank", "Somniant Stock Fund", 0.0099, "units"},
	{"Thalassa Class Main Battle Tank", "Somniant Stock Fund", 0.0050, "units"},
	{"Syrinx Class Armored Infantry", "Somniant Stock Fund", 0.049, "squads"},
	{"Bijarian Command Vehicle", "Somniant Stock Fund", 0.00083, "units"},
	{"Onceanic Recon Vehicle", "Somniant Stock Fund", 0.00249, "units"},
	{"Ephyra Class Anti-Aircraft Vehicle", "Somniant Stock Fund", 0.00120, "units"},
	{"Ampelos Class Armored Recovery Vehicle", "Somniant Stock Fund", 0.0031, "systems"},
	{"Penthia Class Bridge-Laying Vehicle", "Somniant Stock Fund", 0.0008, "systems"},
	{"Ampelos Class Rail-Laying Engineering Vehicle", "Somniant Stock Fund", 0.0021, "systems"},
	{"Corythia Class Dedicated Logistics and Transport Truck", "Somniant Stock Fund", 0.0019, "systems"},
	{"Icaria Class Mine-Clearing / Combat Engineering Vehicle", "Somniant Stock Fund", 0.00095, "systems"},
	{"Aiji Class Air-Caravan", "Somniant Stock Fund", 0.00013, "ships"},
	{"Kalithros-Class Amphibious Airstrip Barge", "Somniant Stock Fund", 0.00021, "ships"},
	{"Sideron Class Coastal Battlecruiser", "Somniant Stock Fund", 0.00019, "ships"},
	{"Eidolon Class Cruiser", "Somniant Stock Fund", 0.00020, "ships"},
	{"Vaeringheim Class Corvette", "Somniant Stock Fund", 0.00050, "ships"},
	{"Sylvapolis Class Frigate", "Somniant Stock Fund", 0.00032, "ships"},
	{"Aetherium Class Patrol Ship", "Somniant Stock Fund", 0.00058, "ships"},
	{"Atterian Class Combat Ship", "Somniant Stock Fund", 0.00016, "ships"},
	{"Xylanda Class Attack Submarine", "Somniant Stock Fund", 0.00025, "ships"},
	{"Acheron Class Submersible Destroyer", "Somniant Stock Fund", 0.00016, "ships"},
	{"Bijarian Ballistic Missile Submarine", "Somniant Stock Fund", 0.00012, "ships"},
	{"Velkara Class Littoral Landing Ship", "Somniant Stock Fund", 0.00026, "ships"},
	{"Saluria Class Gunboat", "Somniant Stock Fund", 0.00041, "ships"},
	{"Cetus Class Attack Craft", "Somniant Stock Fund", 0.00050, "ships"},
	{"Odobenus Class Minelayer", "Somniant Stock Fund", 0.0003, "ships"},
	{"Cetomagna Class Minehunter", "Somniant Stock Fund", 0.0003, "ships"},
	{"Aithra Class Proximity Aircraft", "Somniant Stock Fund", 0.00083, "aircraft"},
	{"Orphali Class Tanker Aircraft", "Somniant Stock Fund", 0.00044, "aircraft"},
	{"Ventiflor Eye Class AEW&C Aircraft", "Somniant Stock Fund", 0.00019, "aircraft"},
	{"Fluxus Class Maritime Patrol Aircraft", "Somniant Stock Fund", 0.00063, "aircraft"},
	{"Hostica Class Maritime Patrol Aircraft", "Somniant Stock Fund", 0.00071, "aircraft"},
	{"Chrysos Class Sea Bomber", "Somniant Stock Fund", 0.00166, "aircraft"},
	{"Misttalon Class Heavy Bomber", "Somniant Stock Fund", 0.00025, "aircraft"},
	{"Symphonara Class Compound Intercept", "Somniant Stock Fund", 0.00066, "aircraft"},
	{"Nefelian Transport Plane", "Somniant Stock Fund", 0.00083, "aircraft"},
	{"Noctiluna Class Medium Transport Helicopter", "Somniant Stock Fund", 0.0010, "aircraft"},
	{"Umbraclaw Class Heavy Transport Helicopter", "Somniant Stock Fund", 0.00089, "aircraft"},
	{"Thalassa Class Attack Helicopter", "Somniant Stock Fund", 0.00130, "aircraft"},
	{"Catonis Class Unmanned Aircraft", "Somniant Stock Fund", 0.00083, "aircraft"},
	{"Lotos Class Tactical UAV", "Somniant Stock Fund", 0.00087, "aircraft"},
	{"Aurantius Class Multi-Role UAV", "Somniant Stock Fund", 0.00091, "aircraft"},
	{"Abeis Class Advanced Air Defense System", "Somniant Stock Fund", 0.0012, "units"},
	{"Abeis Class Static Emplacement", "Somniant Stock Fund", 0.00075, "emplacements"},
	{"Abeis-Empress Class Littoral Battlecruiser", "Somniant Stock Fund", 0.00022, "ships"},
	{"Abeis-Erigone Class Littoral Orbital & Missile Intercept Catamaran", "Somniant Stock Fund", 0.00017, "ships"},
	{"Abeis-Minerva Class Combat Littoral Strike Aircraft", "Somniant Stock Fund", 0.00051, "aircraft"},
	{"Abeis-Osiríos Class CAS Gunship", "Somniant Stock Fund", 0.00096, "aircraft"},
	{"Abeis-Boreas Littoral Dominance Helicopter", "Somniant Stock Fund", 0.00085, "aircraft"},
	{"Abeis-Bulhanu Class High-Speed Skirmisher", "Somniant Stock Fund", 0.0068, "units"},
	{"Abeis-Bulhanu Khamsin-Class Desert Skirmisher", "Somniant Stock Fund", 0.0059, "units"},
	{"Abeis-Bulhanu Virelia-Class Urban Pacifier", "Somniant Stock Fund", 0.0042, "units"},
	{"Abeis-Hrimthurs Class Arctic Hoverbike", "Somniant Stock Fund", 0.0051, "units"},
	{"Abeis-Ismael Class “Cathartes” Littoral Hoverbike", "Somniant Stock Fund", 0.0057, "units"},
	{"Abeis-Empress Class “Strix-E” Swarm-Interdictor Hoverbike", "Somniant Stock Fund", 0.0048, "units"},
	{"Anguilla Class Coastal Missile Battery", "Somniant Stock Fund", 0.0022, "batteries"},
	{"Abeis-Aetherion Class Multidomain Hover-Corvette", "Somniant Stock Fund", 0.000022, "batteries"},
	{"White Granite", "Trans-Rodinian Granite Agency", 4.215, "blocks"},
	{"Polished Granite Tiles", "Trans-Rodinian Granite Agency", 1.782, "crates"},
	{"Granite Dust", "Trans-Rodinian Granite Agency", 0.540, "tons"},
	{"Sculptor’s-Grade Granite", "Trans-Rodinian Granite Agency", 0.095, "blocks"},
	{"Reinforced Stone Slabs", "Trans-Rodinian Granite Agency", 2.417, "panels"},
	{"Ornamental Stone Inlays", "Trans-Rodinian Granite Agency", 0.222, "sets"},
	{"Fire-Resistant Stone Mix", "Trans-Rodinian Granite Agency", 3.006, "tons"},
	{"Gravemarkers", "Trans-Rodinian Granite Agency", 0.315, "units"},
	{"Granite Pillars", "Trans-Rodinian Granite Agency", 1.104, "columns"},
	{"Silver Ore (Kralian Sourced)", "Port of Corumia", 0.76, "bars"},
	{"Fragrance Resin Base (Asee Extract)", "Port of Corumia", 49.30, "ampoules"},
	{"Sevid-Fiota Rope Fibers", "Port of Corumia", 24.20, "bundles"},
	{"Twine Material (Unprocessed)", "Port of Corumia", 58.5, "rolls"},
	{"Raw String Material", "Port of Corumia", 72.30, "rolls"},
	{"Rope", "Port of Corumia", 23.90, "bundles"},
	{"String", "Port of Corumia", 70.0, "rolls"},
	{"Indigo Dye Cakes (Pressed)", "Port of Corumia", 15.60, "cakes"},
	{"Ceramic Amphorae (Export-Grade)", "Port of Corumia", 3.42, "units"},
	{"Pitch & Naval Tar", "Port of Corumia", 14.30, "casks"},
	{"Braxian crafted Biolume Resin Drop Earrings", "Port of Corumia", 0.87, "pairs"},
	{"Braxian crafted Cave-Amber Choker (indigo-dyed cord)", "Port of Corumia", 0.52, "pieces"},
	{"Braxian crafted Kralian-Silver Spiral Armlet", "Port of Corumia", 0.29, "pieces"},
	{"Braxian crafted Bijeko-Lisea-Nas Fang Pendant (silver mount)", "Port of Corumia", 0.49, "pieces"},
	{"Braxian crafted Fa-Hial-Irf Wingcase Brooch (insect relief)", "Port of Corumia", 0.34, "pieces"},
	{"Arctic Hematite Ore 64% Fe", "Thesean Iron Exports", 1.85, "tons"},
	{"Magnetite Concentrate 68% Fe", "Thesean Iron Exports", 1.40, "tons"},
	{"Sinter Fines Low-P 0.04%", "Thesean Iron Exports", 1.22, "tons"},
	{"Direct-Reduced Iron (Hot Briquetted)", "Thesean Iron Exports", 0.78, "tons"},
	{"Pig Iron Ingots Arctic Furnace", "Thesean Iron Exports", 0.96, "tons"},
	{"Ritual-Grade Iron Ingots (Leng Rite)", "Thesean Iron Exports", 0.33, "bars"},
	{"Rail Bloom Stock 250×250 mm", "Thesean Iron Exports", 0.71, "tons"},
	{"Field-Forged Rebar Bundles", "Thesean Iron Exports", 0.44, "bundles"},
	{"Cold-Rolled Sheet Coil", "Thesean Iron Exports", 0.59, "tons"},
	{"Forged Tool-Steel Billets", "Thesean Iron Exports", 0.27, "billets"},
	{"Natural Gas (Fanghorn Highland) [Pipeline]", "Fanghorn Highland Gas Company", 0.910, "thousand m³"},
	{"Natural Gas (Fanghorn Highland) [Compressed]", "Fanghorn Highland Gas Company", 0.975, "thousand m³"},
	{"Bottled LPG Cooking Cylinders", "Fanghorn Highland Gas Company", 3.40, "cylinders"},
	{"Highland Winter Heating Gas", "Fanghorn Highland Gas Company", 1.290, "thousand m³"},
	{"Industrial Process Gas (Refineries & Kilns)", "Fanghorn Highland Gas Company", 1.825, "thousand m³"},
	{"Peak-Load Power Plant Supply Contracts", "Fanghorn Highland Gas Company", 0.85, "contracts"},
	{"Refrigerated LNG Bunker Fuel (Lake Vessels)", "Fanghorn Highland Gas Company", 2.160, "tons"},
	{"Compressed Vehicle Gas (CNG) Refills", "Fanghorn Highland Gas Company", 2.10, "refills"},
	{"Remote Highlands Household Supply Packages", "Fanghorn Highland Gas Company", 4.75, "households"},
	{"Emergency Cold-Season Reserve Gas", "Fanghorn Highland Gas Company", 1.35, "contracts"},
	{"Crude Oil (Gulf of Elijah Blend)", "Gadial Oil", 1.218, "barrels"},
	{"Crude Oil (Storesund Coldwater Blend)", "Gadial Oil", 1.146, "barrels"},
	{"Condensate (Light Stabilized)", "Gadial Oil", 0.932, "barrels"},
	{"Natural Gas (Pipeline Grade)", "Gadial Oil", 0.864, "cubic meters"},
	{"Export LNG (Cryogenic Load)", "Gadial Oil", 2.410, "tons"},
	{"Propane (LPG)", "Gadial Oil", 0.504, "cubic meters"},
	{"Butane (LPG)", "Gadial Oil", 0.468, "cubic meters"},
	{"Marine Gas Oil (MGO) Low-Sulfur", "Gadial Oil", 0.642, "barrels"},
	{"Low-Sulfur Fuel Oil (0.5% Blend)", "Gadial Oil", 0.589, "barrels"},
	{"Jet Fuel (Kerosene Type)", "Gadial Oil", 0.603, "barrels"},
	{"Refined Gasoline (92 Octane)", "Gadial Oil", 0.556, "barrels"},
	{"Naphtha (Petrochemical Feedstock)", "Gadial Oil", 0.521, "barrels"},
	{"Bitumen (Export Base)", "Gadial Oil", 0.248, "tons"},
	{"Industrial Lubricants (Arctic Grade)", "Gadial Oil", 0.432, "liters"},
	{"Petroleum Coke (Calcined)", "Gadial Oil", 0.322, "tons"},
	{ "Salt", "Port of Euranidom", 15.84, "tons" },
	{ "Limestone", "Port of Euranidom", 6.60, "tons" },
	{ "Copper", "Port of Euranidom", 2.77, "tons" },
	{ "Gold", "Port of Euranidom", 0.11, "kilograms" },
	{ "Iron", "Port of Euranidom", 13.80, "tons" },
	{ "Chromium", "Port of Euranidom", 1.88, "tons" },
	{ "Oil", "Port of Euranidom", 4.30, "barrels" },
	{ "Coal", "Port of Euranidom", 9.90, "tons" },
	{ "Granite", "Southern Port of Keltiania", 3.84, "tons" },
	{ "Gold", "Southern Port of Keltiania", 0.11, "kilograms" },
	{ "Oil", "Southern Port of Keltiania", 8.00, "barrels" },
	{ "Natural Gas", "Southern Port of Keltiania", 0.80, "cubic meters" },
	{ "Tharsyr Shoal Salt", "Tharsyr Shoal Salt Works", 0.420, "tons" },
	{ "Coarse Sea Salt", "Tharsyr Shoal Salt Works", 0.360, "sacks" },
	{ "Fine White Salt", "Tharsyr Shoal Salt Works", 0.440, "crates" },
	{ "Ceremonial Temple Salt", "Tharsyr Shoal Salt Works", 0.720, "jars" },
	{ "Cliff-Dried Salt Flakes", "Tharsyr Shoal Salt Works", 0.680, "tins" },
	{ "Brine-Cured Preservation Salt", "Tharsyr Shoal Salt Works", 0.510, "barrels" },
	{ "Mineral Brine Concentrate", "Tharsyr Shoal Salt Works", 0.590, "casks" },
	{ "Salt Blocks", "Tharsyr Shoal Salt Works", 0.390, "blocks" },
	{ "Purification Salt Tablets", "Tharsyr Shoal Salt Works", 0.480, "tablets" },
	{ "Redwood-Smoked Finishing Salt", "Tharsyr Shoal Salt Works", 0.830, "jars" },

	{"Baicha TR30 Heavy Tractor Unit", "Baicha Heavy Industries", 0.180, "units"},
	{"Baicha TR50 Heavy Tractor Unit", "Baicha Heavy Industries", 0.115, "units"},
	{"Baicha MIL30 Armoured Work Truck", "Baicha Heavy Industries", 0.070, "units"},
	{"Baicha Dockyard Crane Carrier", "Baicha Heavy Industries", 0.045, "units"},
	{"Baicha Jumbo Excavator Chassis", "Baicha Heavy Industries", 0.038, "units"},
	{"Baicha Stationary Diesel Engine", "Baicha Heavy Industries", 0.260, "engines"},
	{"Baicha Heavy Vehicle Gearbox Set", "Baicha Heavy Industries", 0.310, "sets"},
	{"Baicha Armoured Hull Plate Kit", "Baicha Heavy Industries", 0.095, "kits"},
	{"Baicha Aircraft Component Crate", "Baicha Heavy Industries", 0.145, "crates"},
	{"Baicha Field Maintenance Parts Pallet", "Baicha Heavy Industries", 0.420, "pallets"},


---------------------------------------------------------
-- Imperial Federation Partner Company
-- Mechazawa Shipbuilding Group
---------------------------------------------------------

	{"Mechazawa Coastal Ferry Hull", "Mechazawa Shipbuilding Group", 0.018, "hulls"},
	{"Mechazawa Lake Cruise Liner Hull", "Mechazawa Shipbuilding Group", 0.0065, "hulls"},
	{"Mechazawa Pilgrim Excursion Vessel", "Mechazawa Shipbuilding Group", 0.011, "vessels"},
	{"Mechazawa Strait Passenger Catamaran", "Mechazawa Shipbuilding Group", 0.014, "vessels"},
	{"Mechazawa Cargo Lighter", "Mechazawa Shipbuilding Group", 0.026, "hulls"},
	{"Mechazawa Harbor Inspection Launch", "Mechazawa Shipbuilding Group", 0.036, "boats"},
	{"Mechazawa Canal Tender", "Mechazawa Shipbuilding Group", 0.032, "boats"},
	{"Mechazawa Civilian Drydock Refit Kit", "Mechazawa Shipbuilding Group", 0.075, "kits"},
	{"Mechazawa Passenger Deck Module", "Mechazawa Shipbuilding Group", 0.090, "modules"},
	{"Mechazawa Marine Engine Mount Set", "Mechazawa Shipbuilding Group", 0.160, "sets"},

---------------------------------------------------------
-- Southern Strait Partner Company
-- Thyrsa Maena Harbor Cooperative
---------------------------------------------------------

	{"Saruq Ferry Mat Rolls", "Thyrsa Maena Harbor Cooperative", 0.42, "rolls"},
	{"Saruq Cargo-Padding Panels", "Thyrsa Maena Harbor Cooperative", 0.55, "panels"},
	{"Saruq Rope Backing Strips", "Thyrsa Maena Harbor Cooperative", 0.36, "bundles"},
	{"Saruq Warehouse Thatch Sheets", "Thyrsa Maena Harbor Cooperative", 0.48, "sheets"},
	{"Saruq Crate-Lining Bundles", "Thyrsa Maena Harbor Cooperative", 0.32, "bundles"},
	{"Reed Cargo Sleeve Sets", "Thyrsa Maena Harbor Cooperative", 0.44, "sets"},
	{"Cane-Fiber Dock Twine", "Thyrsa Maena Harbor Cooperative", 0.28, "coils"},
	{"Ferry Shelter Floor Mats", "Thyrsa Maena Harbor Cooperative", 0.62, "mats"},
	{"Quay Stall Reed Screens", "Thyrsa Maena Harbor Cooperative", 0.40, "screens"},
	{"Low-Cost Reed Partition Panels", "Thyrsa Maena Harbor Cooperative", 0.58, "panels"},

}

---------------------------------------------------------
-- 2.5 City-Signal Integrations (WX / War / Hatch / Temple / Health)
---------------------------------------------------------
local forecastOk, forecast = pcall(require, "Module:BassaridiaForecast")
local hatchOk, hatch = pcall(require, "Module:HatchMinistryDailyOps")
local outbreakOk, outbreaks = pcall(require, "Module:BassaridiaOutbreaks")
local warOk, war = pcall(require, "Module:WarLeagueDivisionOpsBVR")

local function escapePattern(s)
	s = tostring(s or "")
	return s:gsub("([%%%^%$%(%)%.%[%]%*%+%-%?])", "%%%1")
end

-- Company -> HQ mapping (from your General Port company tables / HQ column)
-- Leave blank ("") for non-city / external / region-only entries.
local companyHQOverrides = {
	["Baratar Corporation"] = "Somniumpolis",
	["Roving Wind Farm Corporation"] = "Vaeringheim",
	["Port of Qandra"] = "Delphica",
	["Bijarian Energy Corporation"] = "Pyralis",
	["Thalassian Temples Granite Export Cooperative"] = "Vaeringheim",
	["Thalassian Temple Granite Export Cooperative"] = "Vaeringheim",
	["East Keltian Iron Company"] = "Somniumpolis",
	["Mylecian Coal Ports"] = "Mylecia",
	["Merchants of the Valley of Diamonds"] = "Diamandis",
	["East Keltian Timber Company"] = "New Kingsland",
	["Onceanic Boot Company"] = "Pyralis",
	["Oceanic Boot Company"] = "Pyralis",
	["Commune of the Garganid Apostles"] = "Vaeringheim",
	["Shï Collective"] = "Aureum",
	["Shi Collective"] = "Aureum",
	["Order of the Sphinx"] = "Bjornopolis",
	["Market Hanavusu"] = "Lunalis Sancta",
	["Federation of North Brabipant"] = "", -- Arctic north of Aderstein
	["Copper Mines of Southern Jogi"] = "Jogi",
	["Southern Strait Preservation Corporation"] = "Vaeringheim",
	["Horned Bear Timber Company"] = "Ardclach",
	["Vortelin Electronics"] = "Lewisburg",
	["Thyrsiad Rubber Company"] = "Ferrum Citadel",
	["Stygium Mines of Acheron"] = "Acheron",
	["Amber Ports of Slevik"] = "Slevik",
	["Eosphorus Motor Company"] = "Luminaria",
	["Somniant Stock Fund"] = "Somniumpolis",
	["Trans-Rodinian Granite Agency"] = "", -- Lacaran Mountains / Central Keltia (non-city)
	["Port of Corumia"] = "", -- Corum (external)
	["Thesean Iron Exports"] = "", -- (HQ unspecified)
	["Fanghorn Highland Gas Company"] = "Fanghorn",
	["Gadial Oil"] = "Storesund",
	["Thyrsa Maena Harbor Cooperative"] = "Saruq Thyrsa",



---------------------------------------------------------
-- Imperial Federation Partner Companies
---------------------------------------------------------

	["Baicha Heavy Industries"] = "",
	["Mechazawa Shipbuilding Group"] = "",
}

local function inferHQCity(companyName)
	companyName = tostring(companyName or "")
	return companyHQOverrides[companyName] or ""
end

local function clamp(x, lo, hi)
	if x < lo then return lo end
	if x > hi then return hi end
	return x
end

local function opsLevelToNumber(levelOrLabel)
	local n = tonumber(levelOrLabel)
	if n then return n end
	local t = tostring(levelOrLabel or ""):lower()
	if t:find("green") then return 0 end
	if t:find("yellow") then return 1 end
	if t:find("orange") then return 2 end
	if t:find("red") then return 3 end
	return 0
end

-- Manufacturing product classification (for Temple Bank behavior)
local function productClassManf(productName)
	local n = tostring(productName or ""):lower()

	-- essentials / infrastructure
	if n:find("electricity") or n:find("grid") or n:find("power") or n:find("blackstart")
		or n:find("coal") or n:find("natural gas") or n:find("lng") or n:find("fuel") or n:find("diesel")
		or n:find("gasoline") or n:find("jet fuel") or n:find("propane") or n:find("butane") or n:find("bitumen")
		or n:find("iron") or n:find("steel") or n:find("concrete") or n:find("timber") or n:find("lumber")
	then
		return "essential"
	end

	-- military / security hardware
    	if n:find("rifle") or n:find("pistol") or n:find("shotgun") or n:find("smg") or n:find("grenade")
    		or n:find("armor") or n:find("howitzer") or n:find("missile") or n:find("battery")
    		or n:find("corvette") or n:find("frigate") or n:find("submarine") or n:find("cruiser")
    		or n:find("attack craft") or n:find("minelayer") or n:find("minehunter") or n:find("battlecruiser")
    		or n:find("uav") or n:find("helicopter") or n:find("bomber") or n:find("aircraft")
    		or n:find("zeppelin") or n:find("airship") or n:find("bastion")
    	then
    		return "military"
    	end

	-- luxury / discretionary / ritual-adjacent
	if n:find("diamond") or n:find("jew") or n:find("necklace") or n:find("earring") or n:find("choker") or n:find("armlet") or n:find("pendant") or n:find("brooch")
		or n:find("perfume") or n:find("cologne") or n:find("incense") or n:find("candles")
		or n:find("purple granite") or n:find("temple") or n:find("sealstone")
	then
		return "luxury"
	end

	return "standard"
end

local function getForecastSignal(city, year, dayOfYear)
	if not (forecastOk and forecast and type(forecast.getOpsData) == "function") then
		return { mult = 0, note = nil, opsLevel = 0 }
	end
	local op = forecast.getOpsData(city, year, dayOfYear)
	if not op or not op.alert or not op.impacts then
		return { mult = 0, note = nil, opsLevel = 0 }
	end

	local m = 0
	local ground = tostring(op.impacts.ground or "OK")
	local sea    = tostring(op.impacts.sea or "OK")
	local air    = tostring(op.impacts.air or "OK")

	if ground == "Slow" then m = m + 0.02
	elseif ground == "Closed" then m = m + 0.08 end

	if sea == "Restricted" then m = m + 0.03
	elseif sea == "Closed" then m = m + 0.06 end

	if air == "Limited" then m = m + 0.01
	elseif air == "No-Go" then m = m + 0.04 end

	local cond = tostring(op.condition or "")
	local lc = cond:lower()
	if lc:find("blizzard") then m = m + 0.05
	elseif lc:find("storm") then m = m + 0.03
	elseif lc:find("fog") then m = m + 0.02
	elseif lc:find("rain") then m = m + 0.01 end

	local opsLevel = opsLevelToNumber(op.alert.level)
	local note = string.format("WX/Ops %s (%s; G:%s S:%s A:%s)", tostring(op.alert.label or ""), cond, ground, sea, air)
	return { mult = m, note = note, opsLevel = opsLevel }
end

-- War League posture (derived from Ops Alert) + optional “tempo” proxy
local function getWarLeagueSignal(city, opsLevel, year, dayOfYear)
	local m = 0
	if opsLevel == 1 then m = 0.01
	elseif opsLevel == 2 then m = 0.03
	elseif opsLevel >= 3 then m = 0.06 end

	local notes = {}
	if opsLevel > 0 then
		table.insert(notes, "War posture +" .. string.format("%.0f%%", m*100))
	end

	-- Optional: count city appearances in War League table (deterministic per day)
	if warOk and war and type(war.makeTable) == "function" and city and city ~= "" then
		local tbl = war.makeTable({ args = { rows = "48", showlegend = "no", seed = tostring(year * 1000 + dayOfYear) } })
		tbl = tostring(tbl or "")
		local needle = "%[%[List_of_cities_in_Bassaridia_Vaeringheim#" .. escapePattern(city) .. "%|" .. escapePattern(city) .. "%]%]"
		local c = 0
		for _ in tbl:gmatch(needle) do c = c + 1 end
		if c > 0 then
			local add = math.min(0.04, c * 0.003)
			m = m + add
			table.insert(notes, string.format("War League tempo %d (≈+%.1f%%)", c, add*100))
		end
	end

	return { mult = m, note = (#notes > 0) and table.concat(notes, "; ") or nil }
end

local function countCityInHatchReport(city, year, dayOfYear)
	if not (hatchOk and hatch and type(hatch.dailyReport) == "function") then
		return 0
	end
	local report = hatch.dailyReport({ args = { year = tostring(year), day = tostring(dayOfYear), legend = "no" } })
	report = tostring(report or "")
	local needle = "%[%[List_of_cities_in_Bassaridia_Vaeringheim#" .. escapePattern(city) .. "%|" .. escapePattern(city) .. "%]%]"
	local c = 0
	for _ in report:gmatch(needle) do c = c + 1 end
	return c
end

local function getHatchSignal(city, year, dayOfYear)
	local n = countCityInHatchReport(city, year, dayOfYear)
	if n <= 0 then return { mult = 0, note = nil } end
	local m = math.min(0.05, n * 0.005)
	return { mult = m, note = string.format("Hatch activity %d (≈+%.1f%%)", n, m*100) }
end

local function parseOutbreakSeverity(outText)
	outText = tostring(outText or "")
	local sev = outText:match('style="background:[^"]+"%s*|%s*([A-Z]+)%s*||')
	if sev == "CRITICAL" or sev == "HIGH" or sev == "MEDIUM" or sev == "LOW" or sev == "NONE" then
		return sev
	end
	return "NONE"
end

local function getHealthSignal(city)
	if not (outbreakOk and outbreaks and type(outbreaks.outbreaksForCity) == "function") then
		return { mult = 0, severity = "NONE", note = nil }
	end

	local txt = outbreaks.outbreaksForCity({ args = { city = city } })
	local sev = parseOutbreakSeverity(txt)

	local m = 0
	if sev == "LOW" then m = 0.01
	elseif sev == "MEDIUM" then m = 0.03
	elseif sev == "HIGH" then m = 0.06
	elseif sev == "CRITICAL" then m = 0.10 end

	local note = (sev ~= "NONE") and ("Health " .. sev .. " (≈+" .. string.format("%.0f%%", m*100) .. ")") or nil
	return { mult = m, severity = sev, note = note }
end

local function getTempleBankSignal(pClass, healthSeverity, opsLevel)
	-- Mild, role-based stabilizer:
	--  - stabilize essentials in crisis
	--  - allow luxury/discretionary to rise in crisis
	local crisis = (healthSeverity == "MEDIUM" or healthSeverity == "HIGH" or healthSeverity == "CRITICAL" or opsLevel >= 2)
	if not crisis then return { mult = 0, note = nil } end

	local m = 0
	if pClass == "essential" then
		if healthSeverity == "CRITICAL" then m = -0.05
		elseif healthSeverity == "HIGH" then m = -0.03
		else m = -0.015 end
		if opsLevel >= 3 then m = m - 0.01 end
		return { mult = m, note = string.format("Temple Bank stabilization (%.0f%%)", m*100) }
	elseif pClass == "luxury" then
		if healthSeverity == "CRITICAL" then m = 0.04
		elseif healthSeverity == "HIGH" then m = 0.03
		else m = 0.015 end
		if opsLevel >= 3 then m = m + 0.01 end
		return { mult = m, note = string.format("Temple Bank overhead (+%.0f%%)", m*100) }
	else
		-- standard/military: small friction in crisis
		if opsLevel >= 3 or healthSeverity == "CRITICAL" then m = 0.02
		elseif opsLevel >= 2 or healthSeverity == "HIGH" then m = 0.01 end
		return { mult = m, note = (m ~= 0) and string.format("Temple finance friction (+%.0f%%)", m*100) or nil }
	end
end

---------------------------------------------------------
-- 3) Special Date Events (UNCHANGED)
---------------------------------------------------------
local events = {
	["1,6"]  = "Bayram al-Nur (Festival of Light) [Vaeringheim]",
	["1,18"] = "Chag Or Hadash (Festival of New Light) [Luminaria]",
	["1,30"] = "Symposion Eirinis (Symposium of Harmony) [Serena]",
	["1,43"] = "Alev Günü (Day of Flame) [Pyralis]",
	["1,48"] = "Day of Abandonment [Vaeringheim]",
	["1,55"] = "Tikkun Tzel (Repair of Shadows) [Symphonara]",
	["2,6"]  = "Panegyris Chrysou (Golden Gathering) [Aurelia]",
	["2,17"] = "Constitution Day [Luminaria]",
	["2,19"] = "Mehtap Dalgası (Moonlit Tide) [Vaeringheim]",
	["2,31"] = "Oneiro Foteino (Dream of Illumination) [Somniumpolis]",
	["2,39"] = "Anniversary of victory in the New South Jangsong Campaign [Nexa]",
	["2,44"] = "Erev Galgal (Eve of Cycles) [Nexa]",
	["2,45"] = "Bassaridia Festival [Somniumpolis]",
	["2,48"] = "Anniversary of victory in the Southern Lake Morovia Campaign [Somniumpolis]",
	["2,54"] = "Leilat al-Kamar (Night of the Moon) [Lunalis Sancta]",
	["2,61"] = "Taşrakah (Reverence of the Stone) [Luminaria]",
	["3,6"]  = "Chag Tvuah (Festival of Harvest) [Sylvapolis]",
	["3,18"] = "Anagenesis Eirmos (Procession of Rebirth) [Acheron]",
	["3,28"] = "Panagia Therizis (Holy Day of the Reaper) [Sylvapolis]",
	["3,37"] = "Anniversary of victory in the Morovian Frontier Campaign [Acheron]",
	["3,43"] = "Karnavali Thysias (Carnival of Celebration) [Erythros]",
	["3,53"] = "Sefar Yashar (Straight Path Celebration) [Catonis Atrium]",
}

---------------------------------------------------------
-- 4) simulatePriceChange
--  • Random daily factor (-20%..+20%)
--  • +5% bonus on event days
--  • Local city signals (capped) by company HQ city
--  • rounds to 4 decimals
---------------------------------------------------------
local function simulatePriceChange(basePrice, dayOfMonth, month, psscYear, dayOfYear, city, productName, companyName)
	local dateKey = string.format("%d,%d", month, dayOfMonth)

	-- baseline randomness
	local changeFactor = math.random(-20, 20) / 100
	local explanationParts = {}

	-- event day bump (kept)
	if events[dateKey] then
		table.insert(explanationParts, events[dateKey] .. ": Prices influenced by event dynamics")
		changeFactor = changeFactor + 0.05
	else
		table.insert(explanationParts, "General market fluctuations")
	end

	-- local city signal adjustments
	local cityAdd = 0
	local notes = {}

	city = tostring(city or "")
	if city ~= "" then
		local pClass = productClassManf(productName)

		local wx = getForecastSignal(city, psscYear, dayOfYear)
		cityAdd = cityAdd + (wx.mult or 0)
		if wx.note then table.insert(notes, wx.note) end

		local wl = getWarLeagueSignal(city, wx.opsLevel or 0, psscYear, dayOfYear)
		cityAdd = cityAdd + (wl.mult or 0)
		if wl.note then table.insert(notes, wl.note) end

		local hm = getHatchSignal(city, psscYear, dayOfYear)
		cityAdd = cityAdd + (hm.mult or 0)
		if hm.note then table.insert(notes, hm.note) end

		local ph = getHealthSignal(city)
		cityAdd = cityAdd + (ph.mult or 0)
		if ph.note then table.insert(notes, ph.note) end

		local tb = getTempleBankSignal(pClass, ph.severity or "NONE", wx.opsLevel or 0)
		cityAdd = cityAdd + (tb.mult or 0)
		if tb.note then table.insert(notes, tb.note) end
	end

	-- clamp so local signals can't overwhelm system
	cityAdd = clamp(cityAdd, -0.20, 0.20)
	changeFactor = clamp(changeFactor + cityAdd, -0.35, 0.35)

	if #notes > 0 then
		table.insert(explanationParts, "Local signals: " .. table.concat(notes, "; "))
	end

	local explanation = table.concat(explanationParts, ". ") .. "."
	local newPrice = math.floor((basePrice * (1 + changeFactor)) * 10000) / 10000
	return newPrice, changeFactor, explanation
end

---------------------------------------------------------
-- 5) determinePriceLevel
-- swapped logic retained:
--   adjusted > base => Low
--   adjusted < base => High
--   equal => Standard
---------------------------------------------------------
local function determinePriceLevel(basePrice, adjustedPrice)
	if adjustedPrice > basePrice then
		return "Low"
	elseif adjustedPrice < basePrice then
		return "High"
	else
		return "Standard"
	end
end

---------------------------------------------------------
-- Args helpers (modes) (UNCHANGED)
---------------------------------------------------------
local function getArgs(frame)
	if type(frame) ~= "table" then
		return {}
	end

	local args = {}
	local fargs = frame.args or {}

	local pargs = {}
	if frame.getParent then
		local parent = frame:getParent()
		if parent and parent.args then
			pargs = parent.args
		end
	end
	for k, v in pairs(pargs) do
		if v ~= nil and v ~= "" then
			args[k] = v
		end
	end
	for k, v in pairs(fargs) do
		if v ~= nil and v ~= "" then
			args[k] = v
		end
	end

	return args
end

local function isNo(v)
	v = tostring(v or ""):lower()
	return (v == "no" or v == "n" or v == "false" or v == "0")
end

local function levelSymbol(level)
	if level == "Low" then
		return "↑"
	elseif level == "High" then
		return "↓"
	else
		return "•"
	end
end

---------------------------------------------------------
-- 5.5 Consumer price helpers
--    Converts the industrial ledger into ordinary
--    household and small-shop market prices. The ledger
--    values are units redeemable per poli, so consumer
--    prices move inversely: higher adjusted quantity per
--    poli = lower retail price.
---------------------------------------------------------
local productLookup = nil

local function productKey(name, company)
	return tostring(name or "") .. "||" .. tostring(company or "")
end

local function getProductByNameAndCompany(name, company)
	if productLookup == nil then
		productLookup = {}
		for _, product in ipairs(products) do
			productLookup[productKey(product[1], product[2])] = product
		end
	end
	return productLookup[productKey(name, company)]
end

local function formatConsumerPriceFromNil(totalNil)
	totalNil = math.floor((tonumber(totalNil) or 0) + 0.5)
	if totalNil < 1 then totalNil = 1 end

	local poli = math.floor(totalNil / 200)
	local rem = totalNil % 200
	local sik = math.floor(rem / 10)
	local nilCoins = rem % 10

	local parts = {}
	if poli > 0 then table.insert(parts, tostring(poli) .. "₱̈") end
	if sik > 0 then table.insert(parts, tostring(sik) .. "Ƨ̈") end
	if nilCoins > 0 then table.insert(parts, tostring(nilCoins) .. "•") end
	if #parts == 0 then return "1•" end
	return table.concat(parts, " ")
end

local function consumerRow(productName, companyName, consumerUse, retailUnit, baseNil, note)
	return {
		productName = productName,
		companyName = companyName,
		consumerUse = consumerUse,
		retailUnit = retailUnit,
		baseNil = baseNil,
		note = note or ""
	}
end

local consumerCatalog = {
	-- Household energy, fuel, and heat
	consumerRow("Electricity", "Roving Wind Farm Corporation", "Ordinary household power", "daily household block", 40, "Retail expression of grid power for household use."),
	consumerRow("Electricity (Off-Peak)", "Roving Wind Farm Corporation", "Night-rate household power", "daily household block", 30, "Lower-cost off-peak power."),
	consumerRow("Electricity", "Port of Qandra", "Port-district household power", "daily household block", 42, "Urban and portside retail power."),
	consumerRow("Electricity (Off-Peak)", "Port of Qandra", "Off-peak household power", "daily household block", 32, "Port-district off-peak power."),
	consumerRow("Backup Generator Dispatch (Emergency)", "Port of Qandra", "Emergency household power support", "1 emergency callout", 120, "Used during outages or severe grid disruptions."),
	consumerRow("Bottled LPG Cooking Cylinders", "Fanghorn Highland Gas Company", "Cooking fuel", "1 small cylinder", 300, "Household cooking gas cylinder."),
	consumerRow("Highland Winter Heating Gas", "Fanghorn Highland Gas Company", "Home heating gas", "weekly heating block", 80, "Cold-season heating service."),
	consumerRow("Remote Highlands Household Supply Packages", "Fanghorn Highland Gas Company", "Remote household gas supply", "1 household package", 150, "Bundled gas access for remote households."),
	consumerRow("Compressed Vehicle Gas (CNG) Refills", "Fanghorn Highland Gas Company", "Vehicle fuel", "1 refill", 80, "Small vehicle or service cart fuel."),
	consumerRow("Propane", "Federation of North Brabipant", "Cooking and heating fuel", "small refill", 45, "Retail propane refill."),
	consumerRow("Refined Gasoline", "Federation of North Brabipant", "Motor fuel", "5 liter tin", 100, "Small household vehicle fuel purchase."),
	consumerRow("Diesel Fuel", "Federation of North Brabipant", "Generator or work vehicle fuel", "5 liter tin", 90, "Small diesel purchase."),
	consumerRow("Lubricants", "Federation of North Brabipant", "Tool, cart, and engine maintenance", "small bottle", 35, "Everyday mechanical maintenance oil."),
	consumerRow("Refined Gasoline (92 Octane)", "Gadial Oil", "Motor fuel", "5 liter tin", 105, "Higher-grade motor fuel."),
	consumerRow("Industrial Lubricants (Arctic Grade)", "Gadial Oil", "Cold-weather mechanical maintenance", "small bottle", 45, "Specialized lubricant."),
	consumerRow("Coal Briquettes (Bagged)", "Mylecian Coal Ports", "Cooking, heating, small workshop fuel", "small sack", 35, "Bagged household coal."),
	consumerRow("Firewood (Bundled)", "East Keltian Timber Company", "Hearth and stove fuel", "1 bundle", 25, "Basic household fuel."),
	consumerRow("Resin-Rich Kindling Bundles", "Horned Bear Timber Company", "Fire starting", "1 bundle", 15, "Resin-rich northern kindling."),

	-- Household salt, preservation, and cleaning minerals
	consumerRow("Salt", "Port of Euranidom", "Cooking and preservation", "500 g packet", 8, "Basic household salt."),
	consumerRow("Coarse Sea Salt", "Tharsyr Shoal Salt Works", "Cooking and preservation", "500 g packet", 10, "Coarse kitchen salt."),
	consumerRow("Fine White Salt", "Tharsyr Shoal Salt Works", "Table salt and cooking", "500 g tin", 12, "Fine household salt."),
	consumerRow("Ceremonial Temple Salt", "Tharsyr Shoal Salt Works", "Ritual use and offerings", "small jar", 30, "Temple-grade salt."),
	consumerRow("Cliff-Dried Salt Flakes", "Tharsyr Shoal Salt Works", "Finishing salt", "small tin", 25, "Specialty food salt."),
	consumerRow("Brine-Cured Preservation Salt", "Tharsyr Shoal Salt Works", "Pickling and curing", "small barrel", 45, "Preservation salt for household stores."),
	consumerRow("Salt Blocks", "Tharsyr Shoal Salt Works", "Animal, storage, and household use", "1 block", 20, "Block salt."),
	consumerRow("Purification Salt Tablets", "Tharsyr Shoal Salt Works", "Water and ritual purification", "small packet", 25, "Tablet form salt product."),
	consumerRow("Redwood-Smoked Finishing Salt", "Tharsyr Shoal Salt Works", "Cooking and table use", "small jar", 35, "Luxury finishing salt."),

	-- Footwear, clothing, and personal goods
	consumerRow("Mens' Boots", "Onceanic Boot Company", "Daily footwear", "1 pair", 160, "Common men's boots."),
	consumerRow("Womens' Boots", "Onceanic Boot Company", "Daily footwear", "1 pair", 170, "Common women's boots."),
	consumerRow("Dockside Work Boots (Reinforced)", "Onceanic Boot Company", "Work footwear", "1 pair", 220, "Durable dock and workshop boots."),
	consumerRow("Canal Waders (Waterproof)", "Onceanic Boot Company", "Wetland and canal workwear", "1 pair", 260, "Waterproof canal workwear."),
	consumerRow("Insulated Winter Boots", "Onceanic Boot Company", "Cold-weather footwear", "1 pair", 240, "Winter boots."),
	consumerRow("Riding Boots (Leather)", "Onceanic Boot Company", "Riding and formal travel", "1 pair", 220, "Leather riding boots."),
	consumerRow("Desert Trek Boots (Breathable)", "Onceanic Boot Company", "Desert and hill travel", "1 pair", 200, "Breathable hot-weather boots."),
	consumerRow("Sailor Deck Shoes (Non-Slip)", "Onceanic Boot Company", "Boat and dock footwear", "1 pair", 140, "Non-slip deck shoes."),
	consumerRow("Boot Repair Kits (Leather & Rivet)", "Onceanic Boot Company", "Footwear repair", "1 kit", 40, "Home boot repair kit."),
	consumerRow("Rubber Sole Sheets (Replacement)", "Onceanic Boot Company", "Footwear repair", "1 sheet", 45, "Replacement sole material."),
	consumerRow("Robes", "Order of the Sphinx", "Daily or ritual clothing", "1 robe", 150, "General robe purchase."),
	consumerRow("Dresses", "Order of the Sphinx", "Daily or festival clothing", "1 dress", 140, "General dress purchase."),
	consumerRow("Tarnkappes", "Order of the Sphinx", "Outerwear cloak", "1 cloak", 250, "Higher-value cloak."),
	consumerRow("Coats", "Order of the Sphinx", "Outerwear", "1 coat", 220, "General coat purchase."),
	consumerRow("Perfume", "Market Hanavusu", "Personal fragrance", "small bottle", 50, "Personal luxury good."),
	consumerRow("Cologne", "Market Hanavusu", "Personal fragrance", "small bottle", 45, "Personal luxury good."),
	consumerRow("Incense", "Market Hanavusu", "Household shrine and scent", "small bundle", 20, "Everyday incense."),
	consumerRow("Candles", "Market Hanavusu", "Light and ritual use", "1 piece", 15, "General household candle."),

	-- Jewelry, ornament, and small gifts
	consumerRow("Gold Necklaces", "Shï Collective", "Jewelry and gifts", "1 piece", 500, "High-value personal ornament."),
	consumerRow("Gold Rings", "Shï Collective", "Jewelry and gifts", "1 piece", 300, "Common gold ornament."),
	consumerRow("Gold Bracelets", "Shï Collective", "Jewelry and gifts", "1 piece", 350, "Gold bracelet."),
	consumerRow("Gold Earrings", "Shï Collective", "Jewelry and gifts", "1 pair", 320, "Gold earrings."),
	consumerRow("Cut Diamonds (Small Stones)", "Merchants of the Valley of Diamonds", "Jewelry repair and gifts", "small stone", 250, "Small cut gemstone."),
	consumerRow("Gemstone Appraisal Certificates", "Merchants of the Valley of Diamonds", "Jewelry certification", "1 certificate", 50, "Retail appraisal paperwork."),
	consumerRow("Amber Beads", "Amber Ports of Slevik", "Jewelry making and gifts", "1 strand", 80, "Amber bead strand."),
	consumerRow("Amber Necklaces", "Amber Ports of Slevik", "Jewelry and gifts", "1 piece", 140, "Amber necklace."),
	consumerRow("Amber Rings", "Amber Ports of Slevik", "Jewelry and gifts", "1 piece", 90, "Amber ring."),
	consumerRow("Amber Bracelets", "Amber Ports of Slevik", "Jewelry and gifts", "1 piece", 120, "Amber bracelet."),
	consumerRow("Amber Earrings", "Amber Ports of Slevik", "Jewelry and gifts", "1 pair", 110, "Amber earrings."),
	consumerRow("Amber Brooches", "Amber Ports of Slevik", "Clothing ornament", "1 piece", 90, "Amber brooch."),
	consumerRow("Amber Talismans", "Amber Ports of Slevik", "Ritual or protective charm", "1 piece", 120, "Amber talisman."),
	consumerRow("Amber-Resin Oil", "Amber Ports of Slevik", "Scent and ritual oil", "small bottle", 45, "Amber-based oil."),
	consumerRow("Braxian crafted Biolume Resin Drop Earrings", "Port of Corumia", "Jewelry and gifts", "1 pair", 140, "Crafted earrings."),
	consumerRow("Braxian crafted Cave-Amber Choker (indigo-dyed cord)", "Port of Corumia", "Jewelry and gifts", "1 piece", 160, "Crafted choker."),
	consumerRow("Braxian crafted Kralian-Silver Spiral Armlet", "Port of Corumia", "Jewelry and gifts", "1 piece", 180, "Crafted armlet."),
	consumerRow("Braxian crafted Bijeko-Lisea-Nas Fang Pendant (silver mount)", "Port of Corumia", "Jewelry and gifts", "1 piece", 160, "Crafted pendant."),
	consumerRow("Braxian crafted Fa-Hial-Irf Wingcase Brooch (insect relief)", "Port of Corumia", "Clothing ornament", "1 piece", 150, "Crafted brooch."),

	-- Household repair, craft, and construction materials
	consumerRow("Concrete", "East Keltian Iron Company", "Home repair and small masonry", "small bag", 25, "Small retail masonry bag."),
	consumerRow("Steel", "East Keltian Iron Company", "Household repair and shop fabrication", "small bar bundle", 80, "Retail steel stock."),
	consumerRow("Iron", "East Keltian Iron Company", "Household repair and shop fabrication", "small bar bundle", 60, "Retail iron stock."),
	consumerRow("Conifer Lumber (Milled Planks)", "East Keltian Timber Company", "Home repair and carpentry", "1 plank", 60, "Standard plank."),
	consumerRow("Plywood Sheets (Marine Grade)", "East Keltian Timber Company", "Home repair and boat repair", "1 sheet", 100, "Marine-grade sheet."),
	consumerRow("Sawdust (Bulk)", "East Keltian Timber Company", "Animal bedding, packing, cleaning", "small sack", 8, "Cheap domestic material."),
	consumerRow("Joinery-Grade Boards (Kiln-Dried)", "East Keltian Timber Company", "Furniture and home repair", "small crate", 120, "Fine boards."),
	consumerRow("Milled Lumber (Harbor Planks)", "Horned Bear Timber Company", "Home and dock repair", "1 plank", 65, "Northern plank."),
	consumerRow("Barrel Staves (Cooperage)", "Horned Bear Timber Company", "Barrel repair and craft", "small bundle", 40, "Cooperage material."),
	consumerRow("Wood Tar (Kiln Batch)", "Horned Bear Timber Company", "Waterproofing and repair", "small tin", 35, "Repair tar."),
	consumerRow("Joinery Boards (Premium)", "Horned Bear Timber Company", "Furniture and repair", "small crate", 130, "Premium boards."),
	consumerRow("Copper Wire Spools", "Copper Mines of Southern Jogi", "Electrical repair", "small spool", 40, "Small household or shop spool."),
	consumerRow("Copper Sheet (Rolled)", "Copper Mines of Southern Jogi", "Repair, roofing, craft", "small sheet", 65, "Retail copper sheet."),
	consumerRow("Copper Pipe Sections", "Copper Mines of Southern Jogi", "Plumbing repair", "1 short section", 35, "Retail pipe section."),
	consumerRow("Marine-Grade Fasteners", "Southern Strait Preservation Corporation", "Repair hardware", "small packet", 10, "Corrosion-resistant fasteners."),
	consumerRow("Erosion Control Mesh", "Southern Strait Preservation Corporation", "Garden, drainage, slope repair", "small roll", 55, "Small property repair material."),
	consumerRow("Drainage and Filter Matting", "Southern Strait Preservation Corporation", "Garden and drainage repair", "small roll", 50, "Household drainage material."),
	consumerRow("Field-Forged Rebar Bundles", "Thesean Iron Exports", "Masonry and structural repair", "small bundle", 90, "Retail rebar bundle."),
	consumerRow("Forged Tool-Steel Billets", "Thesean Iron Exports", "Tool repair and small forging", "1 billet", 80, "Small-shop steel stock."),
	consumerRow("Rope", "Port of Corumia", "Household, boat, and market use", "1 bundle", 15, "Everyday rope."),
	consumerRow("String", "Port of Corumia", "Household tying and repair", "1 roll", 8, "Everyday string."),
	consumerRow("Twine Material (Unprocessed)", "Port of Corumia", "Household tying and craft", "1 roll", 12, "Simple twine."),
	consumerRow("Ceramic Amphorae (Export-Grade)", "Port of Corumia", "Storage vessel", "1 amphora", 45, "Household storage jar."),
	consumerRow("Pitch & Naval Tar", "Port of Corumia", "Waterproofing and boat repair", "small cask", 35, "Small repair tar."),
	consumerRow("Indigo Dye Cakes (Pressed)", "Port of Corumia", "Cloth dye and craft", "1 cake", 30, "Household dye cake."),
	consumerRow("Ornamental Stone Inlays", "Trans-Rodinian Granite Agency", "Home shrine and craft", "small set", 120, "Decorative stone pieces."),
	consumerRow("Gravemarkers", "Trans-Rodinian Granite Agency", "Funerary purchase", "1 marker", 300, "Occasional but ordinary civic purchase."),
	consumerRow("Polished Granite Tiles", "Trans-Rodinian Granite Agency", "Floor, shrine, and home repair", "small crate", 100, "Retail tile crate."),
	consumerRow("Purple Granite (Cut Tiles)", "Thalassian Temples Granite Export Cooperative", "Shrine, floor, and home repair", "small crate", 110, "Temple-associated stone tile."),
	consumerRow("Purple Granite Sealstone Tablets", "Thalassian Temples Granite Export Cooperative", "Ritual inscription and civic records", "1 tablet", 150, "Ritual or official stone tablet."),

	-- Electronics, rubber goods, and modern household/small-shop equipment
	consumerRow("HydraLink Router", "Vortelin Electronics", "Home or shop communications", "1 unit", 160, "Network router."),
	consumerRow("Smart Power Converters", "Vortelin Electronics", "Appliance and shop power conversion", "1 unit", 110, "Power converter."),
	consumerRow("Compact Signal Relay", "Vortelin Electronics", "Communication repair", "1 unit", 50, "Small signal relay."),
	consumerRow("CobraSeries Fuse Array", "Vortelin Electronics", "Electrical repair", "1 unit", 20, "Fuse array."),
	consumerRow("LumenTrack LED Driver", "Vortelin Electronics", "Lighting repair", "1 unit", 30, "LED driver."),
	consumerRow("Verdant Power Cell", "Vortelin Electronics", "Portable power", "1 cell", 50, "Rechargeable or replaceable power cell."),
	consumerRow("Basic Sensor Module", "Vortelin Electronics", "Small appliance or shop repair", "1 unit", 50, "Basic sensor part."),
	consumerRow("Electromechanical Timer", "Vortelin Electronics", "Appliance and irrigation timing", "1 unit", 45, "Timer device."),
	consumerRow("Stabilizer Adapter", "Vortelin Electronics", "Electrical protection", "1 unit", 40, "Adapter for unstable power."),
	consumerRow("Basic Radio Kit", "Vortelin Electronics", "Household radio or education", "1 kit", 120, "Basic radio kit."),
	consumerRow("Circuit Training Kit", "Vortelin Electronics", "Education and repair training", "1 kit", 140, "Electronics training kit."),
	consumerRow("Rubber Tubing", "Thyrsiad Rubber Company", "Household, irrigation, and repair", "1 meter", 15, "Retail tubing."),
	consumerRow("Insulated Wire Sheath", "Thyrsiad Rubber Company", "Electrical repair", "1 meter", 12, "Wire insulation."),
	consumerRow("Waterproof Seals", "Thyrsiad Rubber Company", "Repair and plumbing", "1 unit", 20, "Waterproof seal."),
	consumerRow("Torchflex Gaskets", "Thyrsiad Rubber Company", "Repair and appliance maintenance", "1 unit", 15, "Replacement gasket."),
	consumerRow("Elastic Fasteners", "Thyrsiad Rubber Company", "Household fastening", "small bundle", 10, "Elastic fastener bundle."),
	consumerRow("Vehicle Tyres", "Thyrsiad Rubber Company", "Vehicle maintenance", "1 tyre", 180, "Vehicle tyre."),
	consumerRow("Artisan Rubber Mats", "Thyrsiad Rubber Company", "Flooring and workshop use", "1 sheet", 50, "Rubber mat."),
	consumerRow("Medical-Grade Latex", "Thyrsiad Rubber Company", "Clinic and household care", "small bottle", 60, "Medical latex supply."),
	consumerRow("Thyrsian Sole Sheets", "Thyrsiad Rubber Company", "Shoe repair", "1 sheet", 35, "Rubber sole sheet.")
}

---------------------------------------------------------
-- Public invocation:
--   {{#invoke:AutoUpdateManfPrices|consumerPrices}}
--   {{#invoke:AutoUpdateManfPrices|consumerPrices|limit=50}}
---------------------------------------------------------
function p.consumerPrices(frame)
	local args = getArgs(frame)
	local limit = tonumber(args.limit or "")

	local localTime = os.date("*t")
	math.randomseed(localTime.year * 1000 + localTime.yday)

	local dateString, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()
	local out =
		"{| class=\"wikitable sortable\"\n" ..
		"|+ Consumer mining, manufacturing, and energy price list for " .. dateString .. "\n" ..
		"! Date !! Δ !! Product / Service !! Supplier / Port company !! Consumer use !! Retail unit !! Consumer price !! Notes\n"

	local totalBaseNil, totalTodayNil, count = 0, 0, 0

	for _, item in ipairs(consumerCatalog) do
		if not limit or count < limit then
			local product = getProductByNameAndCompany(item.productName, item.companyName)
			if product then
				local name = product[1]
				local company = product[2]
				local basePrice = product[3]
				local city = inferHQCity(company) or ""
				local adjustedQty = select(1, simulatePriceChange(
					basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company
				))

				local consumerNil = item.baseNil
				if adjustedQty and adjustedQty > 0 then
					consumerNil = item.baseNil * (basePrice / adjustedQty)
				end

				local sym
				local rowStyle
				if consumerNil < item.baseNil then
					sym = "↓"
					rowStyle = ' style="background-color:lightblue;"'
				elseif consumerNil > item.baseNil then
					sym = "↑"
					rowStyle = ' style="background-color:#ffcccb;"'
				else
					sym = "•"
					rowStyle = ' style="background-color:lightgreen;"'
				end

				totalBaseNil = totalBaseNil + item.baseNil
				totalTodayNil = totalTodayNil + consumerNil
				count = count + 1

				out = out .. string.format(
					"|-%s\n| %s || %s || %s || %s || %s || %s || %s || %s\n",
					rowStyle,
					dateString,
					sym,
					name,
					company,
					item.consumerUse,
					item.retailUnit,
					formatConsumerPriceFromNil(consumerNil),
					item.note
				)
			end
		end
	end

	local avgBase = totalBaseNil / math.max(count, 1)
	local avgToday = totalTodayNil / math.max(count, 1)
	local avgLabel = "Standard"
	local avgSym = "•"
	if avgToday < avgBase then
		avgLabel = "Lower consumer prices"
		avgSym = "↓"
	elseif avgToday > avgBase then
		avgLabel = "Higher consumer prices"
		avgSym = "↑"
	end

	out = out .. string.format(
		"|-\n! colspan=\"8\" | Consumer average: %s %s; baseline %s, current %s across %d listed goods and services\n|}\n",
		avgSym,
		avgLabel,
		formatConsumerPriceFromNil(avgBase),
		formatConsumerPriceFromNil(avgToday),
		count
	)

	return out
end



---------------------------------------------------------
-- 6) Main Function: generateTable (CONDENSED + BREAKDOWN)
---------------------------------------------------------
function p.generateTable(frame)
	local args = getArgs(frame)
	local mode = tostring(args.mode or "both"):lower()  -- both | summary | breakdown
	local collapse = not isNo(args.collapse)            -- default true
	local showSummary = (mode == "both" or mode == "summary")
	local showBreakdown = (mode == "both" or mode == "breakdown")

	-- Seed randomness
	local localTime = os.date("*t")
	math.randomseed(localTime.year * 1000 + localTime.yday)

	-- Date info
	local dateString, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()

	-- Build tables
	local out = ""
	local summary = ""
	if showSummary then
		summary =
			"{| class=\"wikitable sortable\"\n" ..
			"! Date !! Δ !! Product !! Company !! Tier I Price !! Units !! Notes\n"
	end

	local breakdown = ""
	if showBreakdown then
		local collapseClass = collapse and " mw-collapsible mw-collapsed" or ""
		breakdown =
			"{| class=\"wikitable sortable" .. collapseClass .. "\"\n" ..
			"|+ Full tier breakdown" .. (collapse and " (click to expand)" or "") .. "\n" ..
			"! Date !! Product !! Company !! Base Price !! Level !! Tier III !! Tier II !! Tier I !! Units !! Explanation\n"
	end

	local totalBase, totalNew, count = 0, 0, 0
	for _, product in ipairs(products) do
		local name, company, basePrice, units = unpack(product)

		local city = inferHQCity(company)
		local newPrice, _, explanation = simulatePriceChange(basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company)
		local priceLevel = determinePriceLevel(basePrice, newPrice)
		local sym = levelSymbol(priceLevel)

		-- row coloring (kept)
		local rowStyle
		if priceLevel == "Low" then
			rowStyle = ' style="background-color:lightblue;"'
		elseif priceLevel == "Standard" then
			rowStyle = ' style="background-color:lightgreen;"'
		else
			rowStyle = ' style="background-color:#ffcccb;"'
		end

		local tierIII = math.floor((newPrice / 3) * 10000) / 10000
		local tierII  = math.floor((newPrice * 2/3) * 10000) / 10000
		local tierI   = newPrice

		totalBase = totalBase + basePrice
		totalNew  = totalNew + newPrice
		count = count + 1

		-- Summary row (Tier I headline)
		if showSummary then
			summary = summary .. string.format(
				"|-%s\n| %s || %s || %s || %s || %.4f || %s || %s\n",
				rowStyle, dateString, sym, name, company, tierI, units, explanation
			)
		end

		-- Breakdown row (full detail)
		if showBreakdown then
			breakdown = breakdown .. string.format(
				"|-%s\n| %s || %s || %s || %.4f || %s || %.4f || %.4f || %.4f || %s || %s\n",
				rowStyle, dateString, name, company, basePrice, priceLevel, tierIII, tierII, tierI, units, explanation
			)
		end
	end

	-- Averages (with symbol)
	local avgBase = totalBase / count
	local avgNew  = totalNew / count
	local avgLevel
	if avgNew > avgBase then
		avgLevel = "Low"
	elseif avgNew < avgBase then
		avgLevel = "High"
	else
		avgLevel = "Standard"
	end
	local avgSym = levelSymbol(avgLevel)

	if showSummary then
		summary = summary .. string.format(
			"|-\n! colspan=\"7\" | Average adjusted (%.4f) vs base (%.4f): %s %s\n|}\n",
			avgNew, avgBase, avgSym, avgLevel
		)
		out = out .. summary .. "\n"
	end
	if showBreakdown then
		breakdown = breakdown .. string.format(
			"|-\n! colspan=\"10\" | Average adjusted (%.4f) vs base (%.4f): %s %s\n|}\n",
			avgNew, avgBase, avgSym, avgLevel
		)
		out = out .. breakdown
	end

	return out
end

---------------------------------------------------------
-- Convenience: full expanded breakdown (for updates/audits)
---------------------------------------------------------
function p.full(frame)
	frame = frame or {}
	frame.args = frame.args or {}
	frame.args.mode = "breakdown"
	frame.args.collapse = "no"
	return p.generateTable(frame)
end

---------------------------------------------------------
-- 7) Optional: Single-Day Line Graph
---------------------------------------------------------
function p.generateSingleDayLineGraph()
	local localTime = os.date("*t")
	math.randomseed(localTime.year * 1000 + localTime.yday)

	local dateString, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()
	local data = {}
	for _, product in ipairs(products) do
		local name, company, basePrice = unpack(product)
		local city = inferHQCity(company)
		local newPrice = simulatePriceChange(basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company) -- first return only
		table.insert(data, { product = name, difference = newPrice - basePrice })
	end

	local spec = {
		["$schema"] = "https://vega.github.io/schema/vega-lite/v5.json",
		description = "Single-day price difference chart",
		width = 700,
		height = 400,
		data = { values = data },
		mark = "line",
		encoding = {
			x = { field = "product", type = "ordinal", title = "Product" },
			y = { field = "difference", type = "quantitative", title = "Difference" },
			tooltip = { field = "difference", type = "quantitative" }
		},
		title = "Price Differences for " .. dateString
	}
	return string.format("<graph>%s</graph>", mw.text.jsonEncode(spec))
end

function p.getAverageData()
	local localTime = os.date("*t")
	local dailySeed = localTime.year * 1000 + localTime.yday
	math.randomseed(dailySeed)

	local dateString, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()

	local totalBase, totalNew, count = 0, 0, 0

	for _, product in ipairs(products) do
		local name, company, basePrice, units = unpack(product)
		local city = inferHQCity(company)

		local newPrice = select(1, simulatePriceChange(
			basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company
		))

		totalBase = totalBase + basePrice
		totalNew = totalNew + newPrice
		count = count + 1
	end

	local avgBase = totalBase / count
	local avgNew = totalNew / count
	local avgLevel
	if avgNew > avgBase then
		avgLevel = "Low"
	elseif avgNew < avgBase then
		avgLevel = "High"
	else
		avgLevel = "Standard"
	end

	return {
		label = "Mining / Manufacturing / Energy",
		avgBase = avgBase,
		avgNew = avgNew,
		avgLevel = avgLevel,
		avgSym = levelSymbol(avgLevel),
		pctChange = ((avgNew - avgBase) / avgBase) * 100
	}
end

function p.getCompanyEmploymentInputs()
	local localTime = os.date("*t")
	local dailySeed = localTime.year * 1000 + localTime.yday
	math.randomseed(dailySeed)

	local _, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()

	local companyMap = {}

	for _, product in ipairs(products) do
		local name = product[1]
		local company = product[2]
		local basePrice = product[3]
		local city = inferHQCity(company) or "Vaeringheim"

		local newPrice = select(1, simulatePriceChange(
			basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company
		))

		if not companyMap[company] then
			companyMap[company] = {
				name = company,
				sector = "Mining / Manufacturing / Energy",
				city = city,
				totalBase = 0,
				totalNew = 0,
				count = 0
			}
		end

		local row = companyMap[company]
		row.totalBase = row.totalBase + basePrice
		row.totalNew = row.totalNew + newPrice
		row.count = row.count + 1
	end

	local out = {}
	for _, row in pairs(companyMap) do
		row.avgBase = row.totalBase / row.count
		row.avgNew = row.totalNew / row.count
		row.pctChange = ((row.avgNew - row.avgBase) / row.avgBase) * 100
		table.insert(out, row)
	end

	table.sort(out, function(a, b) return a.name < b.name end)
	return out
end
return p