← Code-Übersicht

run-rechnung.php

Pfad: run-rechnung.php

Ext: php

Größe: 1426 Bytes

Geändert: 2026-07-16 18:00:15+02

#!/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);
    $payload = $result->toArray();
    echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . PHP_EOL;
    if ($payload['errors'] > 0) { exit(2); }
} catch (Throwable $error) {
    fwrite(STDERR, json_encode(['ok' => false, 'error' => $error->getMessage()], JSON_THROW_ON_ERROR) . PHP_EOL);
    exit(1);
}

Frühere Versionen

Version Zeitpunkt Operation
49 2026-07-16 20:03:52.978188+02 UPDATE
32 2026-07-16 19:55:01.884862+02 UPDATE