generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/invoice' into main
- Loading branch information
Showing
20 changed files
with
457 additions
and
68 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
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,11 @@ | ||
<?php | ||
|
||
namespace MorningTrain\Economic\DTOs; | ||
|
||
class Attention | ||
{ | ||
public function __construct( | ||
public ?int $customerContactNumber = null, | ||
) { | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace MorningTrain\Economic\DTOs; | ||
|
||
use MorningTrain\Economic\Resources\VatZone; | ||
|
||
class Recipient | ||
{ | ||
public function __construct( | ||
public readonly string $name, | ||
public readonly VatZone $vatZone, | ||
public ?string $address = null, | ||
public ?string $zip = null, | ||
public ?string $city = null, | ||
public ?string $country = null, | ||
public ?string $ean = null, | ||
public ?string $publicEntryNumber = null, | ||
//public ?Attention $attention = null, | ||
) { | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,22 @@ | ||
<?php | ||
|
||
namespace MorningTrain\Economic\Resources\Invoice; | ||
|
||
use MorningTrain\Economic\Attributes\Resources\Create; | ||
use MorningTrain\Economic\Attributes\Resources\GetCollection; | ||
use MorningTrain\Economic\Attributes\Resources\GetSingle; | ||
|
||
#[GetCollection('invoices/booked')] | ||
#[GetSingle('invoices/booked/:bookedInvoiceNumber', ':bookedInvoiceNumber')] | ||
#[Create('invoices/booked')] | ||
class BookedInvoice extends DraftInvoice | ||
{ | ||
public static function createFromDraft(int|DraftInvoice $draft) | ||
{ | ||
return static::createRequest([ | ||
'draftInvoice' => [ | ||
'draftInvoiceNumber' => is_int($draft) ? $draft : $draft->draftInvoiceNumber, | ||
], | ||
]); | ||
} | ||
} |
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,77 @@ | ||
<?php | ||
|
||
namespace MorningTrain\Economic\Resources\Invoice; | ||
|
||
use DateTime; | ||
use MorningTrain\Economic\Abstracts\Resource; | ||
use MorningTrain\Economic\Attributes\Resources\Create; | ||
use MorningTrain\Economic\Attributes\Resources\GetCollection; | ||
use MorningTrain\Economic\Attributes\Resources\GetSingle; | ||
use MorningTrain\Economic\DTOs\Recipient; | ||
use MorningTrain\Economic\Resources\Currency; | ||
use MorningTrain\Economic\Resources\Customer; | ||
use MorningTrain\Economic\Resources\Layout; | ||
use MorningTrain\Economic\Resources\PaymentTerm; | ||
use MorningTrain\Economic\Traits\Resources\Creatable; | ||
use MorningTrain\Economic\Traits\Resources\GetCollectionable; | ||
use MorningTrain\Economic\Traits\Resources\GetSingleable; | ||
use MorningTrain\Economic\Traits\Resources\HasLines; | ||
|
||
#[GetCollection('invoices/drafts')] | ||
#[GetSingle('invoices/drafts/:draftInvoiceNumber', ':draftInvoiceNumber')] | ||
#[Create('invoices/drafts')] | ||
class DraftInvoice extends Resource | ||
{ | ||
use Creatable, GetCollectionable, GetSingleable; | ||
use HasLines; | ||
|
||
public Customer $customer; | ||
|
||
public Layout $layout; | ||
|
||
public Currency $currency; | ||
|
||
public PaymentTerm $paymentTerms; | ||
|
||
public DateTime $date; | ||
|
||
public Recipient $recipient; | ||
|
||
public ?int $draftInvoiceNumber = null; | ||
|
||
public static function new( | ||
Customer|int $customer, | ||
Layout|int $layout, | ||
Currency|string $currency, | ||
PaymentTerm|int $paymentTerms, | ||
DateTime $date, | ||
Recipient $recipient, | ||
): static { | ||
return new static([ | ||
'customer' => $customer, | ||
'layout' => $layout, | ||
'currency' => $currency, | ||
'paymentTerms' => $paymentTerms, | ||
'date' => $date, | ||
'recipient' => $recipient, | ||
]); | ||
} | ||
|
||
public function create() | ||
{ | ||
return static::createRequest([ | ||
'customer' => $this->customer, | ||
'layout' => $this->layout, | ||
'currency' => $this->currency, | ||
'paymentTerms' => $this->paymentTerms, | ||
'date' => $this->date->format('Y-m-d'), | ||
'recipient' => $this->recipient, | ||
'lines' => $this->lines ?? null, | ||
]); | ||
} | ||
|
||
public function book(): ?BookedInvoice | ||
{ | ||
return BookedInvoice::createFromDraft($this); | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
|
||
namespace MorningTrain\Economic\Resources\Invoice; | ||
|
||
use MorningTrain\Economic\Abstracts\Resource; | ||
use MorningTrain\Economic\Attributes\Resources\Create; | ||
use MorningTrain\Economic\Attributes\Resources\GetCollection; | ||
use MorningTrain\Economic\Attributes\Resources\GetSingle; | ||
use MorningTrain\Economic\Resources\Currency; | ||
use MorningTrain\Economic\Resources\Customer; | ||
use MorningTrain\Economic\Resources\Layout; | ||
use MorningTrain\Economic\Resources\PaymentTerm; | ||
use MorningTrain\Economic\Traits\Resources\Creatable; | ||
use MorningTrain\Economic\Traits\Resources\GetCollectionable; | ||
use MorningTrain\Economic\Traits\Resources\GetSingleable; | ||
|
||
#[GetCollection('products')] | ||
#[GetSingle('invoices/:product', ':product')] | ||
#[Create('invoices/drafts')] | ||
class Invoice extends Resource | ||
{ | ||
use Creatable, GetCollectionable, GetSingleable; | ||
|
||
public static function new( | ||
Customer|int $customer, | ||
Layout|int $layout, | ||
Currency|string $currency, | ||
PaymentTerm|int $paymentTerms, | ||
) { | ||
return new static([ | ||
'customer' => $customer, | ||
'layout' => $layout, | ||
'currency' => $currency, | ||
'paymentTerms' => $paymentTerms, | ||
]); | ||
} | ||
|
||
public function addLine(ProductLine $line): static | ||
{ | ||
$this->lines[] = $line; | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.