← Code-Übersicht

run-rechnung.php

Pfad: run-rechnung.php

Ext: php

Größe: 1356 Bytes

Geändert: 2026-07-16T17:37:59+02:00

Frühere Version vom 2026-07-16T17:37:59+02:00 · zur aktuellen Fassung

#!/usr/bin/env php
<?php
declare(strict_types=1);

use Demo\Infrastructure\Rechnung\InvoiceApplicationFactory;
use Demo\Infrastructure\Rechnung\InvoiceRuntimeConfig;
use Demo\Infrastructure\Rechnung\JsonRuntimeConfig;
use Demo\Infrastructure\Rechnung\LexwareRuntimeConfig;
use Demo\Infrastructure\Rechnung\WetellRuntimeConfig;

require __DIR__ . '/vendor/autoload.php';

try {
    $credentialsDir = JsonRuntimeConfig::environment('APP_CREDENTIALS_DIR') ?? __DIR__ . '/credentials';
    $wetellFile = JsonRuntimeConfig::environment('WETELL_CREDENTIALS_FILE') ?? $credentialsDir . '/wetell.json';
    $lexwareFile = JsonRuntimeConfig::environment('LEXOFFICE_CREDENTIALS_FILE') ?? $credentialsDir . '/lexoffice.json';
    $wetell = WetellRuntimeConfig::fromFile($wetellFile);
    $lexware = LexwareRuntimeConfig::fromFile($lexwareFile);
    $runtime = InvoiceRuntimeConfig::fromEnvironment(__DIR__);
    $application = (new InvoiceApplicationFactory())->create($runtime, $wetell, $lexware);
    $result = $application->execute($runtime->runId, $wetell->username, $wetell->password);
    echo json_encode($result->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . PHP_EOL;
} catch (Throwable $error) {
    fwrite(STDERR, json_encode(['ok' => false, 'error' => $error->getMessage()], JSON_THROW_ON_ERROR) . PHP_EOL);
    exit(1);
}