-- seed data
            // we need to run the end of day report function for a single tenant to ensure it is picking up the tenant with the past next_eod_check_at and generating a report for that tenant and updating the next_eod_check_at field to the future and then we can query the reporting tables to confirm the report is generated correctly with the right data based on the orders we have in the system for that tenant
            // get the last inserted tenant id that is not deleted to ensure we are working with the correct tenant for the test
                $tenantId = $this->setUpNewBasicTenant();

                $outPut = $this->mockPdo->query("select COALESCE(MAX(id), 0) from food_order")->fetchColumn();
                $lastOrderId = (int)$outPut;
                $lastOrderId++;

                // get a user id to use for the order inserts
                $outPut = $this->mockPdo->query("select COALESCE(MAX(pk_user_id), 0) from user_login")->fetchColumn();
                $lastUserId = (int)$outPut;

                // date should be yesterday ad 13:00 to ensure it is within the opening hours and picked up by the reporting function

                $fiveDaysAgoAt1300  = (new DateTime('5 days ago', new \DateTimeZone('Europe/London')))->setTime(13, 0)->format('Y-m-d H:i:s');
                $fiveDaysAgoAt0000  = (new DateTime('5 days ago', new \DateTimeZone('Europe/London')))->setTime(0, 0)->format('Y-m-d H:i:s');
                $fiveDaysAgo        = (new DateTime('5 days ago', new \DateTimeZone('Europe/London')))->format('Y-m-d');
                $fourDaysAgoAt1300  = (new DateTime('4 days ago', new \DateTimeZone('Europe/London')))->setTime(13, 0)->format('Y-m-d H:i:s');
                $fourDaysAgoAt0000  = (new DateTime('4 days ago', new \DateTimeZone('Europe/London')))->setTime(0, 0)->format('Y-m-d H:i:s');
                $fourDaysAgo        = (new DateTime('4 days ago', new \DateTimeZone('Europe/London')))->format('Y-m-d');
                $threeDaysAgoAt1300 = (new DateTime('3 days ago', new \DateTimeZone('Europe/London')))->setTime(13, 0)->format('Y-m-d H:i:s');
                $threeDaysAgoAt0000 = (new DateTime('3 days ago', new \DateTimeZone('Europe/London')))->setTime(0, 0)->format('Y-m-d H:i:s');
                $threeDaysAgo       = (new DateTime('3 days ago', new \DateTimeZone('Europe/London')))->format('Y-m-d');
                $twoDaysAgoAt1300   = (new DateTime('2 days ago', new \DateTimeZone('Europe/London')))->setTime(13, 0)->format('Y-m-d H:i:s');
                $twoDaysAgoAt0000   = (new DateTime('2 days ago', new \DateTimeZone('Europe/London')))->setTime(0, 0)->format('Y-m-d H:i:s');
                $twoDaysAgo         = (new DateTime('2 days ago', new \DateTimeZone('Europe/London')))->format('Y-m-d');
                $yesterdayAt1300    = (new DateTime('yesterday', new \DateTimeZone('Europe/London')))->setTime(13, 0)->format('Y-m-d H:i:s');
                $yesterdayAt0000    = (new DateTime('yesterday', new \DateTimeZone('Europe/London')))->setTime(0, 0)->format('Y-m-d H:i:s');
                $yesterday          = (new DateTime('yesterday', new \DateTimeZone('Europe/London')))->format('Y-m-d');
                $todayAt0000        = (new DateTime('today', new \DateTimeZone('Europe/London')))->setTime(0, 0)->format('Y-m-d H:i:s');

                //$this->mockPdo->exec("INSERT INTO food_order    (id,            public_order_code,  user_id,             guest_user_id,  tenant_id,  delivery_address_id,    billing_address_id,     order_status,   order_type,     product_total_original_gross,  product_total_current_gross,    order_total_current_gross,      order_total_original_gross,     order_full_refund,      order_total_current_reason,                             payment_status,         delivery_fee_gross,     customer_service_fee_gross,         platform_fee_gross,       stripe_fee_total,   small_order_fee_gross,    comment,    tenant_comment,     currency,   transaction_id,                 refunded_id,    payment_intent_id,              stripe_receipt_url,     created_at,                 updated_at) 
                //                                    VALUES      ($lastOrderId,  'C02QD57Y',         $lastUserId,         NULL,           $ids[0],    2,                      NULL,                   'confirmed',    'delivery',     1040,                          1040,                           1290,                           1290,                           000,                   'Delivery Charge Applied, Admin Fee Applied',           'paid',                  200,                    050,                                050,                      062,                250,                     NULL,       '',                 'GBP',      'ch_3TCdZxDRk9nZ67Cn2c0uUuj9',  '',             'pi_3TCdZxDRk9nZ67Cn2DmYfS9d',  '',                     datetime('now', '-5 day'),  datetime('now', '-5 day'))");
                //$lastOrderId++;

                $this->mockPdo->exec("INSERT INTO food_order    (id,            public_order_code,  user_id,             guest_user_id,  tenant_id,  delivery_address_id,    billing_address_id,     order_status,   order_type,     product_total_original_gross,  product_total_current_gross,    order_total_current_gross,      order_total_original_gross,     order_full_refund,      order_total_current_reason,                             payment_status,         delivery_fee_gross,     customer_service_fee_gross,         platform_fee_gross,       stripe_fee_total,   small_order_fee_gross,    comment,    tenant_comment,     currency,   transaction_id,                 refunded_id,    payment_intent_id,              stripe_receipt_url,     created_at,                 updated_at) 
                                                    VALUES      ($lastOrderId,  'C02QD57Z',         $lastUserId,         NULL,           $tenantId,  2,                      NULL,                   'confirmed',    'delivery',     1540,                          1540,                           1790,                           1790,                           000,                   'Delivery Charge Applied',                              'paid',                  200,                    050,                                050,                      062,                250,                     NULL,       '',                 'GBP',      'ch_3TCdZxDRk9nZ67Cn2c0uUuj8',  '',             'pi_3TCdZxDRk9nZ67Cn2DmYfS9e',  '',                     '$fiveDaysAgoAt1300',        '$fiveDaysAgoAt1300')");
                $lastOrderId++;
                $this->mockPdo->exec("INSERT INTO food_order    (id,            public_order_code,  user_id,             guest_user_id,  tenant_id,  delivery_address_id,    billing_address_id,     order_status,   order_type,     product_total_original_gross,  product_total_current_gross,    order_total_current_gross,      order_total_original_gross,     order_full_refund,      order_total_current_reason,                             payment_status,         delivery_fee_gross,     customer_service_fee_gross,         platform_fee_gross,       stripe_fee_total,   small_order_fee_gross,    comment,    tenant_comment,     currency,   transaction_id,                 refunded_id,    payment_intent_id,              stripe_receipt_url,     created_at,                 updated_at) 
                                                    VALUES      ($lastOrderId,  'C02QD57Z',         $lastUserId,         NULL,           $tenantId,  2,                      NULL,                   'confirmed',    'delivery',     1540,                          1540,                           1790,                           1790,                           000,                   'Delivery Charge Applied',                              'paid',                  200,                    050,                                050,                      062,                250,                     NULL,       '',                 'GBP',      'ch_3TCdZxDRk9nZ67Cn2c0uUuj8',  '',             'pi_3TCdZxDRk9nZ67Cn2DmYfS9e',  '',                     '$fiveDaysAgoAt1300',        '$fiveDaysAgoAt1300')");
                $lastOrderId++;
                $this->mockPdo->exec("INSERT INTO food_order    (id,            public_order_code,  user_id,             guest_user_id,  tenant_id,  delivery_address_id,    billing_address_id,     order_status,   order_type,     product_total_original_gross,  product_total_current_gross,    order_total_current_gross,      order_total_original_gross,     order_full_refund,      order_total_current_reason,                             payment_status,         delivery_fee_gross,     customer_service_fee_gross,         platform_fee_gross,       stripe_fee_total,   small_order_fee_gross,    comment,    tenant_comment,     currency,   transaction_id,                 refunded_id,    payment_intent_id,              stripe_receipt_url,     created_at,                 updated_at) 
                                                    VALUES      ($lastOrderId,  'C02QD57Z',         $lastUserId,         NULL,           $tenantId,  2,                      NULL,                   'confirmed',    'delivery',     1540,                          1540,                           1790,                           1790,                           000,                   'Delivery Charge Applied',                              'paid',                  200,                    050,                                050,                      062,                250,                     NULL,       '',                 'GBP',      'ch_3TCdZxDRk9nZ67Cn2c0uUuj8',  '',             'pi_3TCdZxDRk9nZ67Cn2DmYfS9e',  '',                     '$fiveDaysAgoAt1300',        '$fiveDaysAgoAt1300')");
                $lastOrderId++;

                $this->mockPdo->exec("INSERT INTO food_order    (id,            public_order_code,  user_id,             guest_user_id,  tenant_id,  delivery_address_id,    billing_address_id,     order_status,   order_type,     product_total_original_gross,  product_total_current_gross,    order_total_current_gross,      order_total_original_gross,     order_full_refund,      order_total_current_reason,                             payment_status,         delivery_fee_gross,     customer_service_fee_gross,         platform_fee_gross,       stripe_fee_total,   small_order_fee_gross,    comment,    tenant_comment,     currency,   transaction_id,                 refunded_id,    payment_intent_id,              stripe_receipt_url,     created_at,                 updated_at) 
                                                    VALUES      ($lastOrderId,  'C02QD57Z',         $lastUserId,         NULL,           $tenantId,  2,                      NULL,                   'confirmed',    'delivery',     1540,                          1540,                           0000,                           1790,                           1790,                   'Delivery Charge Applied',                              'refunded',             200,                    050,                                050,                      062,                250,                     NULL,       '',                 'GBP',      'ch_3TCdZxDRk9nZ67Cn2c0uUuj8',  '',             'pi_3TCdZxDRk9nZ67Cn2DmYfS9e',  '',                     '$twoDaysAgoAt1300',         '$yesterdayAt1300')");
                $lastOrderId++;  

                // get the last inserted id for food_order_refund_event
                $this->mockPdo->exec("INSERT INTO food_order_refund_event (refund_group_id, order_id, tenant_id, refund_type, order_item_id, gross_pence, net_pence, vat_pence, vat_rate, note, processed_at) VALUES (1, $lastOrderId - 1, $tenantId, 'full', NULL, NULL, NULL, NULL, NULL, 'Full refund for order', '$yesterdayAt1300')");
-- reposnes

Reporting State after EOD run: Array
(
    [0] => Array
        (
            [id] => 4
            [run_id] => 1
            [run_type] => Automatic
            [tenant_id] => 8
            [window_start] => 2026-04-13 00:00:00
            [window_end] => 2026-04-14 00:00:00
            [business_date] => 2026-04-13
            [order_count] => 3
            [full_refund_count] => 0
            [partial_or_item_refund_order_count] => 0
            [full_refund_total] => 0
            [customer_paid_total] => 5370
            [item_refund_total] => 0
            [partial_refund_total] => 0
            [platform_stripe_fees_net] => 186
            [platform_fees_net] => 150
            [platform_customer_service_fee_net] => 150
            [platform_tenant_fee_gross] => 150
            [platform_customer_service_fee_gross] => 150
            [platform_gross_revenue] => 300
            [platform_refunds] => 0
            [platform_net_revenue] => 300
            [platform_refund_impact] => 0
            [platform_net_impact] => 300
            [platform_sales_vat] => 0
            [platform_refund_vat] => 0
            [platform_net_vat] => 0
            [created_at] => 2026-04-18 12:31:54
            [updated_at] => 2026-04-18 12:31:54
        )

    [1] => Array
        (
            [id] => 5
            [run_id] => 2
            [run_type] => Automatic
            [tenant_id] => 8
            [window_start] => 2026-04-14 00:00:00
            [window_end] => 2026-04-15 00:00:00
            [business_date] => 2026-04-14
            [order_count] => 0
            [full_refund_count] => 0
            [partial_or_item_refund_order_count] => 0
            [full_refund_total] => 0
            [customer_paid_total] => 0
            [item_refund_total] => 0
            [partial_refund_total] => 0
            [platform_stripe_fees_net] => 0
            [platform_fees_net] => 0
            [platform_customer_service_fee_net] => 0
            [platform_tenant_fee_gross] => 0
            [platform_customer_service_fee_gross] => 0
            [platform_gross_revenue] => 0
            [platform_refunds] => 0
            [platform_net_revenue] => 0
            [platform_refund_impact] => 0
            [platform_net_impact] => 0
            [platform_sales_vat] => 0
            [platform_refund_vat] => 0
            [platform_net_vat] => 0
            [created_at] => 2026-04-18 12:31:54
            [updated_at] => 2026-04-18 12:31:54
        )

    [2] => Array
        (
            [id] => 6
            [run_id] => 3
            [run_type] => Automatic
            [tenant_id] => 8
            [window_start] => 2026-04-15 00:00:00
            [window_end] => 2026-04-16 00:00:00
            [business_date] => 2026-04-15
            [order_count] => 0
            [full_refund_count] => 0
            [partial_or_item_refund_order_count] => 0
            [full_refund_total] => 0
            [customer_paid_total] => 0
            [item_refund_total] => 0
            [partial_refund_total] => 0
            [platform_stripe_fees_net] => 0
            [platform_fees_net] => 0
            [platform_customer_service_fee_net] => 0
            [platform_tenant_fee_gross] => 0
            [platform_customer_service_fee_gross] => 0
            [platform_gross_revenue] => 0
            [platform_refunds] => 0
            [platform_net_revenue] => 0
            [platform_refund_impact] => 0
            [platform_net_impact] => 0
            [platform_sales_vat] => 0
            [platform_refund_vat] => 0
            [platform_net_vat] => 0
            [created_at] => 2026-04-18 12:31:54
            [updated_at] => 2026-04-18 12:31:54
        )

    [3] => Array
        (
            [id] => 7
            [run_id] => 4
            [run_type] => Automatic
            [tenant_id] => 8
            [window_start] => 2026-04-16 00:00:00
            [window_end] => 2026-04-17 00:00:00
            [business_date] => 2026-04-16
            [order_count] => 1
            [full_refund_count] => 0
            [partial_or_item_refund_order_count] => 0
            [full_refund_total] => 0
            [customer_paid_total] => 1790
            [item_refund_total] => 0
            [partial_refund_total] => 0
            [platform_stripe_fees_net] => 62
            [platform_fees_net] => 50
            [platform_customer_service_fee_net] => 50
            [platform_tenant_fee_gross] => 50
            [platform_customer_service_fee_gross] => 50
            [platform_gross_revenue] => 100
            [platform_refunds] => 0
            [platform_net_revenue] => 100
            [platform_refund_impact] => 0
            [platform_net_impact] => 100
            [platform_sales_vat] => 0
            [platform_refund_vat] => 0
            [platform_net_vat] => 0
            [created_at] => 2026-04-18 12:31:54
            [updated_at] => 2026-04-18 12:31:54
        )

    [4] => Array
        (
            [id] => 8
            [run_id] => 5
            [run_type] => Automatic
            [tenant_id] => 8
            [window_start] => 2026-04-17 00:00:00
            [window_end] => 2026-04-18 00:00:00
            [business_date] => 2026-04-17
            [order_count] => 0
            [full_refund_count] => 1
            [partial_or_item_refund_order_count] => 0
            [full_refund_total] => 1790
            [customer_paid_total] => 0
            [item_refund_total] => 0
            [partial_refund_total] => 0
            [platform_stripe_fees_net] => 0
            [platform_fees_net] => 0
            [platform_customer_service_fee_net] => 0
            [platform_tenant_fee_gross] => 0
            [platform_customer_service_fee_gross] => 0
            [platform_gross_revenue] => 0
            [platform_refunds] => 100
            [platform_net_revenue] => 0
            [platform_refund_impact] => -100
            [platform_net_impact] => -100
            [platform_sales_vat] => 0
            [platform_refund_vat] => 0
            [platform_net_vat] => 0
            [created_at] => 2026-04-18 12:31:54
            [updated_at] => 2026-04-18 12:31:54
        )

)

Reporting State Tenant after EOD run: Array
(
    [0] => Array
        (
            [id] => 4
            [run_id] => 1
            [run_type] => Automatic
            [tenant_id] => 8
            [window_start] => 2026-04-13 00:00:00
            [window_end] => 2026-04-14 00:00:00
            [business_date] => 2026-04-13
            [order_count] => 3
            [full_refund_count] => 0
            [partial_or_item_refund_order_count] => 0
            [customer_paid_total] => 5370
            [item_refund_total] => 0
            [partial_refund_total] => 0
            [tenant_gross_sales] => 5220
            [tenant_full_refund_total] => 0
            [tenant_total_refunds] => 0
            [tenant_refund_total] => 0
            [tenant_delivery_fees_net] => 600
            [tenant_small_order_fees_net] => 750
            [tenant_platform_fees_net] => 150
            [tenant_stripe_fees_net] => 186
            [tenant_net_pre_fee] => 5220
            [tenant_net_post_platform_fee] => 5070
            [tenant_net] => 4884
            [tenant_refund_impact] => 0
            [tenant_stripe_fee_impact] => -186
            [tenant_net_impact_pre_fee] => 5220
            [tenant_net_impact_post_platform_fee] => 5070
            [tenant_net_impact] => 4884
            [tenant_sales_vat_gross] => 0
            [tenant_sales_vat_net] => 0
            [tenant_sales_vat] => 0
            [tenant_refund_vat_gross] => 0
            [tenant_refund_vat_net] => 0
            [tenant_refund_vat] => 0
            [tenant_net_vat_gross] => 0
            [tenant_net_vat_net] => 0
            [tenant_net_vat] => 0
            [created_at] => 2026-04-18 12:31:54
            [updated_at] => 2026-04-18 12:31:54
        )

    [1] => Array
        (
            [id] => 5
            [run_id] => 2
            [run_type] => Automatic
            [tenant_id] => 8
            [window_start] => 2026-04-14 00:00:00
            [window_end] => 2026-04-15 00:00:00
            [business_date] => 2026-04-14
            [order_count] => 0
            [full_refund_count] => 0
            [partial_or_item_refund_order_count] => 0
            [customer_paid_total] => 0
            [item_refund_total] => 0
            [partial_refund_total] => 0
            [tenant_gross_sales] => 0
            [tenant_full_refund_total] => 0
            [tenant_total_refunds] => 0
            [tenant_refund_total] => 0
            [tenant_delivery_fees_net] => 0
            [tenant_small_order_fees_net] => 0
            [tenant_platform_fees_net] => 0
            [tenant_stripe_fees_net] => 0
            [tenant_net_pre_fee] => 0
            [tenant_net_post_platform_fee] => 0
            [tenant_net] => 0
            [tenant_refund_impact] => 0
            [tenant_stripe_fee_impact] => 0
            [tenant_net_impact_pre_fee] => 0
            [tenant_net_impact_post_platform_fee] => 0
            [tenant_net_impact] => 0
            [tenant_sales_vat_gross] => 0
            [tenant_sales_vat_net] => 0
            [tenant_sales_vat] => 0
            [tenant_refund_vat_gross] => 0
            [tenant_refund_vat_net] => 0
            [tenant_refund_vat] => 0
            [tenant_net_vat_gross] => 0
            [tenant_net_vat_net] => 0
            [tenant_net_vat] => 0
            [created_at] => 2026-04-18 12:31:54
            [updated_at] => 2026-04-18 12:31:54
        )

    [2] => Array
        (
            [id] => 6
            [run_id] => 3
            [run_type] => Automatic
            [tenant_id] => 8
            [window_start] => 2026-04-15 00:00:00
            [window_end] => 2026-04-16 00:00:00
            [business_date] => 2026-04-15
            [order_count] => 0
            [full_refund_count] => 0
            [partial_or_item_refund_order_count] => 0
            [customer_paid_total] => 0
            [item_refund_total] => 0
            [partial_refund_total] => 0
            [tenant_gross_sales] => 0
            [tenant_full_refund_total] => 0
            [tenant_total_refunds] => 0
            [tenant_refund_total] => 0
            [tenant_delivery_fees_net] => 0
            [tenant_small_order_fees_net] => 0
            [tenant_platform_fees_net] => 0
            [tenant_stripe_fees_net] => 0
            [tenant_net_pre_fee] => 0
            [tenant_net_post_platform_fee] => 0
            [tenant_net] => 0
            [tenant_refund_impact] => 0
            [tenant_stripe_fee_impact] => 0
            [tenant_net_impact_pre_fee] => 0
            [tenant_net_impact_post_platform_fee] => 0
            [tenant_net_impact] => 0
            [tenant_sales_vat_gross] => 0
            [tenant_sales_vat_net] => 0
            [tenant_sales_vat] => 0
            [tenant_refund_vat_gross] => 0
            [tenant_refund_vat_net] => 0
            [tenant_refund_vat] => 0
            [tenant_net_vat_gross] => 0
            [tenant_net_vat_net] => 0
            [tenant_net_vat] => 0
            [created_at] => 2026-04-18 12:31:54
            [updated_at] => 2026-04-18 12:31:54
        )

    [3] => Array
        (
            [id] => 7
            [run_id] => 4
            [run_type] => Automatic
            [tenant_id] => 8
            [window_start] => 2026-04-16 00:00:00
            [window_end] => 2026-04-17 00:00:00
            [business_date] => 2026-04-16
            [order_count] => 1
            [full_refund_count] => 0
            [partial_or_item_refund_order_count] => 0
            [customer_paid_total] => 1790
            [item_refund_total] => 0
            [partial_refund_total] => 0
            [tenant_gross_sales] => 1740
            [tenant_full_refund_total] => 0
            [tenant_total_refunds] => 0
            [tenant_refund_total] => 0
            [tenant_delivery_fees_net] => 200
            [tenant_small_order_fees_net] => 250
            [tenant_platform_fees_net] => 50
            [tenant_stripe_fees_net] => 62
            [tenant_net_pre_fee] => 1740
            [tenant_net_post_platform_fee] => 1690
            [tenant_net] => 1628
            [tenant_refund_impact] => 0
            [tenant_stripe_fee_impact] => -62
            [tenant_net_impact_pre_fee] => 1740
            [tenant_net_impact_post_platform_fee] => 1690
            [tenant_net_impact] => 1628
            [tenant_sales_vat_gross] => 0
            [tenant_sales_vat_net] => 0
            [tenant_sales_vat] => 0
            [tenant_refund_vat_gross] => 0
            [tenant_refund_vat_net] => 0
            [tenant_refund_vat] => 0
            [tenant_net_vat_gross] => 0
            [tenant_net_vat_net] => 0
            [tenant_net_vat] => 0
            [created_at] => 2026-04-18 12:31:54
            [updated_at] => 2026-04-18 12:31:54
        )

    [4] => Array
        (
            [id] => 8
            [run_id] => 5
            [run_type] => Automatic
            [tenant_id] => 8
            [window_start] => 2026-04-17 00:00:00
            [window_end] => 2026-04-18 00:00:00
            [business_date] => 2026-04-17
            [order_count] => 0
            [full_refund_count] => 1
            [partial_or_item_refund_order_count] => 0
            [customer_paid_total] => 0
            [item_refund_total] => 0
            [partial_refund_total] => 0
            [tenant_gross_sales] => 0
            [tenant_full_refund_total] => 1790
            [tenant_total_refunds] => 1790
            [tenant_refund_total] => 1740
            [tenant_delivery_fees_net] => 0
            [tenant_small_order_fees_net] => 0
            [tenant_platform_fees_net] => 0
            [tenant_stripe_fees_net] => 0
            [tenant_net_pre_fee] => 0
            [tenant_net_post_platform_fee] => 0
            [tenant_net] => 0
            [tenant_refund_impact] => -1740
            [tenant_stripe_fee_impact] => 0
            [tenant_net_impact_pre_fee] => -1740
            [tenant_net_impact_post_platform_fee] => -1740
            [tenant_net_impact] => -1740
            [tenant_sales_vat_gross] => 0
            [tenant_sales_vat_net] => 0
            [tenant_sales_vat] => 0
            [tenant_refund_vat_gross] => 0
            [tenant_refund_vat_net] => 0
            [tenant_refund_vat] => 0
            [tenant_net_vat_gross] => 0
            [tenant_net_vat_net] => 0
            [tenant_net_vat] => 0
            [created_at] => 2026-04-18 12:31:54
            [updated_at] => 2026-04-18 12:31:54
        )

)


