Skip to content

Commit

Permalink
addDocumentPaymentMeanToDirectDebit() now contains $creditorReference…
Browse files Browse the repository at this point in the history
…ID parameter (#54)

* addDocumentPaymentMeanToDirectDebit() now contains $creditorReferenceID parameter

* Fixed backwards-compatibility breaking change

* Referenced PaymentMeans code lists
  • Loading branch information
danielmarschall authored May 23, 2024
1 parent b778941 commit 8f86816
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/ZugferdDocumentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use DOMDocument;
use DOMXPath;

use horstoeko\zugferd\codelists\ZugferdPaymentMeans;

/**
* Class representing the document builder for outgoing documents
*
Expand Down Expand Up @@ -2422,7 +2424,7 @@ public function addDocumentPaymentMean(string $typecode, ?string $information =
*/
public function addDocumentPaymentMeanToCreditTransfer(string $payeeIban, ?string $payeeAccountName = null, ?string $payeePropId = null, ?string $payeeBic = null): ZugferdDocumentBuilder
{
$paymentMeans = $this->getObjectHelper()->getTradeSettlementPaymentMeansType("58");
$paymentMeans = $this->getObjectHelper()->getTradeSettlementPaymentMeansType(ZugferdPaymentMeans::UNTDID_4461_58);
$payeefinancialaccount = $this->getObjectHelper()->getCreditorFinancialAccountType($payeeIban, $payeeAccountName, $payeePropId);
$payeefinancialInstitution = $this->getObjectHelper()->getCreditorFinancialInstitutionType($payeeBic);

Expand All @@ -2439,17 +2441,24 @@ public function addDocumentPaymentMeanToCreditTransfer(string $payeeIban, ?strin
*
* @param string $buyerIban
* Direct debit: ID of the account to be debited
* @param string|null $creditorReferenceID
* Identifier of the creditor (German: "Glaeubiger ID").
* It can also be set using setDocumentGeneralPaymentInformation().
* @return ZugferdDocumentBuilder
*/
public function addDocumentPaymentMeanToDirectDebit(string $buyerIban): ZugferdDocumentBuilder
public function addDocumentPaymentMeanToDirectDebit(string $buyerIban, ?string $creditorReferenceID = null): ZugferdDocumentBuilder
{
$paymentMeans = $this->getObjectHelper()->getTradeSettlementPaymentMeansType("59");
$paymentMeans = $this->getObjectHelper()->getTradeSettlementPaymentMeansType(ZugferdPaymentMeans::UNTDID_4461_59);
$buyerfinancialaccount = $this->getObjectHelper()->getDebtorFinancialAccountType($buyerIban);

$this->getObjectHelper()->tryCall($paymentMeans, "setPayerPartyDebtorFinancialAccount", $buyerfinancialaccount);

$this->getObjectHelper()->tryCallAll($this->headerTradeSettlement, ["addToSpecifiedTradeSettlementPaymentMeans", "setSpecifiedTradeSettlementPaymentMeans"], $paymentMeans);

if (!is_null($creditorReferenceID)) {
$this->getObjectHelper()->tryCall($this->headerTradeSettlement, "setCreditorReferenceID", $this->getObjectHelper()->getIdType($creditorReferenceID));
}

return $this;
}

Expand All @@ -2469,7 +2478,7 @@ public function addDocumentPaymentMeanToDirectDebit(string $buyerIban): ZugferdD
*/
public function addDocumentPaymentMeanToPaymentCard(string $cardType, string $cardId, ?string $cardHolderName = null): ZugferdDocumentBuilder
{
$paymentMeans = $this->getObjectHelper()->getTradeSettlementPaymentMeansType("48");
$paymentMeans = $this->getObjectHelper()->getTradeSettlementPaymentMeansType(ZugferdPaymentMeans::UNTDID_4461_48);
$financialCard = $this->getObjectHelper()->getTradeSettlementFinancialCardType($cardType, $cardId, $cardHolderName);

$this->getObjectHelper()->tryCall($paymentMeans, "setApplicableTradeSettlementFinancialCard", $financialCard);
Expand Down

0 comments on commit 8f86816

Please sign in to comment.