From 8f86816fd79c83c90a9a53f613b192cf53e580ff Mon Sep 17 00:00:00 2001 From: Daniel Marschall <28412477+danielmarschall@users.noreply.github.com> Date: Thu, 23 May 2024 05:07:08 +0200 Subject: [PATCH] addDocumentPaymentMeanToDirectDebit() now contains $creditorReferenceID parameter (#54) * addDocumentPaymentMeanToDirectDebit() now contains $creditorReferenceID parameter * Fixed backwards-compatibility breaking change * Referenced PaymentMeans code lists --- src/ZugferdDocumentBuilder.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ZugferdDocumentBuilder.php b/src/ZugferdDocumentBuilder.php index 006ea5fe..600ec450 100644 --- a/src/ZugferdDocumentBuilder.php +++ b/src/ZugferdDocumentBuilder.php @@ -13,6 +13,8 @@ use DOMDocument; use DOMXPath; +use horstoeko\zugferd\codelists\ZugferdPaymentMeans; + /** * Class representing the document builder for outgoing documents * @@ -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); @@ -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; } @@ -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);