Changeset View
Changeset View
Standalone View
Standalone View
src/app/Documents/Receipt.php
Show All 36 Lines | public function __construct(Wallet $wallet, int $year, int $month) | ||||
$this->wallet = $wallet; | $this->wallet = $wallet; | ||||
$this->year = $year; | $this->year = $year; | ||||
$this->month = $month; | $this->month = $month; | ||||
} | } | ||||
/** | /** | ||||
* Render the mail template with fake data | * Render the mail template with fake data | ||||
* | * | ||||
* @param string $type Output format ('html' or 'pdf') | |||||
* | |||||
* @return string HTML or PDF output | * @return string HTML or PDF output | ||||
*/ | */ | ||||
public static function fakeRender(string $type = 'html'): string | public static function fakeRender(string $type = 'html'): string | ||||
{ | { | ||||
$wallet = new Wallet(); | $wallet = new Wallet(); | ||||
$wallet->id = \App\Utils::uuidStr(); | $wallet->id = \App\Utils::uuidStr(); | ||||
$wallet->owner = new User(['id' => 123456789]); // @phpstan-ignore-line | $wallet->owner = new User(['id' => 123456789]); // @phpstan-ignore-line | ||||
$receipt = new self($wallet, date('Y'), date('n')); | $receipt = new self($wallet, date('Y'), date('n')); | ||||
self::$fakeMode = true; | self::$fakeMode = true; | ||||
if ($type == 'pdf') { | if ($type == 'pdf') { | ||||
return $receipt->pdfOutput(); | return $receipt->pdfOutput(); | ||||
} elseif ($type !== 'html') { | |||||
throw new \Exception("Unsupported output format"); | |||||
} | } | ||||
return $receipt->htmlOutput(); | return $receipt->htmlOutput(); | ||||
} | } | ||||
/** | /** | ||||
* Render the receipt in HTML format. | * Render the receipt in HTML format. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |