-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Invoice: add methods send, createResponse. generatePreview moved to P…
…reviewFactory
- Loading branch information
MartkCz
committed
Feb 27, 2019
1 parent
0cd19ab
commit 6670823
Showing
5 changed files
with
85 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace WebChemistry\Invoice\Preview; | ||
|
||
use DateTime; | ||
use WebChemistry\Invoice\Data\Account; | ||
use WebChemistry\Invoice\Data\Customer; | ||
use WebChemistry\Invoice\Data\Order; | ||
use WebChemistry\Invoice\Data\PaymentInformation; | ||
|
||
final class PreviewFactory { | ||
|
||
public static function createCustomer(): Customer { | ||
return new Customer('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA', '08304431', 'CZ08304431'); | ||
} | ||
|
||
public static function createOrder(): Order { | ||
$account = new Account('2353462013/0800', 'CZ4808000000002353462013', 'GIGACZPX'); | ||
$paymentInfo = new PaymentInformation('$', '0123456789', '1234', 0.21); | ||
|
||
$order = new Order(date('Y') . '0001', new DateTime('+ 7 days'), $account, $paymentInfo); | ||
$order->addItem('Logitech G700s Rechargeable Gaming Mouse', 1790, 4); | ||
$order->addItem('ASUS Z380KL 8" - 16GB, LTE, bílá', 6490, 1); | ||
$order->addItem('Philips 48PFS6909 - 121cm', 13990, 1); | ||
$order->addItem('HP Deskjet 3545 Advantage', 1799, 1); | ||
$order->addItem('LG 105UC9V - 266cm', 11599, 2); | ||
|
||
return $order; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace WebChemistry\Invoice\Responses; | ||
|
||
use Nette\Application\IResponse; | ||
use Nette\Http\IRequest; | ||
use Nette\Http\IResponse as NetteIResponse; | ||
|
||
final class PdfResponse implements IResponse { | ||
|
||
/** @var string */ | ||
private $content; | ||
|
||
public function __construct(string $content) { | ||
$this->content = $content; | ||
} | ||
|
||
public function send(IRequest $httpRequest, NetteIResponse $httpResponse): void { | ||
$httpResponse->setContentType('application/pdf', 'utf-8'); | ||
echo $this->content; | ||
} | ||
|
||
} |