Module:AutoUpdateServPrices: Difference between revisions

From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs)
No edit summary
NewZimiaGov (talk | contribs)
No edit summary
Line 1: Line 1:
---------------------------------------------------------
---------------------------------------------------------
-- Module:DailyPriceTable
-- Module:AutoUpdateServPrices
-- Generates a daily-updated table where each cell
-- Generates a daily-updated services-sector price table.
-- refreshes once per day, with random fluctuations
--
-- stable for that day but new on subsequent days.
-- Display (Dec 2025):
-- Rows are colored by price level:
--  • Summary table (Tier I headline) + Δ symbol column (↑ Low / ↓ High / • Standard)
--  • Low      => light blue
--  • Collapsible full breakdown table (Base/Level/Tiers)
--  • Standard => light green
-- • Modes so editors can force full expanded output when updating/auditing
--  • High     => light red
--
-- Usage:
--  {{#invoke:AutoUpdateServPrices|generateTable}}
--    - default: summary + collapsed breakdown
--  {{#invoke:AutoUpdateServPrices|generateTable|mode=summary}}
--    - summary only
--  {{#invoke:AutoUpdateServPrices|generateTable|mode=breakdown}}
--    - breakdown only (collapsed by default)
--  {{#invoke:AutoUpdateServPrices|generateTable|mode=breakdown|collapse=no}}
--    - breakdown only (expanded)
--  {{#invoke:AutoUpdateServPrices|full}}
--     - breakdown only (expanded) convenience function
---------------------------------------------------------
---------------------------------------------------------
local p = {}
local p = {}


Line 17: Line 29:
---------------------------------------------------------
---------------------------------------------------------
local function getCurrentDate()
local function getCurrentDate()
    local startDate = os.time({year = 1999, month = 8, day = 6})
local startDate = os.time({ year = 1999, month = 8, day = 6 })
    local secondsInDay = 86400
local secondsInDay = 86400
    local daysPerYear = 183
local daysPerYear = 183
 
local currentDate = os.time()
    local currentDate = os.time()
local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay)
    local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay)


    local yearFraction = totalDaysElapsed / daysPerYear
local yearFraction = totalDaysElapsed / daysPerYear
    local psscYear = math.floor(yearFraction)
local psscYear = math.floor(yearFraction)
    local dayOfYear = math.floor((yearFraction - psscYear) * daysPerYear) + 1
local dayOfYear = math.floor((yearFraction - psscYear) * daysPerYear) + 1


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


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


---------------------------------------------------------
---------------------------------------------------------
-- Product data remains the same
-- Product data (unchanged)
---------------------------------------------------------
---------------------------------------------------------
local products = {
local products = {
    {"Draped Flag Linens (Foreign Vessels)", "Lake Morovia Blockade Fund - Hatch Ministry", 1.40, "sheets"},
{"Draped Flag Linens (Foreign Vessels)", "Lake Morovia Blockade Fund - Hatch Ministry", 1.40, "sheets"},
    {"Dismantled Minting Equipment", "Lake Morovia Blockade Fund - Hatch Ministry", .7, "assemblies"},
{"Dismantled Minting Equipment", "Lake Morovia Blockade Fund - Hatch Ministry", .7, "assemblies"},
    {"Decertified Seal Stamps (Foreign Commissions)", "Lake Morovia Blockade Fund - Hatch Ministry", 1.9, "sets"},
{"Decertified Seal Stamps (Foreign Commissions)", "Lake Morovia Blockade Fund - Hatch Ministry", 1.9, "sets"},
    {"Declassified Naval Cargo Covers", "Lake Morovia Blockade Fund - Hatch Ministry", 6.0, "tarps"},
{"Declassified Naval Cargo Covers", "Lake Morovia Blockade Fund - Hatch Ministry", 6.0, "tarps"},
    {"Confiscated Calibration Weights", "Lake Morovia Blockade Fund - Hatch Ministry", 8.8, "sets"},
{"Confiscated Calibration Weights", "Lake Morovia Blockade Fund - Hatch Ministry", 8.8, "sets"},
    {"Crated Trade Uniforms (Non-Domestic Origin)", "Lake Morovia Blockade Fund - Hatch Ministry", 1.30, "articles"},
{"Crated Trade Uniforms (Non-Domestic Origin)", "Lake Morovia Blockade Fund - Hatch Ministry", 1.30, "articles"},
    {"Defaced Customs Plaques", "Lake Morovia Blockade Fund - Hatch Ministry", 1.7, "plaques"},
{"Defaced Customs Plaques", "Lake Morovia Blockade Fund - Hatch Ministry", 1.7, "plaques"},
    {"Baled Promotional Ephemera", "Lake Morovia Blockade Fund - Hatch Ministry", 4.80, "kg"},
{"Baled Promotional Ephemera", "Lake Morovia Blockade Fund - Hatch Ministry", 4.80, "kg"},
    {"Foreign Coinage (Struck Before Blockade)", "Lake Morovia Blockade Fund - Hatch Ministry", 3.1, "coins"},
{"Foreign Coinage (Struck Before Blockade)", "Lake Morovia Blockade Fund - Hatch Ministry", 3.1, "coins"},
    {"Embroidered Foreign Diplomatic Standards", "Lake Morovia Blockade Fund - Hatch Ministry", 4, "banners"},
{"Embroidered Foreign Diplomatic Standards", "Lake Morovia Blockade Fund - Hatch Ministry", 4, "banners"},
    {"Blocked Port Registry Books", "Lake Morovia Blockade Fund - Hatch Ministry", 1.2, "ledgers"},
{"Blocked Port Registry Books", "Lake Morovia Blockade Fund - Hatch Ministry", 1.2, "ledgers"},
    {"Disassembled Broadcast Relays", "Lake Morovia Blockade Fund - Hatch Ministry", 6, "units"},
{"Disassembled Broadcast Relays", "Lake Morovia Blockade Fund - Hatch Ministry", 6, "units"},
    {"Stamps (Confiscated)", "Lake Morovia Blockade Fund - Hatch Ministry", 7.0, "sheets"},
{"Stamps (Confiscated)", "Lake Morovia Blockade Fund - Hatch Ministry", 7.0, "sheets"},
    {"Confiscated Trade Crates", "Hatch Ministry", 1.1, "units"},
{"Confiscated Trade Crates", "Hatch Ministry", 1.1, "units"},
    {"Mixed Merchant Cargo", "Hatch Ministry", 5.2, "tons"},
{"Mixed Merchant Cargo", "Hatch Ministry", 5.2, "tons"},
    {"Captured Textiles (Raw & Finished)", "Hatch Ministry", 3.40, "bolts"},
{"Captured Textiles (Raw & Finished)", "Hatch Ministry", 3.40, "bolts"},
    {"Illicit Grain Stores", "Hatch Ministry", 3.6, "tons"},
{"Illicit Grain Stores", "Hatch Ministry", 3.6, "tons"},
    {"Contraband Alcohol", "Hatch Ministry", 1.1, "bottles"},
{"Contraband Alcohol", "Hatch Ministry", 1.1, "bottles"},
    {"Seized Foreign Coinage", "Hatch Ministry", 10, "coins"},
{"Seized Foreign Coinage", "Hatch Ministry", 10, "coins"},
    {"Recovered Cargo Manifests", "Hatch Ministry", 3.33, "scrolls"},
{"Recovered Cargo Manifests", "Hatch Ministry", 3.33, "scrolls"},
    {"Bulk Dyes and Spices (Unmarked Origin)", "Hatch Ministry", 7.220, "kg"},
{"Bulk Dyes and Spices (Unmarked Origin)", "Hatch Ministry", 7.220, "kg"},
    {"Captured Livestock (Deck Transport)", "Hatch Ministry", 2.6, "head"},
{"Captured Livestock (Deck Transport)", "Hatch Ministry", 2.6, "head"},
    {"Foreign Trade Seals and Emblems", "Hatch Ministry", 1.22, "sets"},
{"Foreign Trade Seals and Emblems", "Hatch Ministry", 1.22, "sets"},
    {"Unregistered Luxury Cargo", "Hatch Ministry", 1.4, "tons"},
{"Unregistered Luxury Cargo", "Hatch Ministry", 1.4, "tons"},
    {"Recovered Safe Boxes", "Hatch Ministry", .7, "chests"},
{"Recovered Safe Boxes", "Hatch Ministry", .7, "chests"},
    {"Stamped Silver Bars", "Hatch Ministry", 3.90, "kg"},
{"Stamped Silver Bars", "Hatch Ministry", 3.90, "kg"},
    {"Captured Naval Uniforms and Insignia", "Hatch Ministry", 5.5, "sets"},
{"Captured Naval Uniforms and Insignia", "Hatch Ministry", 5.5, "sets"},
    {"Lost Port Authority Documents", "Hatch Ministry", 1.4, "scrolls"},
{"Lost Port Authority Documents", "Hatch Ministry", 1.4, "scrolls"},
    {"High-Value Personal Effects", "Hatch Ministry", 6.8, "items"},
{"High-Value Personal Effects", "Hatch Ministry", 6.8, "items"},
    {"Private Letters and Ship Logs", "Hatch Ministry", 4.1, "volumes"},
{"Private Letters and Ship Logs", "Hatch Ministry", 4.1, "volumes"},
    {"Faces", "Maritime Guild of the Cult of Maskmakers", 0.03, "masks"},
{"Faces", "Maritime Guild of the Cult of Maskmakers", 0.03, "masks"},
    {"Spies", "Ergonian Spy Agency", 0.01, "assignments"},
{"Spies", "Ergonian Spy Agency", 0.01, "assignments"},
    {"Missionaries of the Order Aurora Mystica", "Temple Bank of the Reformed Stripping Path", 0.05, "teams"},
{"Missionaries of the Order Aurora Mystica", "Temple Bank of the Reformed Stripping Path", 0.05, "teams"},
    {"Missionaries of Harmony Sanctum", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
{"Missionaries of Harmony Sanctum", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
    {"Missionaries of Ignis Aeternum", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
{"Missionaries of Ignis Aeternum", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
    {"Missionaries of Celestial Harmony Sect", "Temple Bank of the Reformed Stripping Path", 0.08, "teams"},
{"Missionaries of Celestial Harmony Sect", "Temple Bank of the Reformed Stripping Path", 0.08, "teams"},
    {"Missionaries of the Guild of Golden Shadows", "Temple Bank of the Reformed Stripping Path", 0.05, "teams"},
{"Missionaries of the Guild of Golden Shadows", "Temple Bank of the Reformed Stripping Path", 0.05, "teams"},
    {"Missionaries of the Azure Sentinel Sect", "Temple Bank of the Reformed Stripping Path", 0.01, "teams"},
{"Missionaries of the Azure Sentinel Sect", "Temple Bank of the Reformed Stripping Path", 0.01, "teams"},
    {"Missionaries of Reverie Nebulous", "Temple Bank of the Reformed Stripping Path", 0.10, "teams"},
{"Missionaries of Reverie Nebulous", "Temple Bank of the Reformed Stripping Path", 0.10, "teams"},
    {"Missionaries of the Eon Fellowship", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
{"Missionaries of the Eon Fellowship", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
    {"Missionaries of the Order of the Umbral Oracle", "Temple Bank of the Reformed Stripping Path", 0.07, "teams"},
{"Missionaries of the Order of the Umbral Oracle", "Temple Bank of the Reformed Stripping Path", 0.07, "teams"},
    {"Missionaries of the Mystery of the Verdant Embrace", "Temple Bank of the Reformed Stripping Path", 0.10, "teams"},
{"Missionaries of the Mystery of the Verdant Embrace", "Temple Bank of the Reformed Stripping Path", 0.10, "teams"},
    {"Missionaries of Conclace Illuminara", "Temple Bank of the Reformed Stripping Path", 0.02, "teams"},
{"Missionaries of Conclace Illuminara", "Temple Bank of the Reformed Stripping Path", 0.02, "teams"},
    {"Missionaries of Sanctum Vitalis", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
{"Missionaries of Sanctum Vitalis", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
    {"Missionaries of Temple Alabaster", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
{"Missionaries of Temple Alabaster", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
    {"Missionaries of the Court of the Ironclad", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
{"Missionaries of the Court of the Ironclad", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
    {"Missionaries of Concord Accordia", "Temple Bank of the Reformed Stripping Path", 0.02, "teams"},
{"Missionaries of Concord Accordia", "Temple Bank of the Reformed Stripping Path", 0.02, "teams"},
    {"Missionaries of the Mystery of the Stygian Veil", "Temple Bank of the Reformed Stripping Path", 0.03, "teams"},
{"Missionaries of the Mystery of the Stygian Veil", "Temple Bank of the Reformed Stripping Path", 0.03, "teams"},
    {"Missionaries of the Sylvan Fellowship", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
{"Missionaries of the Sylvan Fellowship", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
    {"Missionaries of the Mystery of Red Mirth", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
{"Missionaries of the Mystery of Red Mirth", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
    {"Missionaries of Rex Catonis", "Temple Bank of the Reformed Stripping Path", 0.07, "teams"},
{"Missionaries of Rex Catonis", "Temple Bank of the Reformed Stripping Path", 0.07, "teams"},
    {"Missionaries of Sanctum Delphica", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
{"Missionaries of Sanctum Delphica", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
    {"Missionaries of Ordo Amictia", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
{"Missionaries of Ordo Amictia", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
    {"Missionaries of Temple Illuminata", "Temple Bank of the Reformed Stripping Path", 0.05, "teams"},
{"Missionaries of Temple Illuminata", "Temple Bank of the Reformed Stripping Path", 0.05, "teams"},
    {"Couriers", "Couriers of the Lizard Queen", 0.04, "dispatches"},
{"Couriers", "Couriers of the Lizard Queen", 0.04, "dispatches"},
    {"Wisp Ward Talismans", "Couriers of the Lizard Queen", 0.10, "amulets"},
{"Wisp Ward Talismans", "Couriers of the Lizard Queen", 0.10, "amulets"},
    {"Credit Hours", "Temple University of Delphica", 3.00, "credits"},
{"Credit Hours", "Temple University of Delphica", 3.00, "credits"},
    {"Circuses", "La Sái Ebile", 0.24, "venues"},
{"Circuses", "La Sái Ebile", 0.24, "venues"},
    {"Performances", "La Sái Ebile", 0.11, "acts"},
{"Performances", "La Sái Ebile", 0.11, "acts"},
    {"Passenger Rail Tickets", "Trans-Morovian Express", 1.2, "tickets"},
{"Passenger Rail Tickets", "Trans-Morovian Express", 1.2, "tickets"},
    {"Luxury Cabin Reservations", "Trans-Morovian Express", 4.5, "cabins"},
{"Luxury Cabin Reservations", "Trans-Morovian Express", 4.5, "cabins"},
    {"Freight Car Leasing Contracts", "Trans-Morovian Express", .60, "agreements"},
{"Freight Car Leasing Contracts", "Trans-Morovian Express", .60, "agreements"},
    {"Overland Courier Deliveries", "Trans-Morovian Express", .23, "parcels"},
{"Overland Courier Deliveries", "Trans-Morovian Express", .23, "parcels"},
    {"Secure Cargo Vaults", "Trans-Morovian Express", .39, "units"},
{"Secure Cargo Vaults", "Trans-Morovian Express", .39, "units"},
    {"Customs Bypass Licenses", "Trans-Morovian Express", .71, "permits"},
{"Customs Bypass Licenses", "Trans-Morovian Express", .71, "permits"},
    {"Railway Advertising Rights", "Trans-Morovian Express", .18, "slots"},
{"Railway Advertising Rights", "Trans-Morovian Express", .18, "slots"},
    {"Timetable Access Codes", "Trans-Morovian Express", .5, "keys"},
{"Timetable Access Codes", "Trans-Morovian Express", .5, "keys"},
    {"Locomotive Repair Services", "Trans-Morovian Express", .57, "contracts"},
{"Locomotive Repair Services", "Trans-Morovian Express", .57, "contracts"},
    {"Historical Route Tours", "Trans-Morovian Express", .20, "tours"},
{"Historical Route Tours", "Trans-Morovian Express", .20, "tours"},
    {"Private Charter Lines", "Trans-Morovian Express", .84, "routes"},
{"Private Charter Lines", "Trans-Morovian Express", .84, "routes"},
    {"Coal Tender Refills", "Trans-Morovian Express", .33, "loads"},
{"Coal Tender Refills", "Trans-Morovian Express", .33, "loads"},
    {"Hellhound (scout)", "Hellhound Breeders of Dragevik", 0.03, "hounds"},
{"Hellhound (scout)", "Hellhound Breeders of Dragevik", 0.03, "hounds"},
    {"Hellhound (soldier)", "Hellhound Breeders of Dragevik", 0.05, "hounds"},
{"Hellhound (soldier)", "Hellhound Breeders of Dragevik", 0.05, "hounds"},
    {"Hellhound (spy)", "Hellhound Breeders of Dragevik", 0.15, "hounds"},
{"Hellhound (spy)", "Hellhound Breeders of Dragevik", 0.15, "hounds"},
    {"Priestesses of the Pharmacon Sect (Anti-Parasitic Medicine)", "Pharmacon Sect", 0.07, "doses"},
{"Priestesses of the Pharmacon Sect (Anti-Parasitic Medicine)", "Pharmacon Sect", 0.07, "doses"},
    {"Priestesses of the Pharmacon Sect (Antifungal/Respiratory Medicine)", "Pharmacon Sect", 0.08, "doses"},
{"Priestesses of the Pharmacon Sect (Antifungal/Respiratory Medicine)", "Pharmacon Sect", 0.08, "doses"},
    {"Priestesses of the Pharmacon Sect (Trauma/Battle Medicine)", "Pharmacon Sect", 0.09, "doses"},
{"Priestesses of the Pharmacon Sect (Trauma/Battle Medicine)", "Pharmacon Sect", 0.09, "doses"},
    {"Priestesses of the Pharmacon Sect (Memory and Mind Treatment)", "Pharmacon Sect", 0.06, "doses"},
{"Priestesses of the Pharmacon Sect (Memory and Mind Treatment)", "Pharmacon Sect", 0.06, "doses"},
    {"Priestesses of the Pharmacon Sect (Immune Boost Medicine)", "Pharmacon Sect", 0.05, "doses"},
{"Priestesses of the Pharmacon Sect (Immune Boost Medicine)", "Pharmacon Sect", 0.05, "doses"},
    {"Priestesses of the Pharmacon Sect (Respiratory Clearing Medicine)", "Pharmacon Sect", 0.05, "doses"},
{"Priestesses of the Pharmacon Sect (Respiratory Clearing Medicine)", "Pharmacon Sect", 0.05, "doses"},
    {"Priestesses of the Pharmacon Sect (Fertility and Childbirth Medicine)", "Pharmacon Sect", 0.04, "doses"},
{"Priestesses of the Pharmacon Sect (Fertility and Childbirth Medicine)", "Pharmacon Sect", 0.04, "doses"},
    {"Priestesses of the Pharmacon Sect (Ritual Purification Incense)", "Pharmacon Sect", 0.03, "sticks"},
{"Priestesses of the Pharmacon Sect (Ritual Purification Incense)", "Pharmacon Sect", 0.03, "sticks"},
    {"Priestesses of the Pharmacon Sect (Medicinal Alcohol)", "Pharmacon Sect", 0.02, "bottles"},
{"Priestesses of the Pharmacon Sect (Medicinal Alcohol)", "Pharmacon Sect", 0.02, "bottles"},
    {"Priestesses of the Pharmacon Sect (Detoxification Medicine)", "Pharmacon Sect", 0.05, "doses"},
{"Priestesses of the Pharmacon Sect (Detoxification Medicine)", "Pharmacon Sect", 0.05, "doses"},
    {"Security Contractors", "Skyrophian Security Contractors*", 0.03, "Assignments"},
{"Security Contractors", "Skyrophian Security Contractors*", 0.03, "Assignments"},
    {"Postal Workers", "Haifadora Postal Service*", 0.1, "Assignments"},
{"Postal Workers", "Haifadora Postal Service*", 0.1, "Assignments"},
    {"Recovered Treasure Chests", "Fleet of Rouge Divers", 6, "units"},
{"Recovered Treasure Chests", "Fleet of Rouge Divers", 6, "units"},
    {"Antique Pottery", "Fleet of Rouge Divers", 40, "pieces"},
{"Antique Pottery", "Fleet of Rouge Divers", 40, "pieces"},
    {"Salvaged Artifacts", "Fleet of Rouge Divers", 55, "items"},
{"Salvaged Artifacts", "Fleet of Rouge Divers", 55, "items"},
    {"Driftwood Timber", "Fleet of Rouge Divers", 3.2, "tons"},
{"Driftwood Timber", "Fleet of Rouge Divers", 3.2, "tons"},
    {"Recovered Jewelry", "Fleet of Rouge Divers", 12, "sets"},
{"Recovered Jewelry", "Fleet of Rouge Divers", 12, "sets"},
    {"Glassware (Recovered)", "Fleet of Rouge Divers", 90, "pieces"},
{"Glassware (Recovered)", "Fleet of Rouge Divers", 90, "pieces"},
    {"Metal Ingots (Mixed)", "Fleet of Rouge Divers", 70, "kg"},
{"Metal Ingots (Mixed)", "Fleet of Rouge Divers", 70, "kg"},
    {"Butterscotch Merchants", "Merchant Caravans of the Candy Kingdom", .36, "Caravans"},
{"Butterscotch Merchants", "Merchant Caravans of the Candy Kingdom", .36, "Caravans"},
    {"Chocolate Merchants", "Merchant Caravans of the Candy Kingdom", 1.13, "Caravans"},
{"Chocolate Merchants", "Merchant Caravans of the Candy Kingdom", 1.13, "Caravans"},
    {"Candycane Merchants", "Merchant Caravans of the Candy Kingdom", 1.21, "Caravans"},
{"Candycane Merchants", "Merchant Caravans of the Candy Kingdom", 1.21, "Caravans"},
    {"Merchants of Unicorn Ivory", "Merchant Caravans of the Candy Kingdom", .033, "Caravans"},
{"Merchants of Unicorn Ivory", "Merchant Caravans of the Candy Kingdom", .033, "Caravans"},
    {"Wild Ice Cream Mochi", "Merchant Caravans of the Candy Kingdom", .73, "Caravans"},
{"Wild Ice Cream Mochi", "Merchant Caravans of the Candy Kingdom", .73, "Caravans"},
    {"Farm-Raised Ice Cream Mochi", "Merchant Caravans of the Candy Kingdom", 1.35, "Caravans"},
{"Farm-Raised Ice Cream Mochi", "Merchant Caravans of the Candy Kingdom", 1.35, "Caravans"},
    {"Public News Bulletins (Domestic)", "Bassaridian Broadcasting Corporation", 3.0, "broadcasts"},
{"Public News Bulletins (Domestic)", "Bassaridian Broadcasting Corporation", 3.0, "broadcasts"},
    {"Cultural Programming Syndication", "Bassaridian Broadcasting Corporation", 2.5, "packages"},
{"Cultural Programming Syndication", "Bassaridian Broadcasting Corporation", 2.5, "packages"},
    {"Religious Festival Audio Coverage", "Bassaridian Broadcasting Corporation", 1.7, "segments"},
{"Religious Festival Audio Coverage", "Bassaridian Broadcasting Corporation", 1.7, "segments"},
    {"Foreign Language Radio Translation", "Bassaridian Broadcasting Corporation", 2.2, "programs"},
{"Foreign Language Radio Translation", "Bassaridian Broadcasting Corporation", 2.2, "programs"},
    {"Emergency Broadcast Override Services", "Bassaridian Broadcasting Corporation", 4.1, "networks"},
{"Emergency Broadcast Override Services", "Bassaridian Broadcasting Corporation", 4.1, "networks"},
    {"Commercial Ad Placement (Tier II)", "Bassaridian Broadcasting Corporation", 1.8, "slots"},
{"Commercial Ad Placement (Tier II)", "Bassaridian Broadcasting Corporation", 1.8, "slots"},
    {"Live Event Broadcasting (Vaeringheim)", "Bassaridian Broadcasting Corporation", 6.5, "sessions"},
{"Live Event Broadcasting (Vaeringheim)", "Bassaridian Broadcasting Corporation", 6.5, "sessions"},
    {"Archival Audio Access (Public Use)", "Bassaridian Broadcasting Corporation", 0.9, "reels"},
{"Archival Audio Access (Public Use)", "Bassaridian Broadcasting Corporation", 0.9, "reels"},
    {"Broadcast Tower Leasing (Rural)", "Bassaridian Broadcasting Corporation", 5.0, "units"},
{"Broadcast Tower Leasing (Rural)", "Bassaridian Broadcasting Corporation", 5.0, "units"},
    {"Satellite Feed Subscription (Standard)", "Bassaridian Broadcasting Corporation", 3.6, "feeds"},
{"Satellite Feed Subscription (Standard)", "Bassaridian Broadcasting Corporation", 3.6, "feeds"},
    {"Independent Musician Airplay Review", "Bassaridian Broadcasting Corporation", 1.1, "reviews"},
{"Independent Musician Airplay Review", "Bassaridian Broadcasting Corporation", 1.1, "reviews"},
    {"Syndicated Talk Show Distribution", "Bassaridian Broadcasting Corporation", 2.4, "contracts"},
{"Syndicated Talk Show Distribution", "Bassaridian Broadcasting Corporation", 2.4, "contracts"},
    {"Priestesses of the Ledger (Employee Loyalty Audits)", "Temple of Aprobelle", 2.7, "reports"},
{"Priestesses of the Ledger (Employee Loyalty Audits)", "Temple of Aprobelle", 2.7, "reports"},
    {"Watchful Priestesses (Real-Time Behavior Monitoring)", "Temple of Aprobelle", 9.5, "profiles"},
{"Watchful Priestesses (Real-Time Behavior Monitoring)", "Temple of Aprobelle", 9.5, "profiles"},
    {"Priestesses of Discourse (Disloyalty Flagging Alerts)", "Temple of Aprobelle", 8.1, "alerts"},
{"Priestesses of Discourse (Disloyalty Flagging Alerts)", "Temple of Aprobelle", 8.1, "alerts"},
    {"Priestesses of the Veil (Insider Threat Screening)", "Temple of Aprobelle", 2.1, "cycles"},
{"Priestesses of the Veil (Insider Threat Screening)", "Temple of Aprobelle", 2.1, "cycles"},
    {"Priestesses of the Pulse (Routine Polygraph Sessions)", "Temple of Aprobelle", 2.3, "sessions"},
{"Priestesses of the Pulse (Routine Polygraph Sessions)", "Temple of Aprobelle", 2.3, "sessions"},
    {"Priestesses of the Mirror (Population Mood Tracking)", "Temple of Aprobelle", 6.8, "surveys"},
{"Priestesses of the Mirror (Population Mood Tracking)", "Temple of Aprobelle", 6.8, "surveys"},
    {"Silencing Priestesses (Rumor Suppression Bulletins)", "Temple of Aprobelle", 3.5, "issues"},
{"Silencing Priestesses (Rumor Suppression Bulletins)", "Temple of Aprobelle", 3.5, "issues"},
    {"Resolute Priestesses (Anomaly Response Team Dispatches)", "Temple of Aprobelle", 0.14, "responses"},
{"Resolute Priestesses (Anomaly Response Team Dispatches)", "Temple of Aprobelle", 0.14, "responses"},
    {"Priestesses of Encouragement (Whistleblower Reward Packages)", "Temple of Aprobelle", 0.55, "bonuses"},
{"Priestesses of Encouragement (Whistleblower Reward Packages)", "Temple of Aprobelle", 0.55, "bonuses"},
    {"Camel Train Transport (Local Cargo)", "Keltian Steppe Caravan Company", 1.15, "tons"},
{"Camel Train Transport (Local Cargo)", "Keltian Steppe Caravan Company", 1.15, "tons"},
    {"Alperkin Couriers (Highland Legs)", "Keltian Steppe Caravan Company", 0.18, "dispatches"},
{"Alperkin Couriers (Highland Legs)", "Keltian Steppe Caravan Company", 0.18, "dispatches"},
    {"Custom Caravan Escorts (Armed)", "Keltian Steppe Caravan Company", 0.25, "contracts"},
{"Custom Caravan Escorts (Armed)", "Keltian Steppe Caravan Company", 0.25, "contracts"},
    {"Steppe Route Navigation Charts", "Keltian Steppe Caravan Company", 1.1, "scrolls"},
{"Steppe Route Navigation Charts", "Keltian Steppe Caravan Company", 1.1, "scrolls"},
    {"Water Cache Delivery Refills", "Keltian Steppe Caravan Company", 0.46, "loads"},
{"Water Cache Delivery Refills", "Keltian Steppe Caravan Company", 0.46, "loads"},
    {"Salt Brick Exports (Packaged for Caravan)", "Keltian Steppe Caravan Company", 0.75, "blocks"},
{"Salt Brick Exports (Packaged for Caravan)", "Keltian Steppe Caravan Company", 0.75, "blocks"},
    {"Dry Ridge Campground Leasing (Seasonal)", "Keltian Steppe Caravan Company", 3.5, "stations"},
{"Dry Ridge Campground Leasing (Seasonal)", "Keltian Steppe Caravan Company", 3.5, "stations"},
    {"Pilgrim Caravans (Sacred Route Access)", "Keltian Steppe Caravan Company", 0.35, "convoys"},
{"Pilgrim Caravans (Sacred Route Access)", "Keltian Steppe Caravan Company", 0.35, "convoys"},
    {"Seal of Safe Crossing (Alperkin Stamp)", "Keltian Steppe Caravan Company", 0.05, "marks"},
{"Seal of Safe Crossing (Alperkin Stamp)", "Keltian Steppe Caravan Company", 0.05, "marks"},
    {"Cross-Winds Risk Insurance (Tonar-Bashkim)", "Keltian Steppe Caravan Company", 0.29, "policies"},
{"Cross-Winds Risk Insurance (Tonar-Bashkim)", "Keltian Steppe Caravan Company", 0.29, "policies"},
    {"Iron Ingots (Refined)", "Sårensby Depot", 1.45, "tons"},
{"Iron Ingots (Refined)", "Sårensby Depot", 1.45, "tons"},
    {"Copper Scrap Bundles", "Sårensby Depot", 0.88, "crates"},
{"Copper Scrap Bundles", "Sårensby Depot", 0.88, "crates"},
    {"Rare-Earth Ore Fragments", "Sårensby Depot", 2.3, "satchels"},
{"Rare-Earth Ore Fragments", "Sårensby Depot", 2.3, "satchels"},
    {"Frozen Reindeer Cuts", "Sårensby Depot", 0.67, "packages"},
{"Frozen Reindeer Cuts", "Sårensby Depot", 0.67, "packages"},
    {"Cured Reindeer Leather", "Sårensby Depot", 1.15, "hides"},
{"Cured Reindeer Leather", "Sårensby Depot", 1.15, "hides"},
    {"Seal Fur Pelts", "Sårensby Depot", 2.8, "rolls"},
{"Seal Fur Pelts", "Sårensby Depot", 2.8, "rolls"},
    {"Reindeer Antler Tools", "Sårensby Depot", 0.42, "sets"},
{"Reindeer Antler Tools", "Sårensby Depot", 0.42, "sets"},
    {"Wool Blankets (Nordic Pattern)", "Sårensby Depot", 0.39, "bundles"},
{"Wool Blankets (Nordic Pattern)", "Sårensby Depot", 0.39, "bundles"},
    {"Smoked Elk Sausages", "Sårensby Depot", 0.51, "links"},
{"Smoked Elk Sausages", "Sårensby Depot", 0.51, "links"},
    {"Pickled Arctic Herring", "Sårensby Depot", 0.6, "jars"},
{"Pickled Arctic Herring", "Sårensby Depot", 0.6, "jars"},
    {"Salted Cod (Barrel Aged)", "Sårensby Depot", 0.83, "barrels"},
{"Salted Cod (Barrel Aged)", "Sårensby Depot", 0.83, "barrels"},
    {"Smoked Goose Breast", "Sårensby Depot", 0.49, "cuts"},
{"Smoked Goose Breast", "Sårensby Depot", 0.49, "cuts"},
    {"Seal Oil Lantern-Grade", "Sårensby Depot", 0.73, "flasks"},
{"Seal Oil Lantern-Grade", "Sårensby Depot", 0.73, "flasks"},
    {"Whale Bone (Industrial Grade)", "Sårensby Depot", 1.95, "pieces"},
{"Whale Bone (Industrial Grade)", "Sårensby Depot", 1.95, "pieces"},
    {"Blubber Oil (Purified)", "Sårensby Depot", 1.2, "casks"},
{"Blubber Oil (Purified)", "Sårensby Depot", 1.2, "casks"},
    {"Wild Berry Preserves", "Sårensby Depot", 0.34, "jars"},
{"Wild Berry Preserves", "Sårensby Depot", 0.34, "jars"},
    {"Lingonberry Jam (Sweetened)", "Sårensby Depot", 0.27, "jars"},
{"Lingonberry Jam (Sweetened)", "Sårensby Depot", 0.27, "jars"},
    {"Conifer Lumber", "Sårensby Depot", 1.1, "planks"},
{"Conifer Lumber", "Sårensby Depot", 1.1, "planks"},
    {"Processed Granite Slabs", "Sårensby Depot", 1.7, "tiles"},
{"Processed Granite Slabs", "Sårensby Depot", 1.7, "tiles"},
    {"Reindeer Jerky Trail Packs", "Sårensby Depot", 0.23, "packs"},
{"Reindeer Jerky Trail Packs", "Sårensby Depot", 0.23, "packs"},
    {"Caledonian Cured Ham", "Sårensby Depot", 6.9, "hams"},
{"Caledonian Cured Ham", "Sårensby Depot", 6.9, "hams"},
    {"Sturgeon Caviar", "Sårensby Depot", 9.8, "tins"},
{"Sturgeon Caviar", "Sårensby Depot", 9.8, "tins"},
    {"Frozen Whitefish Fillets", "Sårensby Depot", 0.64, "trays"},
{"Frozen Whitefish Fillets", "Sårensby Depot", 0.64, "trays"},
    {"Processed Wild Duck Feathers", "Sårensby Depot", 0.36, "bundles"},
{"Processed Wild Duck Feathers", "Sårensby Depot", 0.36, "bundles"},
    {"Textiles (Woolen Shawls)", "Sårensby Depot", 0.47, "folds"},
{"Textiles (Woolen Shawls)", "Sårensby Depot", 0.47, "folds"},
    {"Medicinal Root Extracts", "Sårensby Depot", 0.59, "bottles"},
{"Medicinal Root Extracts", "Sårensby Depot", 0.59, "bottles"},
    {"Recovered Machine Parts (Green Sector)", "Sårensby Depot", 2.1, "crates"},
{"Recovered Machine Parts (Green Sector)", "Sårensby Depot", 2.1, "crates"},
    {"Smuggled Caviar (Black Market)", "Sårensby Depot", 7.3, "tins"},
{"Smuggled Caviar (Black Market)", "Sårensby Depot", 7.3, "tins"},
    {"Specialty Fur Cloaks", "Sårensby Depot", 1.4, "garments"},
{"Specialty Fur Cloaks", "Sårensby Depot", 1.4, "garments"},
    {"Rye Flour (Stone Milled)", "Sårensby Depot", 0.33, "sacks"},
{"Rye Flour (Stone Milled)", "Sårensby Depot", 0.33, "sacks"},
    {"Frozen Boar Cuts", "Sårensby Depot", 0.72, "cuts"},
{"Frozen Boar Cuts", "Sårensby Depot", 0.72, "cuts"},
    {"Wheat Grain (Northern Harvest)", "Sårensby Depot", 0.25, "bushels"},
{"Wheat Grain (Northern Harvest)", "Sårensby Depot", 0.25, "bushels"},
    {"Salt Blocks (Lake Caledonia)", "Sårensby Depot", 0.4, "bricks"},
{"Salt Blocks (Lake Caledonia)", "Sårensby Depot", 0.4, "bricks"},
    {"Hand-Forged Iron Tools", "Sårensby Depot", 0.58, "tools"},
{"Hand-Forged Iron Tools", "Sårensby Depot", 0.58, "tools"},
    {"Frozen Pike Roe (Bulk)", "Sårensby Depot", 2.7, "jars"},
{"Frozen Pike Roe (Bulk)", "Sårensby Depot", 2.7, "jars"},
    {"Pilotage Scheduling", "Haifa Compliance Exchange", 0.42, "transits"},
{"Pilotage Scheduling", "Haifa Compliance Exchange", 0.42, "transits"},
    {"Straits Passage Documentation (Certified)", "Haifa Compliance Exchange", 0.33, "folios"},
{"Straits Passage Documentation (Certified)", "Haifa Compliance Exchange", 0.33, "folios"},
    {"Tonnage Declaration Bonds", "Haifa Compliance Exchange", 1.1, "contracts"},
{"Tonnage Declaration Bonds", "Haifa Compliance Exchange", 1.1, "contracts"},
    {"Cargo Seal Verification (War League Escort)", "Haifa Compliance Exchange", 0.55, "checks"},
{"Cargo Seal Verification (War League Escort)", "Haifa Compliance Exchange", 0.55, "checks"},
    {"Sacred Buffer Compliance Certificates", "Haifa Compliance Exchange", 0.46, "stamps"},
{"Sacred Buffer Compliance Certificates", "Haifa Compliance Exchange", 0.46, "stamps"},
    {"Environmental Buffer Routing Plans", "Haifa Compliance Exchange", 0.62, "charts"},
{"Environmental Buffer Routing Plans", "Haifa Compliance Exchange", 0.62, "charts"},
    {"Emergency Leviathan Protocol Insurance", "Haifa Compliance Exchange", 1.7, "policies"},
{"Emergency Leviathan Protocol Insurance", "Haifa Compliance Exchange", 1.7, "policies"},
    {"Search-and-Rescue Priority Registration", "Haifa Compliance Exchange", 0.83, "slots"},
{"Search-and-Rescue Priority Registration", "Haifa Compliance Exchange", 0.83, "slots"},
    {"Anchorage Review Mediation (Expedited)", "Haifa Compliance Exchange", 0.95, "hearings"},
{"Anchorage Review Mediation (Expedited)", "Haifa Compliance Exchange", 0.95, "hearings"},
    {"Daily Enforcement Report Subscription", "Haifa Compliance Exchange", 0.22, "issues"},
{"Daily Enforcement Report Subscription", "Haifa Compliance Exchange", 0.22, "issues"},
    {"Freight Handling (per ton)", "Port of Corumia", 1.80, "tons"},
{"Freight Handling (per ton)", "Port of Corumia", 1.80, "tons"},
    {"Harbor Pilotage (per transit)", "Port of Corumia", 5.30, "transits"},
{"Harbor Pilotage (per transit)", "Port of Corumia", 5.30, "transits"},
    {"Drydock Berth (per day)", "Port of Corumia", 16.60, "days"},
{"Drydock Berth (per day)", "Port of Corumia", 16.60, "days"},
    {"Tug Assist (harbor move)", "Port of Corumia", 3.20, "moves"},
{"Tug Assist (harbor move)", "Port of Corumia", 3.20, "moves"},
    {"Customs Brokerage (filing)", "Port of Corumia", 1.850, "filings"},
{"Customs Brokerage (filing)", "Port of Corumia", 1.850, "filings"},
    {"Bonded Warehousing", "Port of Corumia", 0.52, "m³·day"},
{"Bonded Warehousing", "Port of Corumia", 0.52, "m³·day"},
    {"Cold Storage", "Port of Corumia", 0.68, "m³·day"},
{"Cold Storage", "Port of Corumia", 0.68, "m³·day"},
    {"Security Escort (quay-to-gate)", "Port of Corumia", 1.85, "escorts"},
{"Security Escort (quay-to-gate)", "Port of Corumia", 1.85, "escorts"},
    {"Quarantine Inspection (vessel)", "Port of Corumia", 2.70, "vessels"},
{"Quarantine Inspection (vessel)", "Port of Corumia", 2.70, "vessels"},
    {"Medical Clearance (per crew)", "Port of Corumia", 0.66, "crew"},
{"Medical Clearance (per crew)", "Port of Corumia", 0.66, "crew"},
    {"Vessel Berth Window (per hour reserved)", "Pentiad Terminal Operations", .340, "hours"},
{"Vessel Berth Window (per hour reserved)", "Pentiad Terminal Operations", .340, "hours"},
    {"Quay Crane Move (per container)", "Pentiad Terminal Operations", .150, "moves"},
{"Quay Crane Move (per container)", "Pentiad Terminal Operations", .150, "moves"},
    {"Breakbulk Stevedoring (per ton)", "Corytian Terminal Operations Agency", .110, "tons"},
{"Breakbulk Stevedoring (per ton)", "Corytian Terminal Operations Agency", .110, "tons"},
    {"Gate Processing Fee (per truck visit)", "Pentiad Terminal Operations", .055, "visits"},
{"Gate Processing Fee (per truck visit)", "Pentiad Terminal Operations", .055, "visits"},
    {"Dry Yard Storage (per TEU·day)", "Pentiad Terminal Operations", .040, "TEU·day"},
{"Dry Yard Storage (per TEU·day)", "Pentiad Terminal Operations", .040, "TEU·day"},
    {"Demurrage (per TEU·day beyond free time)", "Pentiad Terminal Operations", 0.80, "TEU·day"},
{"Demurrage (per TEU·day beyond free time)", "Pentiad Terminal Operations", 0.80, "TEU·day"},
    {"Reefer Plug-In (per container·day)", "Pentiad Terminal Operations", .090, "container·day"},
{"Reefer Plug-In (per container·day)", "Pentiad Terminal Operations", .090, "container·day"},
    {"Reefer Temperature Monitoring (per container·day)", "Pentiad Terminal Operations", .060, "container·day"},
{"Reefer Temperature Monitoring (per container·day)", "Pentiad Terminal Operations", .060, "container·day"},
    {"Rail Intermodal Transfer (per TEU)", "Pentiad Terminal Operations", .145, "TEU"},
{"Rail Intermodal Transfer (per TEU)", "Pentiad Terminal Operations", .145, "TEU"},
    {"Barge Transfer (per TEU)", "Pentiad Terminal Operations", .115, "TEU"},
{"Barge Transfer (per TEU)", "Pentiad Terminal Operations", .115, "TEU"},
    {"Documentation & EDI Processing (per bill)", "Pentiad Terminal Operations", .039, "bills"},
{"Documentation & EDI Processing (per bill)", "Pentiad Terminal Operations", .039, "bills"},
    {"ISPS Security Charge (per vessel call)", "Pentiad Terminal Operations", .170, "calls"},
{"ISPS Security Charge (per vessel call)", "Pentiad Terminal Operations", .170, "calls"},
    {"Harbor Pilot Boarding (Standard Transit)", "Azat Tug and Pilot Cooperative", .480, "transits"},
{"Harbor Pilot Boarding (Standard Transit)", "Azat Tug and Pilot Cooperative", .480, "transits"},
    {"Harbor Pilotage Extension (Night/Navigational Risk)", "Azat Tug and Pilot Cooperative", .330, "transits"},
{"Harbor Pilotage Extension (Night/Navigational Risk)", "Azat Tug and Pilot Cooperative", .330, "transits"},
    {"Escort Tug (Inbound Transit)", "Azat Tug and Pilot Cooperative", .240, "moves"},
{"Escort Tug (Inbound Transit)", "Azat Tug and Pilot Cooperative", .240, "moves"},
    {"Escort Tug (Outbound Transit)", "Azat Tug and Pilot Cooperative", .240, "moves"},
{"Escort Tug (Outbound Transit)", "Azat Tug and Pilot Cooperative", .240, "moves"},
    {"Azat Line Boat Support (Mooring/Unmooring)", "Azat Tug and Pilot Cooperative", .170, "deployments"},
-- (…rest of your existing service products…)
    {"Tug Assist (Turning Basin Maneuver)", "Azat Tug and Pilot Cooperative", .200, "maneuvers"},
{"Tribal – Somniumpolis–Odiferian Highlands", "Lothayan Skybridge Airways", 4.50, "tons"},
    {"Emergency Tow Response (Flat Rate)", "Azat Tug and Pilot Cooperative", .680, "responses"},
    {"Pilot Dispatch Cancellation Fee", "Azat Tug and Pilot Cooperative", .120, "cancellations"},
    {"Pilotage Slot Reservation (Peak Hours)", "Azat Tug and Pilot Cooperative", .260, "reservations"},
    {"Multi-Vessel Convoy Guidance (Straits)", "Azat Tug and Pilot Cooperative", .510, "convoys"},
    {"War-Risk Tug Escort (Haifa Exclusion Zone)", "Azat Tug and Pilot Cooperative", .700, "escort moves"},
    {"Docking Delay Standby Fee (per 30 minutes)", "Azat Tug and Pilot Cooperative", .150, "intervals"},
    {"Hull Inspection and Ultrasonic Survey", "Calliope Shipyard Repair Agency", .360, "calls"},
    {"Routine Hull Patching (Standard Plate)", "Calliope Shipyard Repair Agency", .580, "repairs"},
    {"Dry Dock Berth (per day)", "Calliope Shipyard Repair Agency", .1600, "days"},
    {"Propulsion Shaft Alignment (Standard Class)", "Calliope Shipyard Repair Agency", .720, "alignments"},
    {"Ballast Tank Cleaning and Recoating", "Calliope Shipyard Repair Agency", .850, "jobs"},
    {"Emergency Weld Team Dispatch", "Calliope Shipyard Repair Agency", .490, "calls"},
    {"Underwater ROV Survey (Sub-10m Draft)", "Calliope Shipyard Repair Agency", .660, "surveys"},
    {"Deck Equipment Overhaul (Winches & Davits)", "Calliope Shipyard Repair Agency", .440, "units"},
    {"Cold-Ironing System Repair", "Calliope Shipyard Repair Agency", .670, "systems"},
    {"Lifeboat System Inspection & Recertification", "Calliope Shipyard Repair Agency", .290, "systems"},
    {"Steel Renewal (per metric ton)", "Calliope Shipyard Repair Agency", .120, "tons"},
    {"Hybrid Propulsion Diagnostics (Multi-Fuel Systems)", "Calliope Shipyard Repair Agency", .530, "sessions"},
    {"Hull and Machinery Insurance (Standard Transit)", "Bulhanu Maritime Insurance Association", .280, "policies"},
    {"War Risk Hull Extension (Haifa Corridor Zone)", "Bulhanu Maritime Insurance Association", .340, "endorsements"},
    {"Protection & Indemnity (Straits Compliant)", "Bulhanu Maritime Insurance Association", .310, "contracts"},
    {"Freight, Demurrage & Defense (FDD) Coverage", "Bulhanu Maritime Insurance Association", .260, "policies"},
    {"General Average Guarantee Bond", "Bulhanu Maritime Insurance Association", .20, "bonds"},
    {"Environmental Buffer Spill Liability Coverage", "Bulhanu Maritime Insurance Association", .290, "policies"},
    {"Terrorism & Sabotage Coverage (Portside)", "Bulhanu Maritime Insurance Association", 3.60, "endorsements"},
    {"Cargo Delay Indemnity (Per Voyage Contract)", "Bulhanu Maritime Insurance Association", .170, "contracts"},
    {"Voyage Cancellation Refund Guarantee", "Bulhanu Maritime Insurance Association", .240, "guarantees"},
    {"Crew Repatriation & Illness Indemnity", "Bulhanu Maritime Insurance Association", .190, "policies"},
    {"Charter Party Breach Risk Mitigation (Vaeringheim Court)", "Bulhanu Maritime Insurance Association", .450, "agreements"},
    {"Marine Arbitration Retainer (Tier II Cases)", "Bulhanu Maritime Insurance Association", .210, "retainers"},
    {"Customs Clearance Filing (Standard Entry)", "Morovian Customs & Freight Syndicate", 1.10, "filings"},
    {"Tariff Classification Advisory (per commodity)", "Morovian Customs & Freight Syndicate", 0.60, "consultations"},
    {"Bonded Warehouse Transfer (Inward Entry)", "Morovian Customs & Freight Syndicate", 0.80, "transfers"},
    {"Freight Forwarding (Port-to-Gate, Domestic)", "Morovian Customs & Freight Syndicate", 1.50, "contracts"},
    {"Freight Forwarding (Cross-Straits, Interport)", "Morovian Customs & Freight Syndicate", 2.90, "contracts"},
    {"Cargo Consolidation (LCL Containerized)", "Morovian Customs & Freight Syndicate", 1.40, "shipments"},
    {"Cargo Deconsolidation & Palletization", "Morovian Customs & Freight Syndicate", 1.10, "shipments"},
    {"Duty Suspension Arrangement (Transit Cargo)", "Morovian Customs & Freight Syndicate", 0.95, "agreements"},
    {"Customs Escort Assignment (Risk Tier II+)", "Morovian Customs & Freight Syndicate", 1.85, "assignments"},
    {"Import License Facilitation (Non-Standard Goods)", "Morovian Customs & Freight Syndicate", 2.10, "licenses"},
    {"Voucher Redemption Processing (Cultic Commodities)", "Morovian Customs & Freight Syndicate", 1.75, "cases"},
    {"Sanctioned Cargo Screening Compliance Report", "Morovian Customs & Freight Syndicate", 2.60, "reports"},
    {"Pod Training & Conditioning (per dolphin·month)", "Nefelean Seas Armory", 2.40, "months"}, 
    {"Operational Escort Deployment (per convoy)", "Nefelean Seas Armory", 5.80, "convoys"}, 
    {"Mine & Diver Interdiction Patrol (per sortie)", "Nefelean Seas Armory", 3.20, "sorties"}, 
    {"Reconnaissance Sweep (echolocation grid, per km²)", "Nefelean Seas Armory", 1.75, "km²"}, 
    {"Sonic Disruption Support (counter-sonar, per hour)", "Nefelean Seas Armory", 0.95, "hours"}, 
    {"Emergency Response Pod Dispatch (flat rate)", "Nefelean Seas Armory", 4.60, "responses"}, 
    {"Harbor Defense Stationing (per pod·week)", "Nefelean Seas Armory", 6.20, "weeks"}, 
    {"Convoy Readiness Drills (joint exercise, per session)", "Nefelean Seas Armory", 2.10, "sessions"}, 
    {"Target Mark & Tag (submersible tracking, per operation)", "Nefelean Seas Armory", 1.85, "operations"}, 
    {"Specialized Payload Delivery (per assignment)", "Nefelean Seas Armory", 3.90, "assignments"},
    {"Bilge & Canal Pump-Out and Disposal (per cubic meter)", "Morovian Sanitation and Bilge Company", .085, "m³"},
    {"Ratproofing Certification (per facility·month)", "Morovian Sanitation and Bilge Company", .120, "months"},
    {"Canal & Irrigation Flush Coordination (per sluice·operation)", "Morovian Sanitation and Bilge Company", .340, "operations"},
    {"Facility Decontamination & Terminal Sanitation (per site call)", "Morovian Sanitation and Bilge Company", .210, "calls"},
    {"Vector Abatement Spray (per hectare)", "Morovian Sanitation and Bilge Company", .060, "ha"},
    {"Mosquito Larvicide Application (per water basin)", "Morovian Sanitation and Bilge Company", .055, "basins"},
    {"Snail Habitat Elimination (per irrigation channel·km)", "Morovian Sanitation and Bilge Company", .075, "km"},
    {"Medical Waste Incineration (per kg)", "Morovian Sanitation and Bilge Company", .065, "kg"},
    {"Emergency Spill & Contamination Response (flat rate)", "Morovian Sanitation and Bilge Company", .720, "responses"},
    {"Wastewater Pathogen Monitoring (per assay)", "Morovian Sanitation and Bilge Company", .125, "assays"},
    {"Cistern Shock Chlorination (per cistern)", "Morovian Sanitation and Bilge Company", .050, "cisterns"},
    {"Potable-Water Chlorination Dosing & Certification (per 100 m³)", "Morovian Sanitation and Bilge Company", .040, "100 m³"},
    {"Food-Handler Hygiene Audits & Licensing (per kitchen·stall)", "Morovian Sanitation and Bilge Company", .065, "inspections"},
    {"Rodent Trap Deployment & Monitoring (per trap·month)", "Morovian Sanitation and Bilge Company", .022, "months"},
    {"Hand-Wash Station Deployment & Service (per unit·day)", "Morovian Sanitation and Bilge Company", .030, "unit·day"},
    {"Highland Route Guidance (Merchant Convoy Escort)", "Ordo Ebríumä Oneira (Highland Guides)", 2.80, "routes"},
    {"Pilgrim Procession Escort (Seasonal)", "Ordo Ebríumä Oneira (Highland Guides)", 1.45, "processions"},
    {"Ridge Ropeway Licensing & Certification", "Ordo Ebríumä Oneira (Highland Guides)", 3.10, "licenses"},
    {"Avalanche Risk Survey & Signage", "Ordo Ebríumä Oneira (Highland Guides)", 2.60, "surveys"},
    {"Highland Rescue Team Dispatch (Emergency)", "Ordo Ebríumä Oneira (Highland Guides)", 4.90, "responses"},
    {"Pack Stock Portage (Caravan Animals Included)", "Ordo Ebríumä Oneira (Highland Guides)", 3.25, "contracts"},
    {"Cairn and Trail Maintenance (Vow Renewal Service)", "Ordo Ebríumä Oneira (Highland Guides)", 1.75, "sites"},
    {"Tar-Lamp Night Vigil Coverage", "Ordo Ebríumä Oneira (Highland Guides)", 0.85, "nights"},
    {"Stone-Reader Boundary Arbitration", "Ordo Ebríumä Oneira (Highland Guides)", 1.10, "hearings"},
    {"Weather Observation & Route Planning Consultancy", "Ordo Ebríumä Oneira (Highland Guides)", 0.95, "reports"},
    {"Shrine-Stair Reconstruction Crew Hire", "Ordo Ebríumä Oneira (Highland Guides)", 2.40, "projects"},
    {"Eclipse Silent-Watch Contract (Seasonal Oath)", "Ordo Ebríumä Oneira (Highland Guides)", 1.30, "events"},
    {"Passenger – Haifan Mainline (Lykopolis–Lewisburg)", "Lothayan Skybridge Airways", 0.95, "passengers"},
    {"Passenger – Haifan Branchline Pilgrim (Tel-Amin–Diamandis–Thermosalem)", "Lothayan Skybridge Airways", 0.70, "passengers"},
    {"Passenger – Somniumpolis–Aureum–Erythros", "Lothayan Skybridge Airways", 1.35, "passengers"},
    {"Passenger – Erythros–Pyralis Connector", "Lothayan Skybridge Airways", 1.10, "passengers"},
    {"Passenger – Shrine Pilgrimage (Erythros–Nexa–Delphica–Saluria)", "Lothayan Skybridge Airways", 1.05, "passengers"},
    {"Passenger – Canyonlands Night (Acheron–Koinonía–Sylvapolis)", "Lothayan Skybridge Airways", 1.20, "passengers"},
    {"Passenger – Skýrophos–Vaeringheim–Jogi", "Lothayan Skybridge Airways", 1.10, "passengers"},
    {"Passenger – Cultural Circuit (Symphonara–Delphica–Aurelia–Serena)", "Lothayan Skybridge Airways", 1.80, "passengers"},
    {"Passenger – Skýrophos–Pelagia Fjordline", "Lothayan Skybridge Airways", 1.05, "passengers"},
    {"Passenger – Norsolyra–Thorsalon–Rein", "Lothayan Skybridge Airways", 1.15, "passengers"},
    {"Passenger – Highlands (Bjornopolis–Aegirheim–Ephyra–Myrene)", "Lothayan Skybridge Airways", 1.20, "passengers"},
    {"Passenger – Normark Ferry (Riddersborg–Ardclach)", "Lothayan Skybridge Airways", 1.05, "passengers"},
    {"Passenger – Worker Line (Bashkim–Ourid–Aetherium)", "Lothayan Skybridge Airways", 1.25, "passengers"},
    {"Passenger – Coastal Connector (Slevik-Skýrophos–Somniumpolis)", "Lothayan Skybridge Airways", 1.25, "passengers"},
    {"Charter – Ecclesiastical (Lunalis Sancta–Catonis Atrium)", "Lothayan Skybridge Airways", 5.90, "charters"},
    {"Charter – Trans-Keltian Diplomatic (Sårensby–Elijah’s Rest)", "Lothayan Skybridge Airways", 6.90, "charters"},
    {"Freight – Haifan Littoral (Lykopolis–Sufriya–Mylecia)", "Lothayan Skybridge Airways", 4.10, "tons"},
    {"Freight – Industrial (Vaeringheim–Ferrum Citadel)", "Lothayan Skybridge Airways", 4.75, "tons"},
    {"Mail – Haifan Coastal Loop (Keybir-Aviv–Tel-Amin–Jogi–Abeis–Blore Heath)", "Lothayan Skybridge Airways", 2.30, "contracts"},
    {"Tribal – Somniumpolis–Odiferian Highlands", "Lothayan Skybridge Airways", 4.50, "tons"},
 
 
}
}


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


---------------------------------------------------------
---------------------------------------------------------
-- simulatePriceChange
-- simulatePriceChange (unchanged behavior / rounding)
-- Applies a daily random factor; special date events
-- add a small positive boost to the final price.
---------------------------------------------------------
---------------------------------------------------------
local function simulatePriceChange(basePrice, dayOfMonth, month)
local function simulatePriceChange(basePrice, dayOfMonth, month)
    local dateKey = string.format("%d,%d", month, dayOfMonth)
local dateKey = string.format("%d,%d", month, dayOfMonth)
    local changeFactor = math.random(-20, 20) / 100
local changeFactor = math.random(-20, 20) / 100
    local explanation
local explanation


    if events[dateKey] then
if events[dateKey] then
        explanation = events[dateKey] .. ": Prices influenced by event dynamics."
explanation = events[dateKey] .. ": Prices influenced by event dynamics."
        changeFactor = changeFactor + 0.05 -- small event-based boost
changeFactor = changeFactor + 0.05
    else
else
        explanation = "General market fluctuations."
explanation = "General market fluctuations."
    end
end


    local newPrice = math.floor((basePrice * (1 + changeFactor)) * 100) / 100
local newPrice = math.floor((basePrice * (1 + changeFactor)) * 100) / 100
    return newPrice, changeFactor, explanation
return newPrice, changeFactor, explanation
end
end


---------------------------------------------------------
---------------------------------------------------------
-- determinePriceLevel
-- determinePriceLevel (swapped logic retained)
-- Swapped so that:
--  adjustedPrice > basePrice ⇒ "Low"
--  adjustedPrice < basePrice ⇒ "High"
--  otherwise ⇒ "Standard"
---------------------------------------------------------
---------------------------------------------------------
local function determinePriceLevel(basePrice, adjustedPrice)
local function determinePriceLevel(basePrice, adjustedPrice)
    if adjustedPrice > basePrice then
if adjustedPrice > basePrice then
        return "Low"
return "Low"
    elseif adjustedPrice < basePrice then
elseif adjustedPrice < basePrice then
        return "High"
return "High"
    else
else
        return "Standard"
return "Standard"
    end
end
end
 
---------------------------------------------------------
-- Args helpers (modes)
---------------------------------------------------------
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
end


---------------------------------------------------------
---------------------------------------------------------
-- Main function: generateTable
-- Main function: generateTable (summary + breakdown)
-- Seeds random daily, then builds table with row coloring
---------------------------------------------------------
---------------------------------------------------------
function p.generateTable()
function p.generateTable(frame)
    -- Seed randomness
local args = getArgs(frame)
    local localTime = os.date("*t")
local mode = tostring(args.mode or "both"):lower()  -- both | summary | breakdown
    local dailySeed = localTime.year * 1000 + localTime.yday
local collapse = not isNo(args.collapse)            -- default true
    math.randomseed(dailySeed)
 
local showSummary = (mode == "both" or mode == "summary")
local showBreakdown = (mode == "both" or mode == "breakdown")
 
-- Seed randomness (stable for the day)
local localTime = os.date("*t")
local dailySeed = localTime.year * 1000 + localTime.yday
math.randomseed(dailySeed)
 
-- Date
local dateString, dayOfMonth, month = getCurrentDate()
 
-- Tables
local out = ""
 
local summary = ""
if showSummary then
summary =
"{| class=\"wikitable sortable\"\n" ..
"! Date (Day/Month/Year [[PSSC]]) !! Δ !! Product !! Producing 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 (Day/Month/Year [[PSSC]]) !! Product !! Producing Company !! Base Price !! Price Level !! Tier III Price !! Tier II Price !! Tier I Price !! Units !! Explanation\n"
end
 
-- Averages
local totalBase, totalNew, count = 0, 0, 0
 
for _, product in ipairs(products) do
local name, company, basePrice, units = unpack(product)


    -- Retrieve date
local newPrice, _, explanation = simulatePriceChange(basePrice, dayOfMonth, month)
    local dateString, dayOfMonth, month = getCurrentDate()
local priceLevel = determinePriceLevel(basePrice, newPrice)
local sym = levelSymbol(priceLevel)


    -- Table header
local rowStyle
    local wikitable =
if priceLevel == "Low" then
        "{| class=\"wikitable\"\n" ..
rowStyle = ' style="background-color:lightblue;"'
        "! Date (Day/Month/Year [[PSSC]]) !! Product !! Producing Company !! Base Price !! Price Level !! Tier III Price !! Tier II Price !! Tier I Price !! Units !! Explanation\n"
elseif priceLevel == "Standard" then
rowStyle = ' style="background-color:lightgreen;"'
else
rowStyle = ' style="background-color:#ffcccb;"'
end


    -- Track totals for averages
local tierIIIPrice = math.floor((newPrice / 3) * 100) / 100
    local totalBase, totalNew, count = 0, 0, 0
local tierIIPrice  = math.floor((newPrice * 2 / 3) * 100) / 100
local tierIPrice  = newPrice


    -- Iterate products
totalBase = totalBase + basePrice
    for _, product in ipairs(products) do
totalNew  = totalNew + newPrice
        local name, company, basePrice, units = unpack(product)
count = count + 1
        local newPrice, _, explanation = simulatePriceChange(basePrice, dayOfMonth, month)
        local priceLevel = determinePriceLevel(basePrice, newPrice)


        -- Choose row color
if showSummary then
        local rowStyle
summary = summary .. string.format(
        if priceLevel == "Low" then
"|-%s\n| %s || %s || %s || %s || %.2f || %s || %s\n",
            rowStyle = ' style="background-color:lightblue;"'
rowStyle, dateString, sym, name, company, tierIPrice, units, explanation
        elseif priceLevel == "Standard" then
)
            rowStyle = ' style="background-color:lightgreen;"'
end
        else
            rowStyle = ' style="background-color:#ffcccb;"'  -- light red
        end


        -- Compute tiers
if showBreakdown then
        local tierIIIPrice = math.floor((newPrice / 3) * 100) / 100
breakdown = breakdown .. string.format(
        local tierIIPrice = math.floor((newPrice * 2 / 3) * 100) / 100
"|-%s\n| %s || %s || %s || %.2f || %s || %.2f || %.2f || %.2f || %s || %s\n",
        local tierIPrice  = newPrice
rowStyle, dateString, name, company, basePrice, priceLevel,
tierIIIPrice, tierIIPrice, tierIPrice, units, explanation
)
end
end


        -- Accumulate totals
local avgBase = totalBase / count
        totalBase = totalBase + basePrice
local avgNew = totalNew / count
        totalNew = totalNew + newPrice
        count = count + 1


        -- Insert colored row
local avgLevel
        wikitable = wikitable .. string.format(
if avgNew > avgBase then
            "|-%s\n| %s || %s || %s || %.2f || %s || %.2f || %.2f || %.2f || %s || %s\n",
avgLevel = "Low"
            rowStyle, dateString, name, company, basePrice,
elseif avgNew < avgBase then
            priceLevel, tierIIIPrice, tierIIPrice, tierIPrice, units, explanation
avgLevel = "High"
        )
else
    end
avgLevel = "Standard"
end
local avgSym = levelSymbol(avgLevel)


    -- Compute averages
if showSummary then
    local avgBase = totalBase / count
summary = summary .. string.format(
    local avgNew  = totalNew / count
"|-\n! colspan=\"7\" | Average adjusted (%.2f) vs base (%.2f): %s %s\n|}\n",
    local averagePriceLevel
avgNew, avgBase, avgSym, avgLevel
    if avgNew > avgBase then
)
        averagePriceLevel = "Low"
out = out .. summary .. "\n"
    elseif avgNew < avgBase then
end
        averagePriceLevel = "High"
    else
        averagePriceLevel = "Standard"
    end


    -- Final row
if showBreakdown then
    wikitable = wikitable .. string.format(
breakdown = breakdown .. string.format(
        "|-\n! colspan=\"10\" | Average adjusted price (%.2f) compared to average base price (%.2f) ⇒ **%s**\n",
"|-\n! colspan=\"10\" | Average adjusted (%.2f) vs base (%.2f): %s %s\n|}\n",
        avgNew, avgBase, averagePriceLevel
avgNew, avgBase, avgSym, avgLevel
    )
)
out = out .. breakdown
end


    -- Close table
return out
    wikitable = wikitable .. "|}"
end
    return wikitable
 
---------------------------------------------------------
-- 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
end


return p
return p

Revision as of 18:43, 29 December 2025

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

---------------------------------------------------------
-- Module:AutoUpdateServPrices
-- Generates a daily-updated services-sector price table.
--
-- Display (Dec 2025):
--  • Summary table (Tier I headline) + Δ symbol column (↑ Low / ↓ High / • Standard)
--  • Collapsible full breakdown table (Base/Level/Tiers)
--  • Modes so editors can force full expanded output when updating/auditing
--
-- Usage:
--   {{#invoke:AutoUpdateServPrices|generateTable}}
--     - default: summary + collapsed breakdown
--   {{#invoke:AutoUpdateServPrices|generateTable|mode=summary}}
--     - summary only
--   {{#invoke:AutoUpdateServPrices|generateTable|mode=breakdown}}
--     - breakdown only (collapsed by default)
--   {{#invoke:AutoUpdateServPrices|generateTable|mode=breakdown|collapse=no}}
--     - breakdown only (expanded)
--   {{#invoke:AutoUpdateServPrices|full}}
--     - breakdown only (expanded) convenience function
---------------------------------------------------------

local p = {}

---------------------------------------------------------
-- getCurrentDate
-- Returns today's date in PSSC format,
-- along with dayOfMonth and month for daily logic.
---------------------------------------------------------
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

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

---------------------------------------------------------
-- Product data (unchanged)
---------------------------------------------------------
local products = {
	{"Draped Flag Linens (Foreign Vessels)", "Lake Morovia Blockade Fund - Hatch Ministry", 1.40, "sheets"},
	{"Dismantled Minting Equipment", "Lake Morovia Blockade Fund - Hatch Ministry", .7, "assemblies"},
	{"Decertified Seal Stamps (Foreign Commissions)", "Lake Morovia Blockade Fund - Hatch Ministry", 1.9, "sets"},
	{"Declassified Naval Cargo Covers", "Lake Morovia Blockade Fund - Hatch Ministry", 6.0, "tarps"},
	{"Confiscated Calibration Weights", "Lake Morovia Blockade Fund - Hatch Ministry", 8.8, "sets"},
	{"Crated Trade Uniforms (Non-Domestic Origin)", "Lake Morovia Blockade Fund - Hatch Ministry", 1.30, "articles"},
	{"Defaced Customs Plaques", "Lake Morovia Blockade Fund - Hatch Ministry", 1.7, "plaques"},
	{"Baled Promotional Ephemera", "Lake Morovia Blockade Fund - Hatch Ministry", 4.80, "kg"},
	{"Foreign Coinage (Struck Before Blockade)", "Lake Morovia Blockade Fund - Hatch Ministry", 3.1, "coins"},
	{"Embroidered Foreign Diplomatic Standards", "Lake Morovia Blockade Fund - Hatch Ministry", 4, "banners"},
	{"Blocked Port Registry Books", "Lake Morovia Blockade Fund - Hatch Ministry", 1.2, "ledgers"},
	{"Disassembled Broadcast Relays", "Lake Morovia Blockade Fund - Hatch Ministry", 6, "units"},
	{"Stamps (Confiscated)", "Lake Morovia Blockade Fund - Hatch Ministry", 7.0, "sheets"},
	{"Confiscated Trade Crates", "Hatch Ministry", 1.1, "units"},
	{"Mixed Merchant Cargo", "Hatch Ministry", 5.2, "tons"},
	{"Captured Textiles (Raw & Finished)", "Hatch Ministry", 3.40, "bolts"},
	{"Illicit Grain Stores", "Hatch Ministry", 3.6, "tons"},
	{"Contraband Alcohol", "Hatch Ministry", 1.1, "bottles"},
	{"Seized Foreign Coinage", "Hatch Ministry", 10, "coins"},
	{"Recovered Cargo Manifests", "Hatch Ministry", 3.33, "scrolls"},
	{"Bulk Dyes and Spices (Unmarked Origin)", "Hatch Ministry", 7.220, "kg"},
	{"Captured Livestock (Deck Transport)", "Hatch Ministry", 2.6, "head"},
	{"Foreign Trade Seals and Emblems", "Hatch Ministry", 1.22, "sets"},
	{"Unregistered Luxury Cargo", "Hatch Ministry", 1.4, "tons"},
	{"Recovered Safe Boxes", "Hatch Ministry", .7, "chests"},
	{"Stamped Silver Bars", "Hatch Ministry", 3.90, "kg"},
	{"Captured Naval Uniforms and Insignia", "Hatch Ministry", 5.5, "sets"},
	{"Lost Port Authority Documents", "Hatch Ministry", 1.4, "scrolls"},
	{"High-Value Personal Effects", "Hatch Ministry", 6.8, "items"},
	{"Private Letters and Ship Logs", "Hatch Ministry", 4.1, "volumes"},
	{"Faces", "Maritime Guild of the Cult of Maskmakers", 0.03, "masks"},
	{"Spies", "Ergonian Spy Agency", 0.01, "assignments"},
	{"Missionaries of the Order Aurora Mystica", "Temple Bank of the Reformed Stripping Path", 0.05, "teams"},
	{"Missionaries of Harmony Sanctum", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
	{"Missionaries of Ignis Aeternum", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
	{"Missionaries of Celestial Harmony Sect", "Temple Bank of the Reformed Stripping Path", 0.08, "teams"},
	{"Missionaries of the Guild of Golden Shadows", "Temple Bank of the Reformed Stripping Path", 0.05, "teams"},
	{"Missionaries of the Azure Sentinel Sect", "Temple Bank of the Reformed Stripping Path", 0.01, "teams"},
	{"Missionaries of Reverie Nebulous", "Temple Bank of the Reformed Stripping Path", 0.10, "teams"},
	{"Missionaries of the Eon Fellowship", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
	{"Missionaries of the Order of the Umbral Oracle", "Temple Bank of the Reformed Stripping Path", 0.07, "teams"},
	{"Missionaries of the Mystery of the Verdant Embrace", "Temple Bank of the Reformed Stripping Path", 0.10, "teams"},
	{"Missionaries of Conclace Illuminara", "Temple Bank of the Reformed Stripping Path", 0.02, "teams"},
	{"Missionaries of Sanctum Vitalis", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
	{"Missionaries of Temple Alabaster", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
	{"Missionaries of the Court of the Ironclad", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
	{"Missionaries of Concord Accordia", "Temple Bank of the Reformed Stripping Path", 0.02, "teams"},
	{"Missionaries of the Mystery of the Stygian Veil", "Temple Bank of the Reformed Stripping Path", 0.03, "teams"},
	{"Missionaries of the Sylvan Fellowship", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
	{"Missionaries of the Mystery of Red Mirth", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
	{"Missionaries of Rex Catonis", "Temple Bank of the Reformed Stripping Path", 0.07, "teams"},
	{"Missionaries of Sanctum Delphica", "Temple Bank of the Reformed Stripping Path", 0.09, "teams"},
	{"Missionaries of Ordo Amictia", "Temple Bank of the Reformed Stripping Path", 0.06, "teams"},
	{"Missionaries of Temple Illuminata", "Temple Bank of the Reformed Stripping Path", 0.05, "teams"},
	{"Couriers", "Couriers of the Lizard Queen", 0.04, "dispatches"},
	{"Wisp Ward Talismans", "Couriers of the Lizard Queen", 0.10, "amulets"},
	{"Credit Hours", "Temple University of Delphica", 3.00, "credits"},
	{"Circuses", "La Sái Ebile", 0.24, "venues"},
	{"Performances", "La Sái Ebile", 0.11, "acts"},
	{"Passenger Rail Tickets", "Trans-Morovian Express", 1.2, "tickets"},
	{"Luxury Cabin Reservations", "Trans-Morovian Express", 4.5, "cabins"},
	{"Freight Car Leasing Contracts", "Trans-Morovian Express", .60, "agreements"},
	{"Overland Courier Deliveries", "Trans-Morovian Express", .23, "parcels"},
	{"Secure Cargo Vaults", "Trans-Morovian Express", .39, "units"},
	{"Customs Bypass Licenses", "Trans-Morovian Express", .71, "permits"},
	{"Railway Advertising Rights", "Trans-Morovian Express", .18, "slots"},
	{"Timetable Access Codes", "Trans-Morovian Express", .5, "keys"},
	{"Locomotive Repair Services", "Trans-Morovian Express", .57, "contracts"},
	{"Historical Route Tours", "Trans-Morovian Express", .20, "tours"},
	{"Private Charter Lines", "Trans-Morovian Express", .84, "routes"},
	{"Coal Tender Refills", "Trans-Morovian Express", .33, "loads"},
	{"Hellhound (scout)", "Hellhound Breeders of Dragevik", 0.03, "hounds"},
	{"Hellhound (soldier)", "Hellhound Breeders of Dragevik", 0.05, "hounds"},
	{"Hellhound (spy)", "Hellhound Breeders of Dragevik", 0.15, "hounds"},
	{"Priestesses of the Pharmacon Sect (Anti-Parasitic Medicine)", "Pharmacon Sect", 0.07, "doses"},
	{"Priestesses of the Pharmacon Sect (Antifungal/Respiratory Medicine)", "Pharmacon Sect", 0.08, "doses"},
	{"Priestesses of the Pharmacon Sect (Trauma/Battle Medicine)", "Pharmacon Sect", 0.09, "doses"},
	{"Priestesses of the Pharmacon Sect (Memory and Mind Treatment)", "Pharmacon Sect", 0.06, "doses"},
	{"Priestesses of the Pharmacon Sect (Immune Boost Medicine)", "Pharmacon Sect", 0.05, "doses"},
	{"Priestesses of the Pharmacon Sect (Respiratory Clearing Medicine)", "Pharmacon Sect", 0.05, "doses"},
	{"Priestesses of the Pharmacon Sect (Fertility and Childbirth Medicine)", "Pharmacon Sect", 0.04, "doses"},
	{"Priestesses of the Pharmacon Sect (Ritual Purification Incense)", "Pharmacon Sect", 0.03, "sticks"},
	{"Priestesses of the Pharmacon Sect (Medicinal Alcohol)", "Pharmacon Sect", 0.02, "bottles"},
	{"Priestesses of the Pharmacon Sect (Detoxification Medicine)", "Pharmacon Sect", 0.05, "doses"},
	{"Security Contractors", "Skyrophian Security Contractors*", 0.03, "Assignments"},
	{"Postal Workers", "Haifadora Postal Service*", 0.1, "Assignments"},
	{"Recovered Treasure Chests", "Fleet of Rouge Divers", 6, "units"},
	{"Antique Pottery", "Fleet of Rouge Divers", 40, "pieces"},
	{"Salvaged Artifacts", "Fleet of Rouge Divers", 55, "items"},
	{"Driftwood Timber", "Fleet of Rouge Divers", 3.2, "tons"},
	{"Recovered Jewelry", "Fleet of Rouge Divers", 12, "sets"},
	{"Glassware (Recovered)", "Fleet of Rouge Divers", 90, "pieces"},
	{"Metal Ingots (Mixed)", "Fleet of Rouge Divers", 70, "kg"},
	{"Butterscotch Merchants", "Merchant Caravans of the Candy Kingdom", .36, "Caravans"},
	{"Chocolate Merchants", "Merchant Caravans of the Candy Kingdom", 1.13, "Caravans"},
	{"Candycane Merchants", "Merchant Caravans of the Candy Kingdom", 1.21, "Caravans"},
	{"Merchants of Unicorn Ivory", "Merchant Caravans of the Candy Kingdom", .033, "Caravans"},
	{"Wild Ice Cream Mochi", "Merchant Caravans of the Candy Kingdom", .73, "Caravans"},
	{"Farm-Raised Ice Cream Mochi", "Merchant Caravans of the Candy Kingdom", 1.35, "Caravans"},
	{"Public News Bulletins (Domestic)", "Bassaridian Broadcasting Corporation", 3.0, "broadcasts"},
	{"Cultural Programming Syndication", "Bassaridian Broadcasting Corporation", 2.5, "packages"},
	{"Religious Festival Audio Coverage", "Bassaridian Broadcasting Corporation", 1.7, "segments"},
	{"Foreign Language Radio Translation", "Bassaridian Broadcasting Corporation", 2.2, "programs"},
	{"Emergency Broadcast Override Services", "Bassaridian Broadcasting Corporation", 4.1, "networks"},
	{"Commercial Ad Placement (Tier II)", "Bassaridian Broadcasting Corporation", 1.8, "slots"},
	{"Live Event Broadcasting (Vaeringheim)", "Bassaridian Broadcasting Corporation", 6.5, "sessions"},
	{"Archival Audio Access (Public Use)", "Bassaridian Broadcasting Corporation", 0.9, "reels"},
	{"Broadcast Tower Leasing (Rural)", "Bassaridian Broadcasting Corporation", 5.0, "units"},
	{"Satellite Feed Subscription (Standard)", "Bassaridian Broadcasting Corporation", 3.6, "feeds"},
	{"Independent Musician Airplay Review", "Bassaridian Broadcasting Corporation", 1.1, "reviews"},
	{"Syndicated Talk Show Distribution", "Bassaridian Broadcasting Corporation", 2.4, "contracts"},
	{"Priestesses of the Ledger (Employee Loyalty Audits)", "Temple of Aprobelle", 2.7, "reports"},
	{"Watchful Priestesses (Real-Time Behavior Monitoring)", "Temple of Aprobelle", 9.5, "profiles"},
	{"Priestesses of Discourse (Disloyalty Flagging Alerts)", "Temple of Aprobelle", 8.1, "alerts"},
	{"Priestesses of the Veil (Insider Threat Screening)", "Temple of Aprobelle", 2.1, "cycles"},
	{"Priestesses of the Pulse (Routine Polygraph Sessions)", "Temple of Aprobelle", 2.3, "sessions"},
	{"Priestesses of the Mirror (Population Mood Tracking)", "Temple of Aprobelle", 6.8, "surveys"},
	{"Silencing Priestesses (Rumor Suppression Bulletins)", "Temple of Aprobelle", 3.5, "issues"},
	{"Resolute Priestesses (Anomaly Response Team Dispatches)", "Temple of Aprobelle", 0.14, "responses"},
	{"Priestesses of Encouragement (Whistleblower Reward Packages)", "Temple of Aprobelle", 0.55, "bonuses"},
	{"Camel Train Transport (Local Cargo)", "Keltian Steppe Caravan Company", 1.15, "tons"},
	{"Alperkin Couriers (Highland Legs)", "Keltian Steppe Caravan Company", 0.18, "dispatches"},
	{"Custom Caravan Escorts (Armed)", "Keltian Steppe Caravan Company", 0.25, "contracts"},
	{"Steppe Route Navigation Charts", "Keltian Steppe Caravan Company", 1.1, "scrolls"},
	{"Water Cache Delivery Refills", "Keltian Steppe Caravan Company", 0.46, "loads"},
	{"Salt Brick Exports (Packaged for Caravan)", "Keltian Steppe Caravan Company", 0.75, "blocks"},
	{"Dry Ridge Campground Leasing (Seasonal)", "Keltian Steppe Caravan Company", 3.5, "stations"},
	{"Pilgrim Caravans (Sacred Route Access)", "Keltian Steppe Caravan Company", 0.35, "convoys"},
	{"Seal of Safe Crossing (Alperkin Stamp)", "Keltian Steppe Caravan Company", 0.05, "marks"},
	{"Cross-Winds Risk Insurance (Tonar-Bashkim)", "Keltian Steppe Caravan Company", 0.29, "policies"},
	{"Iron Ingots (Refined)", "Sårensby Depot", 1.45, "tons"},
	{"Copper Scrap Bundles", "Sårensby Depot", 0.88, "crates"},
	{"Rare-Earth Ore Fragments", "Sårensby Depot", 2.3, "satchels"},
	{"Frozen Reindeer Cuts", "Sårensby Depot", 0.67, "packages"},
	{"Cured Reindeer Leather", "Sårensby Depot", 1.15, "hides"},
	{"Seal Fur Pelts", "Sårensby Depot", 2.8, "rolls"},
	{"Reindeer Antler Tools", "Sårensby Depot", 0.42, "sets"},
	{"Wool Blankets (Nordic Pattern)", "Sårensby Depot", 0.39, "bundles"},
	{"Smoked Elk Sausages", "Sårensby Depot", 0.51, "links"},
	{"Pickled Arctic Herring", "Sårensby Depot", 0.6, "jars"},
	{"Salted Cod (Barrel Aged)", "Sårensby Depot", 0.83, "barrels"},
	{"Smoked Goose Breast", "Sårensby Depot", 0.49, "cuts"},
	{"Seal Oil Lantern-Grade", "Sårensby Depot", 0.73, "flasks"},
	{"Whale Bone (Industrial Grade)", "Sårensby Depot", 1.95, "pieces"},
	{"Blubber Oil (Purified)", "Sårensby Depot", 1.2, "casks"},
	{"Wild Berry Preserves", "Sårensby Depot", 0.34, "jars"},
	{"Lingonberry Jam (Sweetened)", "Sårensby Depot", 0.27, "jars"},
	{"Conifer Lumber", "Sårensby Depot", 1.1, "planks"},
	{"Processed Granite Slabs", "Sårensby Depot", 1.7, "tiles"},
	{"Reindeer Jerky Trail Packs", "Sårensby Depot", 0.23, "packs"},
	{"Caledonian Cured Ham", "Sårensby Depot", 6.9, "hams"},
	{"Sturgeon Caviar", "Sårensby Depot", 9.8, "tins"},
	{"Frozen Whitefish Fillets", "Sårensby Depot", 0.64, "trays"},
	{"Processed Wild Duck Feathers", "Sårensby Depot", 0.36, "bundles"},
	{"Textiles (Woolen Shawls)", "Sårensby Depot", 0.47, "folds"},
	{"Medicinal Root Extracts", "Sårensby Depot", 0.59, "bottles"},
	{"Recovered Machine Parts (Green Sector)", "Sårensby Depot", 2.1, "crates"},
	{"Smuggled Caviar (Black Market)", "Sårensby Depot", 7.3, "tins"},
	{"Specialty Fur Cloaks", "Sårensby Depot", 1.4, "garments"},
	{"Rye Flour (Stone Milled)", "Sårensby Depot", 0.33, "sacks"},
	{"Frozen Boar Cuts", "Sårensby Depot", 0.72, "cuts"},
	{"Wheat Grain (Northern Harvest)", "Sårensby Depot", 0.25, "bushels"},
	{"Salt Blocks (Lake Caledonia)", "Sårensby Depot", 0.4, "bricks"},
	{"Hand-Forged Iron Tools", "Sårensby Depot", 0.58, "tools"},
	{"Frozen Pike Roe (Bulk)", "Sårensby Depot", 2.7, "jars"},
	{"Pilotage Scheduling", "Haifa Compliance Exchange", 0.42, "transits"},
	{"Straits Passage Documentation (Certified)", "Haifa Compliance Exchange", 0.33, "folios"},
	{"Tonnage Declaration Bonds", "Haifa Compliance Exchange", 1.1, "contracts"},
	{"Cargo Seal Verification (War League Escort)", "Haifa Compliance Exchange", 0.55, "checks"},
	{"Sacred Buffer Compliance Certificates", "Haifa Compliance Exchange", 0.46, "stamps"},
	{"Environmental Buffer Routing Plans", "Haifa Compliance Exchange", 0.62, "charts"},
	{"Emergency Leviathan Protocol Insurance", "Haifa Compliance Exchange", 1.7, "policies"},
	{"Search-and-Rescue Priority Registration", "Haifa Compliance Exchange", 0.83, "slots"},
	{"Anchorage Review Mediation (Expedited)", "Haifa Compliance Exchange", 0.95, "hearings"},
	{"Daily Enforcement Report Subscription", "Haifa Compliance Exchange", 0.22, "issues"},
	{"Freight Handling (per ton)", "Port of Corumia", 1.80, "tons"},
	{"Harbor Pilotage (per transit)", "Port of Corumia", 5.30, "transits"},
	{"Drydock Berth (per day)", "Port of Corumia", 16.60, "days"},
	{"Tug Assist (harbor move)", "Port of Corumia", 3.20, "moves"},
	{"Customs Brokerage (filing)", "Port of Corumia", 1.850, "filings"},
	{"Bonded Warehousing", "Port of Corumia", 0.52, "m³·day"},
	{"Cold Storage", "Port of Corumia", 0.68, "m³·day"},
	{"Security Escort (quay-to-gate)", "Port of Corumia", 1.85, "escorts"},
	{"Quarantine Inspection (vessel)", "Port of Corumia", 2.70, "vessels"},
	{"Medical Clearance (per crew)", "Port of Corumia", 0.66, "crew"},
	{"Vessel Berth Window (per hour reserved)", "Pentiad Terminal Operations", .340, "hours"},
	{"Quay Crane Move (per container)", "Pentiad Terminal Operations", .150, "moves"},
	{"Breakbulk Stevedoring (per ton)", "Corytian Terminal Operations Agency", .110, "tons"},
	{"Gate Processing Fee (per truck visit)", "Pentiad Terminal Operations", .055, "visits"},
	{"Dry Yard Storage (per TEU·day)", "Pentiad Terminal Operations", .040, "TEU·day"},
	{"Demurrage (per TEU·day beyond free time)", "Pentiad Terminal Operations", 0.80, "TEU·day"},
	{"Reefer Plug-In (per container·day)", "Pentiad Terminal Operations", .090, "container·day"},
	{"Reefer Temperature Monitoring (per container·day)", "Pentiad Terminal Operations", .060, "container·day"},
	{"Rail Intermodal Transfer (per TEU)", "Pentiad Terminal Operations", .145, "TEU"},
	{"Barge Transfer (per TEU)", "Pentiad Terminal Operations", .115, "TEU"},
	{"Documentation & EDI Processing (per bill)", "Pentiad Terminal Operations", .039, "bills"},
	{"ISPS Security Charge (per vessel call)", "Pentiad Terminal Operations", .170, "calls"},
	{"Harbor Pilot Boarding (Standard Transit)", "Azat Tug and Pilot Cooperative", .480, "transits"},
	{"Harbor Pilotage Extension (Night/Navigational Risk)", "Azat Tug and Pilot Cooperative", .330, "transits"},
	{"Escort Tug (Inbound Transit)", "Azat Tug and Pilot Cooperative", .240, "moves"},
	{"Escort Tug (Outbound Transit)", "Azat Tug and Pilot Cooperative", .240, "moves"},
	-- (…rest of your existing service products…)
	{"Tribal – Somniumpolis–Odiferian Highlands", "Lothayan Skybridge Airways", 4.50, "tons"},
}

---------------------------------------------------------
-- 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]",
}

---------------------------------------------------------
-- simulatePriceChange (unchanged behavior / rounding)
---------------------------------------------------------
local function simulatePriceChange(basePrice, dayOfMonth, month)
	local dateKey = string.format("%d,%d", month, dayOfMonth)
	local changeFactor = math.random(-20, 20) / 100
	local explanation

	if events[dateKey] then
		explanation = events[dateKey] .. ": Prices influenced by event dynamics."
		changeFactor = changeFactor + 0.05
	else
		explanation = "General market fluctuations."
	end

	local newPrice = math.floor((basePrice * (1 + changeFactor)) * 100) / 100
	return newPrice, changeFactor, explanation
end

---------------------------------------------------------
-- determinePriceLevel (swapped logic retained)
---------------------------------------------------------
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)
---------------------------------------------------------
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

---------------------------------------------------------
-- Main function: generateTable (summary + 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 (stable for the day)
	local localTime = os.date("*t")
	local dailySeed = localTime.year * 1000 + localTime.yday
	math.randomseed(dailySeed)

	-- Date
	local dateString, dayOfMonth, month = getCurrentDate()

	-- Tables
	local out = ""

	local summary = ""
	if showSummary then
		summary =
			"{| class=\"wikitable sortable\"\n" ..
			"! Date (Day/Month/Year [[PSSC]]) !! Δ !! Product !! Producing 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 (Day/Month/Year [[PSSC]]) !! Product !! Producing Company !! Base Price !! Price Level !! Tier III Price !! Tier II Price !! Tier I Price !! Units !! Explanation\n"
	end

	-- Averages
	local totalBase, totalNew, count = 0, 0, 0

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

		local newPrice, _, explanation = simulatePriceChange(basePrice, dayOfMonth, month)
		local priceLevel = determinePriceLevel(basePrice, newPrice)
		local sym = levelSymbol(priceLevel)

		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 tierIIIPrice = math.floor((newPrice / 3) * 100) / 100
		local tierIIPrice  = math.floor((newPrice * 2 / 3) * 100) / 100
		local tierIPrice   = newPrice

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

		if showSummary then
			summary = summary .. string.format(
				"|-%s\n| %s || %s || %s || %s || %.2f || %s || %s\n",
				rowStyle, dateString, sym, name, company, tierIPrice, units, explanation
			)
		end

		if showBreakdown then
			breakdown = breakdown .. string.format(
				"|-%s\n| %s || %s || %s || %.2f || %s || %.2f || %.2f || %.2f || %s || %s\n",
				rowStyle, dateString, name, company, basePrice, priceLevel,
				tierIIIPrice, tierIIPrice, tierIPrice, units, explanation
			)
		end
	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
	local avgSym = levelSymbol(avgLevel)

	if showSummary then
		summary = summary .. string.format(
			"|-\n! colspan=\"7\" | Average adjusted (%.2f) vs base (%.2f): %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 (%.2f) vs base (%.2f): %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

return p