-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from josemmo/develop
v0.1.4
- Loading branch information
Showing
10 changed files
with
233 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Contributing | ||
Thanks for taking your time to contribute to this project! | ||
This document will get you on the right track to help improve eInvoicing. | ||
|
||
## How to Get Started | ||
Use the following sites to get more information about the European electronic invocing specification: | ||
|
||
- [EU e-Invoicing core concepts](https://josemmo.github.io/einvoicing/getting-started/eu-einvoicing-concepts/) | ||
- [Compliance with the European standard on eInvoicing](https://ec.europa.eu/cefdigital/wiki/x/ggTvB) | ||
- [Obtaining a copy of the European standard on eInvoicing](https://ec.europa.eu/cefdigital/wiki/x/kgLvB) | ||
- [UBL Invoice fields](https://docs.peppol.eu/poacc/billing/3.0/syntax/ubl-invoice/tree/) | ||
- [CEF eInvoicing Validator](https://www.itb.ec.europa.eu/invoice/upload) | ||
|
||
## PR Requirements | ||
Before opening a Pull Request, please make sure your code meets the following requirements: | ||
|
||
### 1. Uses `develop` as the base branch | ||
The main repository branch is only for stable releases. | ||
|
||
### 2. Passes static analysis inspection | ||
``` | ||
vendor/bin/phan --testdox | ||
``` | ||
|
||
### 3. Passes all tests | ||
``` | ||
vendor/bin/simple-phpunit | ||
``` | ||
|
||
### 4. Complies with EN 16931 | ||
Although the most popular European Invoicing CIUS is [PEPPOL BIS Billing 3.0](https://docs.peppol.eu/poacc/billing/3.0/), | ||
the real deal is the "European Standard for Electronic invocing" or EN 16931. | ||
|
||
This means that, while most users will use the [Peppol](src/Presets/Peppol.php) preset for reading and writing invoices, | ||
there are other CIUS/extensions from various member states and business sectors which might not be an exact match to PEPPOL. | ||
|
||
Because the one thing all these specifications have in common is EN 16931, fields and methods you add to the library | ||
must have the same names as they do in the European Standard. |
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,59 @@ | ||
<?php | ||
namespace Einvoicing; | ||
|
||
use DateTime; | ||
|
||
class InvoiceReference { | ||
protected $value; | ||
protected $issueDate; | ||
|
||
/** | ||
* Class constructor | ||
* @param string $value Value | ||
* @param DateTime|null $issueDate Issue date | ||
*/ | ||
public function __construct(string $value, ?DateTime $issueDate=null) { | ||
$this->setValue($value); | ||
$this->setIssueDate($issueDate); | ||
} | ||
|
||
|
||
/** | ||
* Get value | ||
* @return string Value | ||
*/ | ||
public function getValue(): string { | ||
return $this->value; | ||
} | ||
|
||
|
||
/** | ||
* Set value | ||
* @param string $value Value | ||
* @return self Invoice reference instance | ||
*/ | ||
public function setValue(string $value): self { | ||
$this->value = $value; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Get issue date | ||
* @return DateTime|null Issue date | ||
*/ | ||
public function getIssueDate(): ?DateTime { | ||
return $this->issueDate; | ||
} | ||
|
||
|
||
/** | ||
* Set issue date | ||
* @param DateTime|null $issueDate Issue date | ||
* @return self Invoice reference instance | ||
*/ | ||
public function setIssueDate(?DateTime $issueDate): self { | ||
$this->issueDate = $issueDate; | ||
return $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
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,53 @@ | ||
<?php | ||
namespace Einvoicing\Traits; | ||
|
||
use Einvoicing\InvoiceReference; | ||
use OutOfBoundsException; | ||
|
||
trait PrecedingInvoiceReferencesTrait { | ||
protected $precedingInvoiceReferences = []; | ||
|
||
/** | ||
* Get preceding invoice references | ||
* @return InvoiceReference[] Array of preceding invoice references | ||
*/ | ||
public function getPrecedingInvoiceReferences(): array { | ||
return $this->precedingInvoiceReferences; | ||
} | ||
|
||
|
||
/** | ||
* Add preceding invoice reference | ||
* @param InvoiceReference $reference Preceding invoice reference | ||
* @return self This instance | ||
*/ | ||
public function addPrecedingInvoiceReference(InvoiceReference $reference): self { | ||
$this->precedingInvoiceReferences[] = $reference; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Remove preceding invoice reference | ||
* @param int $index Preceding invoice reference index | ||
* @return self This instance | ||
* @throws OutOfBoundsException if preceding invoice reference index is out of bounds | ||
*/ | ||
public function removePrecedingInvoiceReference(int $index): self { | ||
if ($index < 0 || $index >= count($this->precedingInvoiceReferences)) { | ||
throw new OutOfBoundsException('Could not find preceding invoice reference by index'); | ||
} | ||
array_splice($this->precedingInvoiceReferences, $index, 1); | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Clear all preceding invoice references | ||
* @return self This instance | ||
*/ | ||
public function clearPrecedingInvoiceReferences(): self { | ||
$this->precedingInvoiceReferences = []; | ||
return $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
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