-
Notifications
You must be signed in to change notification settings - Fork 30
/
Peppol.php
62 lines (53 loc) · 1.92 KB
/
Peppol.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace Einvoicing\Presets;
use Einvoicing\Invoice;
// @phan-file-suppress PhanPluginInconsistentReturnFunction, PhanPossiblyNonClassMethodCall
/**
* PEPPOL BIS Billing 3.0
* @author OpenPEPPOL
* @link https://docs.peppol.eu/poacc/billing/3.0/
*/
class Peppol extends AbstractPreset {
/**
* @inheritdoc
*/
public function getSpecification(): string {
return "urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0";
}
/**
* @inheritdoc
*/
public function getRules(): array {
$res = [];
$res['PEPPOL-EN16931-R002'] = static function(Invoice $inv) {
if (count($inv->getNotes()) > 1) {
return "No more than one note is allowed on document level.";
}
};
$res['PEPPOL-EN16931-R003'] = static function(Invoice $inv) {
if ($inv->getBuyerReference() !== null) return;
if ($inv->getPurchaseOrderReference() !== null) return;
return "A buyer reference or purchase order reference MUST be provided.";
};
$res['PEPPOL-EN16931-R061'] = static function(Invoice $inv) {
if ($inv->getPayment() === null) return;
if ($inv->getPayment()->getMandate() === null) return;
if ($inv->getPayment()->getMandate()->getReference() === null) {
return "Mandate reference MUST be provided for direct debit";
}
};
$res['BG-17'] = static function(Invoice $inv) {
if ($inv->getPayment() !== null && count($inv->getPayment()->getTransfers()) > 1) {
return "An Invoice shall not have multiple credit transfers";
}
};
return $res;
}
/**
* @inheritdoc
*/
public function setupInvoice(Invoice $invoice) {
parent::setupInvoice($invoice);
$invoice->setBusinessProcess('urn:fdc:peppol.eu:2017:poacc:billing:01:1.0');
}
}