Skip to content

Commit

Permalink
Merge pull request #1 from davidoskay/main
Browse files Browse the repository at this point in the history
ADD support for person in invoice creating, FIX error when code in po…
  • Loading branch information
MattMoszczynski authored Mar 17, 2022
2 parents cf4d57e + b606067 commit e6e7a02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/FakturowniaInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function __construct($kind = FakturowniaInvoiceKind::INVOICE_VAT, $number
'phone' => ""
);
$this->buyer = array(
'first_name' => "",
'last_name' => "",
'name' => "",
'tax_number' => null,
'street' => "",
Expand Down Expand Up @@ -150,6 +152,10 @@ public static function createFromJson($json)
);

$invoice->isBuyerCompany = ($json['buyer_company'] > 0 ? true : false);
if(!$invoice->isBuyerCompany) {
$invoice->buyer['first_name'] = $json['buyer_first_name'];
$invoice->buyer['last_name'] = $json['buyer_last_name'];
}

if (isset($json['recipient_name']) && !empty($json['recipient_name'])) {
$invoice->recipient = array(
Expand Down Expand Up @@ -202,6 +208,8 @@ public function toArray($includeEmptyFields = true)
'seller_country' => $this->seller['country'],
'seller_phone' => $this->seller['phone'],
'buyer_name' => $this->buyer['name'],
'buyer_first_name' => $this->buyer['first_name'],
'buyer_last_name' => $this->buyer['last_name'],
'buyer_tax_no' => $this->buyer['tax_number'],
'buyer_street' => $this->buyer['street'],
'buyer_post_code' => $this->buyer['post_code'],
Expand Down
7 changes: 5 additions & 2 deletions src/FakturowniaPosition.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ public static function createFromJson($json)
{
$position = new FakturowniaPosition($json['name'], $json['quantity'], $json['total_price_gross'], false, $json['tax']);
$position->id = $json['id'];
$position->code = $json['code'];
$position->description = $json['description'];

if (isset($json['code']) && !empty($json['code'])) {
$position->code = $json['code'];
}

$position->description = $json['description'];
$position->quantityUnit = $json['quantity_unit'];

// ----------[ DATA PROCESSING END ]----------
Expand Down

0 comments on commit e6e7a02

Please sign in to comment.