<?php

declare(strict_types=1);

require __DIR__ . '/../includes/bootstrap.php';
require __DIR__ . '/../includes/helpers.php';
require __DIR__ . '/../includes/invoice_contract.php';
require __DIR__ . '/../includes/invoice_pdf_generator.php';

$contract = [
    'token' => 'testpdf123',
    'id' => 99,
    'invoice_mode' => 'pos',
    'contract_line' => 'Karvi POS',
    'contract_date' => '2026-06-18',
    'delivery_date' => '2026-07-18',
    'customer_details' => "Test GmbH\nMusterstr. 1\n60311 Frankfurt",
    'installment_months' => 12,
    'line_items' => [[
        'description' => 'Karvi POS System inkl. iPad',
        'quantity' => 1,
        'unit_price_net' => 1950,
        'total_net' => 1950,
    ]],
    'optional_printer' => 0,
    'discount' => 0,
    'totals' => invoice_calculate_totals(
        [['total_net' => 1950]],
        0,
        false,
        ['unit_price_net' => 0]
    ),
];

$path = __DIR__ . '/../uploads/contracts/test_invoice_layout.pdf';
$file = generate_invoice_contract_pdf($contract, $path);
echo $file . ' OK size=' . filesize($path) . PHP_EOL;
