<?php

it('supports barred filtering when listing e-conomic customers', function (): void {
    $routeFile = app_path('routes/customerSearchRoute.php');
    $routeContent = file_get_contents($routeFile);

    expect($routeContent)->not->toBeFalse();
    expect($routeContent)->toContain("fromRequest('barred')");
    expect($routeContent)->toContain('listCustomers(');

    $customersFile = app_path('modules/economic/customers/economicCustomers.php');
    $customersContent = file_get_contents($customersFile);

    expect($customersContent)->not->toBeFalse();
    expect($customersContent)->toContain('normalizeBarredFilter(');
    expect($customersContent)->toContain('barred$eq:');
});

it('implements a dedicated v2 e-conomic revenue statistics service and route', function (): void {
    $routeFile = app_path('routes/orderInvoicesRoute.php');
    $routeContent = file_get_contents($routeFile);

    expect($routeContent)->not->toBeFalse();
    expect($routeContent)->toContain('/collected-invoices/economic/v2/revenue-statistics');
    expect($routeContent)->toContain("requirePermission('view_collected_invoice_economic_v2_revenue_statistics')");
    expect($routeContent)->toContain('getBookedRevenueStatistics(');

    $serviceFile = app_path('classes/economic_v2_revenue_statistics_service.php');
    $serviceContent = file_get_contents($serviceFile);

    expect($serviceContent)->not->toBeFalse();
    expect($serviceContent)->toContain('class economic_v2_revenue_statistics_service');
    expect($serviceContent)->toContain('passesBarredFilter(');
    expect($serviceContent)->toContain('reduceInvoiceLines(');
});

