Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow meansofpayment to be set customers #212

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PhpTwinfield;

use PhpTwinfield\Enums\CollectionSchema;
use PhpTwinfield\Enums\MeansOfPayment;
use PhpTwinfield\Transactions\TransactionFields\OfficeField;
use PhpTwinfield\Transactions\TransactionLineFields\VatCodeField;

Expand Down Expand Up @@ -47,6 +48,7 @@ class Customer
private $editDimensionName;
private $dueDays = 0;
private $payAvailable = false;
private $meansOfPayment;
private $payCode;
private $vatCode;
private $eBilling = false;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/DomDocuments/CustomersDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions src/Enums/MeansOfPayment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace PhpTwinfield\Enums;

use MyCLabs\Enum\Enum;

/**
* @method static MeansOfPayment NONE()
* @method static MeansOfPayment PAYMENTFILE()
*/
class MeansOfPayment extends Enum
{
protected const NONE = "none";
protected const PAYMENTFILE = "paymentfile";
}
2 changes: 2 additions & 0 deletions tests/IntegrationTests/CustomerIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PhpTwinfield\CustomerCollectMandate;
use PhpTwinfield\DomDocuments\CustomersDocument;
use PhpTwinfield\Enums\CollectionSchema;
use PhpTwinfield\Enums\MeansOfPayment;
use PhpTwinfield\Mappers\CustomerMapper;
use PhpTwinfield\Office;
use PhpTwinfield\Response\Response;
Expand Down Expand Up @@ -174,6 +175,7 @@ public function testSendCustomerWorks()
$customer->setName('Customer 0');
$customer->setDueDays('30');
$customer->setPayAvailable(true);
$customer->setMeansOfPayment(MeansOfPayment::PAYMENTFILE());
$customer->setPayCode('SEPANLDD');

$address = new CustomerAddress();
Expand Down
1 change: 1 addition & 0 deletions tests/IntegrationTests/resources/customerSendRequest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<firstrundate>20180608</firstrundate>
</collectmandate>
<collectionschema>core</collectionschema>
<meansofpayment>paymentfile</meansofpayment>
</financials>
<addresses>
<address type="invoice" default="true">
Expand Down