From 20e35cfb724346f641d554f6c09fd0499a7bcd8b Mon Sep 17 00:00:00 2001 From: Roj Vroemen Date: Tue, 26 Apr 2022 14:09:43 +0200 Subject: [PATCH] Allow meansofpayment to be set --- src/Customer.php | 13 +++++++++++++ src/DomDocuments/CustomersDocument.php | 7 +++++++ src/Enums/MeansOfPayment.php | 15 +++++++++++++++ .../IntegrationTests/CustomerIntegrationTest.php | 2 ++ .../resources/customerSendRequest.xml | 1 + 5 files changed, 38 insertions(+) create mode 100644 src/Enums/MeansOfPayment.php diff --git a/src/Customer.php b/src/Customer.php index 7f599f9a..c5bb39c7 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -3,6 +3,7 @@ namespace PhpTwinfield; use PhpTwinfield\Enums\CollectionSchema; +use PhpTwinfield\Enums\MeansOfPayment; use PhpTwinfield\Transactions\TransactionFields\OfficeField; use PhpTwinfield\Transactions\TransactionLineFields\VatCodeField; @@ -47,6 +48,7 @@ class Customer private $editDimensionName; private $dueDays = 0; private $payAvailable = false; + private $meansOfPayment; private $payCode; private $vatCode; private $eBilling = false; @@ -266,6 +268,17 @@ public function setPayAvailable(bool $payAvailable): self return $this; } + public function getMeansOfPayment(): ?MeansOfPayment + { + return $this->meansOfPayment; + } + + public function setMeansOfPayment(?MeansOfPayment $meansOfPayment): self + { + $this->meansOfPayment = $meansOfPayment; + return $this; + } + public function getPayCode() { return $this->payCode; diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index 2ae3503b..84aa4c8e 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -143,6 +143,13 @@ public function addCustomer(Customer $customer): void $collectionSchemaElement = $this->createElement('collectionschema', $collectionSchema->getValue()); $financialElement->appendChild($collectionSchemaElement); } + + $meansOfPayment = $customer->getMeansOfPayment(); + + if ($meansOfPayment !== null) { + $meansOfPaymentElement = $this->createElement('meansofpayment', $meansOfPayment->getValue()); + $financialElement->appendChild($meansOfPaymentElement); + } } //check if creditmanagement should be set diff --git a/src/Enums/MeansOfPayment.php b/src/Enums/MeansOfPayment.php new file mode 100644 index 00000000..01b07fb3 --- /dev/null +++ b/src/Enums/MeansOfPayment.php @@ -0,0 +1,15 @@ +setName('Customer 0'); $customer->setDueDays('30'); $customer->setPayAvailable(true); + $customer->setMeansOfPayment(MeansOfPayment::PAYMENTFILE()); $customer->setPayCode('SEPANLDD'); $address = new CustomerAddress(); diff --git a/tests/IntegrationTests/resources/customerSendRequest.xml b/tests/IntegrationTests/resources/customerSendRequest.xml index dafe323c..7c56101a 100644 --- a/tests/IntegrationTests/resources/customerSendRequest.xml +++ b/tests/IntegrationTests/resources/customerSendRequest.xml @@ -16,6 +16,7 @@ 20180608 core + paymentfile